From: Chip Salzenberg Date: Thu, 6 Mar 1997 15:46:38 +0000 (+1200) Subject: Ignore whitespace before +*? in //x X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b5a24f7bf17586443d8cd7520981cbe87a0b29d;p=p5sagit%2Fp5-mst-13.2.git Ignore whitespace before +*? in //x --- diff --git a/regcomp.c b/regcomp.c index 0621c39..4c34b59 100644 --- a/regcomp.c +++ b/regcomp.c @@ -109,6 +109,7 @@ static void reginsert _((char, char *)); static void regoptail _((char *, char *)); static void regset _((char *, I32)); static void regtail _((char *, char *)); +static char* regwhite _((char *, char *)); static char* nextchar _((void)); /* @@ -943,6 +944,9 @@ tryagain: len++) { oldp = p; + + if (regflags & PMf_EXTENDED) + p = regwhite(p, regxend); switch (*p) { case '^': case '$': @@ -1021,22 +1025,12 @@ tryagain: break; } break; - case '#': - if (regflags & PMf_EXTENDED) { - while (p < regxend && *p != '\n') p++; - } - /* FALL THROUGH */ - case ' ': case '\t': case '\n': case '\r': case '\f': case '\v': - if (regflags & PMf_EXTENDED) { - p++; - len--; - continue; - } - /* FALL THROUGH */ default: ender = *p++; break; } + if (regflags & PMf_EXTENDED) + p = regwhite(p, regxend); if (ISMULT2(p)) { /* Back off on ?+*. */ if (len) p = oldp; @@ -1067,6 +1061,25 @@ tryagain: return(ret); } +static char * +regwhite(p, e) +char *p; +char *e; +{ + while (p < e) { + if (isSPACE(*p)) + ++p; + else if (*p == '#') { + do { + p++; + } while (p < e && *p != '\n'); + } + else + break; + } + return p; +} + static void regset(opnd, c) char *opnd;