summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/regex/engine.c')
-rw-r--r--lib/libc/regex/engine.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c
index 9d11f54..8bc3de8 100644
--- a/lib/libc/regex/engine.c
+++ b/lib/libc/regex/engine.c
@@ -180,7 +180,7 @@ int eflags;
/* prescreening; this does wonders for this rather slow code */
if (g->must != NULL) {
- if(g->charjump != NULL && g->matchjump != NULL) {
+ if (g->charjump != NULL && g->matchjump != NULL) {
mustlen = -g->mlen;
mustfirst = g->must;
mustlast = g->must + g->mlen - 1;
@@ -188,21 +188,21 @@ int eflags;
matchjump = g->matchjump;
bmps = stop;
pp = mustlast;
- for(bmp = start+g->mlen-1; bmp < bmps;) {
+ for (bmp = start+g->mlen-1; bmp < bmps;) {
/* Fast skip non-matches */
- while(bmp < bmps && charjump[*bmp])
+ while (bmp < bmps && charjump[*bmp])
bmp += charjump[*bmp];
- if(bmp >= bmps)
+ if (bmp >= bmps)
break;
/* Greedy matcher */
/* We depend on not being used for
* for strings of length 1
*/
- while(*--bmp == *--pp && pp != mustfirst);
+ while (*--bmp == *--pp && pp != mustfirst);
- if(*bmp == *pp)
+ if (*bmp == *pp)
break;
/* Jump to next possible match */
@@ -211,8 +211,9 @@ int eflags;
bmp += (cj < mj ? mj : cj);
pp = mustlast;
}
- if(pp != mustfirst)
+ if (pp != mustfirst)
return(REG_NOMATCH);
+ dp = bmp;
} else {
for (dp = start; dp < stop; dp++)
if (*dp == g->must[0] &&
@@ -239,6 +240,10 @@ int eflags;
SETUP(m->empty);
CLEAR(m->empty);
+ /* Adjust start according to moffset, to speed things up */
+ if (g->moffset > -1)
+ start = dp - g->moffset;
+
/* this loop does only one repetition except for backrefs */
for (;;) {
endp = fast(m, start, stop, gf, gl);
OpenPOWER on IntegriCloud