fix for /(^|a)b/ breakage from Ilya Zakharevich
Gurusamy Sarathy [Tue, 28 Dec 1999 03:44:10 +0000 (03:44 +0000)]
p4raw-id: //depot/perl@4724

regcomp.c
t/op/re_tests

index f935190..3e7c012 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -545,9 +545,21 @@ S_study_chunk(pTHX_ regnode **scanp, I32 *deltap, regnode *last, scan_data_t *da
                    }
                }
                else if (flags & SCF_DO_STCLASS_AND) {
-                   cl_and(data->start_class, &accum);
-                   if (min1)
+                   if (min1) {
+                       cl_and(data->start_class, &accum);
                        flags &= ~SCF_DO_STCLASS;
+                   }
+                   else {
+                       /* Switch to OR mode: cache the old value of 
+                        * data->start_class */
+                       StructCopy(data->start_class, &and_with,
+                                  struct regnode_charclass_class);
+                       flags &= ~SCF_DO_STCLASS_AND;
+                       StructCopy(&accum, data->start_class,
+                                  struct regnode_charclass_class);
+                       flags |= SCF_DO_STCLASS_OR;
+                       data->start_class->flags |= ANYOF_EOS;
+                   }
                }
            }
            else if (code == BRANCHJ)   /* single branch is optimized. */
index e957609..d506e6e 100644 (file)
@@ -749,3 +749,4 @@ tt+$        xxxtt   y       -       -
 '(\.c(pp|xx|c)?$)'i    IO.c    y       $1      .c
 ^([a-z]:)      C:/     n       -       -
 '^\S\s+aa$'m   \nx aa  y       -       -
+(^|a)b ab      y       -       -