"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/re2search.cpp" between
bed-3.0.0.src.tar.xz and bed-3.0.1.src.tar.xz

About: bed is an adjustable data format binary editor.

re2search.cpp  (bed-3.0.0.src.tar.xz):re2search.cpp  (bed-3.0.1.src.tar.xz)
skipping to change at line 43 skipping to change at line 43
} }
*/ */
extern int standardascii(ScreenPart *); extern int standardascii(ScreenPart *);
#ifdef USE_RE2 #ifdef USE_RE2
extern const char *regexerrorstring; extern const char *regexerrorstring;
// bool PossibleMatchRange(string* min, string* max, int maxlen) const // bool PossibleMatchRange(string* min, string* max, int maxlen) const
#include <re2/re2.h> #include <re2/re2.h>
const char *Editor::replace(char *input,int inlen,int *outlen) { const char *Editor::replace(char *input,int inlen,int *outlen) {
using namespace std;
using namespace re2; using namespace re2;
StringPiece repl(re2replacestr,replacestrlen); StringPiece repl(re2replacestr,replacestrlen);
StringPiece zoekin(input,inlen); StringPiece zoekin(input,inlen);
static string out; static string out;
if(RE2::Extract(zoekin,*re2pattern, repl, &out)) { if(RE2::Extract(zoekin,*re2pattern, repl, &out)) {
*outlen= out.length(); *outlen= out.length();
return out.data(); return out.data();
} }
*outlen=0; *outlen=0;
return NULL; return NULL;
skipping to change at line 88 skipping to change at line 89
} }
*/ */
//bool Editor::re2searchgegs(const signed char *const str,int len,bool sense, bo ol doreplace) { //bool Editor::re2searchgegs(const signed char *const str,int len,bool sense, bo ol doreplace) {
bool Editor::re2searchgegs(SearchAim &aim) { bool Editor::re2searchgegs(SearchAim &aim) {
int len=aim.len; int len=aim.len;
if(len<=0) { if(len<=0) {
regexerrorstring=reinterpret_cast<const char *>(-1); regexerrorstring=reinterpret_cast<const char *>(-1);
output("Search string wrong size"); output("Search string wrong size");
return false; return false;
} }
using namespace std;
using namespace re2; using namespace re2;
// mem.setsearchstr(str, len) ; // mem.setsearchstr(str, len) ;
#if 0 #if 0
char aroundstr[len+3]; char aroundstr[len+3];
memcpy(aroundstr+1,aim.str,len); /*To get the match position I add () aro und the searchstr, memcpy(aroundstr+1,aim.str,len); /*To get the match position I add () aro und the searchstr,
because of this references (\num) to match ed groups are incremented with re2memcpy.*/ because of this references (\num) to match ed groups are incremented with re2memcpy.*/
aroundstr[0]='('; aroundstr[0]='(';
aroundstr[++len]=')'; aroundstr[++len]=')';
aroundstr[++len]='\0'; aroundstr[++len]='\0';
#endif #endif
skipping to change at line 239 skipping to change at line 242
} }
blnr+=nrblock; blnr+=nrblock;
int binlen=took-inblock,takelen=binlen; int binlen=took-inblock,takelen=binlen;
const int patlen=minnum(100,bs-bytes+1); const int patlen=minnum(100,bs-bytes+1);
OFFTYPE first=OFFTYPEINVALID; OFFTYPE first=OFFTYPEINVALID;
int firstlen=0; int firstlen=0;
bool list=islist; bool list=islist;
int terug=0; int terug=0;
OFFTYPE lastpos[boundaries] {}; #ifdef __clang__
OFFTYPE lastpos[boundaries];
memset(&lastpos,0,sizeof(OFFTYPE)*boundaries);
#else
OFFTYPE lastpos[boundaries] {};
#endif
while(took>0) { while(took>0) {
for(int shift=0;shift<boundaries;shift++) { for(int shift=0;shift<boundaries;shift++) {
const int diff=lastpos[shift]-(off+shift); const int diff=lastpos[shift]-(off+shift);
// const int added=shift+((diff>0)?((diff+bytes)/bytes)*bytes:0); // const int added=shift+((diff>0)?((diff+bytes)/bytes)*bytes:0);
const int added=shift+((diff>0)?diff:0); const int added=shift+((diff>0)?diff:0);
const int inbuf= inblock+added; const int inbuf= inblock+added;
const int count=datashown->fromascii((unsigned char *)formbuf,(unsigned c har *)(binbuf+inbuf),takelen-added); const int count=datashown->fromascii((unsigned char *)formbuf,(unsigned c har *)(binbuf+inbuf),takelen-added);
int matchlen; int matchlen;
int startpos=0; int startpos=0;
for(int pos;startpos<count&&((matchlen=re2match(formbuf+startpos,count-st artpos,&pos))>0);startpos+=ellen) { for(int pos;startpos<count&&((matchlen=re2match(formbuf+startpos,count-st artpos,&pos))>0);startpos+=ellen) {
skipping to change at line 478 skipping to change at line 486
} }
OFFTYPE Editor::re2searchnext(SearchAim &aim) { OFFTYPE Editor::re2searchnext(SearchAim &aim) {
if(!re2pattern) { if(!re2pattern) {
regexerrorstring="No previous (re2) search"; regexerrorstring="No previous (re2) search";
return OFFTYPEINVALID; return OFFTYPEINVALID;
} }
extern unsigned long long startuptime; extern unsigned long long startuptime;
SEARCHINTDEC( 0x4000000000/startuptime ) SEARCHINTDEC( 0x4000000000/startuptime )
using namespace std;
using namespace re2; using namespace re2;
char *const buf=(char *)alignedalloc(blocksize(),SECTORSIZE+blocksize()); char *const buf=(char *)alignedalloc(blocksize(),SECTORSIZE+blocksize());
BEDS_SIZE_T count,count2, begin=searchpos%blocksize(); BEDS_SIZE_T count,count2, begin=searchpos%blocksize();
char *bufbegin=begin+buf; char *bufbegin=begin+buf;
BLOCKTYPE bl=searchpos/blocksize(); BLOCKTYPE bl=searchpos/blocksize();
if((count=mem.getblock(bl++,buf))>=blocksize()) if((count=mem.getblock(bl++,buf))>=blocksize())
if((count2=mem.getblock(bl,buf+SECTORSIZE))>0) if((count2=mem.getblock(bl,buf+SECTORSIZE))>0)
count+=count2; count+=count2;
 End of changes. 4 change blocks. 
1 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)