diff options
author | Daniel C. Sobral <dcs@FreeBSD.org> | 2000-07-02 10:58:07 +0000 |
---|---|---|
committer | Daniel C. Sobral <dcs@FreeBSD.org> | 2000-07-02 10:58:07 +0000 |
commit | e6a886d8dbcf8e1f3e9a252369051f15af41f8ab (patch) | |
tree | 04268007e5ad6704e4d41f71ced6d06af046f24d /lib/libc/regex/engine.c | |
parent | 5ead635430dfdbe9d23ffb332a519dbd937239cf (diff) |
Notes
Diffstat (limited to 'lib/libc/regex/engine.c')
-rw-r--r-- | lib/libc/regex/engine.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 9d11f543bb5b..8bc3de8e9d13 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); |