diff options
Diffstat (limited to 'ext/misc/regexp.c')
-rw-r--r-- | ext/misc/regexp.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/misc/regexp.c b/ext/misc/regexp.c index 52973cc73..d5b387205 100644 --- a/ext/misc/regexp.c +++ b/ext/misc/regexp.c @@ -328,7 +328,9 @@ static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){ } } for(i=0; i<pNext->nState; i++){ - if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; } + int x = pNext->aState[i]; + while( pRe->aOp[x]==RE_OP_GOTO ) x += pRe->aArg[x]; + if( pRe->aOp[x]==RE_OP_ACCEPT ){ rc = 1; break; } } re_match_end: sqlite3_free(pToFree); @@ -483,7 +485,6 @@ static const char *re_subcompile_string(ReCompiled *p){ iStart = p->nState; switch( c ){ case '|': - case '$': case ')': { p->sIn.i--; return 0; @@ -520,6 +521,10 @@ static const char *re_subcompile_string(ReCompiled *p){ re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1); break; } + case '$': { + re_append(p, RE_OP_MATCH, RE_EOF); + break; + } case '{': { int m = 0, n = 0; int sz, j; @@ -656,11 +661,7 @@ static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){ re_free(pRe); return zErr; } - if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){ - re_append(pRe, RE_OP_MATCH, RE_EOF); - re_append(pRe, RE_OP_ACCEPT, 0); - *ppRe = pRe; - }else if( pRe->sIn.i>=pRe->sIn.mx ){ + if( pRe->sIn.i>=pRe->sIn.mx ){ re_append(pRe, RE_OP_ACCEPT, 0); *ppRe = pRe; }else{ |