make behavior of /(a{3})+/ like /(aaa)+/ w.r.t where it matches
authorIlya Zakharevich <ilya@math.berkeley.edu>
Fri, 21 Aug 1998 05:41:02 +0000 (01:41 -0400)
committerGurusamy Sarathy <gsar@cpan.org>
Wed, 23 Sep 1998 05:50:36 +0000 (05:50 +0000)
Message-Id: <199808210941.FAA16467@monk.mps.ohio-state.edu>
Subject: Re: your mail

p4raw-id: //depot/perl@1815

regexec.c
t/op/re_tests

index 0627e2b..2dac18d 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2546,14 +2546,14 @@ regrepeat_hard(regnode *p, I32 max, I32 *lp)
     register char *start;
     register char *loceol = PL_regeol;
     I32 l = 0;
-    I32 count = 0;
+    I32 count = 0, res = 1;
 
     if (!max)
        return 0;
 
     start = PL_reginput;
     if (UTF) {
-       while (PL_reginput < loceol && (scan = PL_reginput, regmatch(p))) {
+       while (PL_reginput < loceol && (scan = PL_reginput, res = regmatch(p))) {
            if (!count++) {
                l = 0;
                while (start < PL_reginput) {
@@ -2569,7 +2569,7 @@ regrepeat_hard(regnode *p, I32 max, I32 *lp)
        }
     }
     else {
-       while (PL_reginput < loceol && (scan = PL_reginput, regmatch(p))) {
+       while (PL_reginput < loceol && (scan = PL_reginput, res = regmatch(p))) {
            if (!count++) {
                *lp = l = PL_reginput - start;
                if (max != REG_INFTY && l*max < loceol - scan)
@@ -2579,7 +2579,7 @@ regrepeat_hard(regnode *p, I32 max, I32 *lp)
            }
        }
     }
-    if (PL_reginput < loceol)
+    if (!res)
        PL_reginput = scan;
     
     return count;
index d1b1cec..8bd175d 100644 (file)
@@ -335,6 +335,9 @@ a(?:b|(c|e){1,2}?|d)+?(.)   ace     y       $1$2    ce
 ^(a(?(1)\1)){4}$       aaaaaaaaaa      y       $1      aaaa
 ^(a(?(1)\1)){4}$       aaaaaaaaa       n       -       -
 ^(a(?(1)\1)){4}$       aaaaaaaaaaa     n       -       -
+((a{4})+)      aaaaaaaaa       y       $1      aaaaaaaa
+(((aa){2})+)   aaaaaaaaaa      y       $1      aaaaaaaa
+(((a{2}){2})+) aaaaaaaaaa      y       $1      aaaaaaaa
 (?:(f)(o)(o)|(b)(a)(r))*       foobar  y       $1:$2:$3:$4:$5:$6       f:o:o:b:a:r
 (?<=a)b        ab      y       $&      b
 (?<=a)b        cb      n       -       -