Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | s/re_exec\b/re_execute/g, for compatibility with BSD. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
6a26eb349743852f9c215d9cc5a9f6b2 |
| User & Date: | stephan 2013-01-02 11:39:51.686 |
Context
|
2013-01-02
| ||
| 12:19 | Fixed 2 string pointer type warnings reported on the mailing list. ... (check-in: 46af6b8260 user: stephan tags: trunk) | |
| 11:39 | s/re_exec\b/re_execute/g, for compatibility with BSD. ... (check-in: 6a26eb3497 user: stephan tags: trunk) | |
| 10:47 | Fixed JSON-side warnings reported by Baptiste Daroussin. ... (check-in: 8fec4c959c user: stephan tags: trunk) | |
Changes
Changes to src/diff.c.
| ︙ | ︙ | |||
421 422 423 424 425 426 427 |
*/
static int re_dline_match(
ReCompiled *pRe, /* The regular expression to be matched */
DLine *aDLine, /* First of N DLines to compare against */
int N /* Number of DLines to check */
){
while( N-- ){
| | | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
*/
static int re_dline_match(
ReCompiled *pRe, /* The regular expression to be matched */
DLine *aDLine, /* First of N DLines to compare against */
int N /* Number of DLines to check */
){
while( N-- ){
if( re_execute(pRe, aDLine->z, LENGTH(aDLine)) ){
return 1;
}
aDLine++;
}
return 0;
}
|
| ︙ | ︙ |
Changes to src/regexp.c.
| ︙ | ︙ | |||
176 177 178 179 180 181 182 |
static int re_space_char(int c){
return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f';
}
/* Run a compiled regular expression on the zero-terminated input
** string zIn[]. Return true on a match and false if there is no match.
*/
| | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
static int re_space_char(int c){
return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f';
}
/* Run a compiled regular expression on the zero-terminated input
** string zIn[]. Return true on a match and false if there is no match.
*/
int re_execute(ReCompiled *pRe, const unsigned char *zIn, int nIn){
ReStateSet aStateSet[2], *pThis, *pNext;
ReStateNumber aSpace[100];
ReStateNumber *pToFree;
unsigned int i = 0;
unsigned int iSwap = 0;
int c = RE_EOF+1;
int cPrev = 0;
|
| ︙ | ︙ | |||
273 274 275 276 277 278 279 |
}
case RE_OP_GOTO: {
re_add_state(pThis, x+pRe->aArg[x]);
break;
}
case RE_OP_ACCEPT: {
rc = 1;
| | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
}
case RE_OP_GOTO: {
re_add_state(pThis, x+pRe->aArg[x]);
break;
}
case RE_OP_ACCEPT: {
rc = 1;
goto re_execute_end;
}
case RE_OP_CC_INC:
case RE_OP_CC_EXC: {
int j = 1;
int n = pRe->aArg[x];
int hit = 0;
for(j=1; j>0 && j<n; j++){
|
| ︙ | ︙ | |||
305 306 307 308 309 310 311 |
}
}
}
}
for(i=0; i<pNext->nState; i++){
if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; }
}
| | | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
}
}
}
}
for(i=0; i<pNext->nState; i++){
if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; }
}
re_execute_end:
fossil_free(pToFree);
return rc;
}
/* Resize the opcode and argument arrays for an RE under construction.
*/
static int re_resize(ReCompiled *p, int N){
|
| ︙ | ︙ | |||
597 598 599 600 601 602 603 |
fossil_free(pRe->aOp);
fossil_free(pRe->aArg);
}
}
/*
** Compile a textual regular expression in zIn[] into a compiled regular
| | | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
fossil_free(pRe->aOp);
fossil_free(pRe->aArg);
}
}
/*
** Compile a textual regular expression in zIn[] into a compiled regular
** expression suitable for us by re_execute() and return a pointer to the
** compiled regular expression in *ppRe. Return NULL on success or an
** error message if something goes wrong.
*/
const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){
ReCompiled *pRe;
const char *zErr;
int i, j;
|
| ︙ | ︙ | |||
698 699 700 701 702 703 704 |
sqlite3_result_error_nomem(context);
return;
}
sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free);
}
zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
if( zStr!=0 ){
| | | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
sqlite3_result_error_nomem(context);
return;
}
sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free);
}
zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
if( zStr!=0 ){
sqlite3_result_int(context, re_execute(pRe, zStr, -1));
}
}
/*
** Invoke this routine in order to install the REGEXP function in an
** SQLite database connection.
**
|
| ︙ | ︙ | |||
729 730 731 732 733 734 735 |
int ln = 0;
int n;
char zLine[2000];
while( fgets(zLine, sizeof(zLine), in) ){
ln++;
n = (int)strlen(zLine);
while( n && (zLine[n-1]=='\n' || zLine[n-1]=='\r') ) n--;
| | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
int ln = 0;
int n;
char zLine[2000];
while( fgets(zLine, sizeof(zLine), in) ){
ln++;
n = (int)strlen(zLine);
while( n && (zLine[n-1]=='\n' || zLine[n-1]=='\r') ) n--;
if( re_execute(pRe, (const unsigned char*)zLine, n) ){
printf("%s:%d:%.*s\n", zFile, ln, n, zLine);
}
}
}
/*
** COMMAND: test-grep
|
| ︙ | ︙ |