aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/regexp.c
diff options
context:
space:
mode:
authordrh <>2022-07-03 18:12:43 +0000
committerdrh <>2022-07-03 18:12:43 +0000
commit0e4ab0db7ee162e5d73437d3650078c145a68839 (patch)
treebebdd411dde7f85c2ad2112a60877aa4d523a6ed /ext/misc/regexp.c
parentf28727f61e270ecbd58e52318d3895990ff66fe5 (diff)
downloadsqlite-0e4ab0db7ee162e5d73437d3650078c145a68839.tar.gz
sqlite-0e4ab0db7ee162e5d73437d3650078c145a68839.zip
Enhance the REGEXP extension so that the end-of-input indicate ("$") is
allowed to occur on one branch of an OR ("|"). [forum:/forumpost/0107d5d40dd273e2|Forum post 0107d5d40dd273e2], second issue. FossilOrigin-Name: 3c04d21e6c632feb3bea8d1fa76bedcbfe254b0dc59865633d158a3f1bddefba
Diffstat (limited to 'ext/misc/regexp.c')
-rw-r--r--ext/misc/regexp.c15
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{