summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorChip Salzenberg <chip@perl.com>1997-03-07 03:46:38 +1200
committerChip Salzenberg <chip@atlantic.net>1997-03-09 11:57:19 +1200
commit5b5a24f7bf17586443d8cd7520981cbe87a0b29d (patch)
tree4f92b02091b594314226a0658c5d02396ee1ea72 /regcomp.c
parent7f78d98189c412252e923b039525e576dc0eca8d (diff)
downloadperl-5b5a24f7bf17586443d8cd7520981cbe87a0b29d.tar.gz
Ignore whitespace before +*? in //x
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/regcomp.c b/regcomp.c
index 0621c39231..4c34b59c61 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;