Change 33175 by [EMAIL PROTECTED] on 2008/02/01 20:32:00

        Integrate:
        [ 31303]
        Subject: Re: [perl #43015] regex /.*\z/ doesn't matches strings ending 
with \n
        From: demerphq <[EMAIL PROTECTED]>
        Date: Mon, 28 May 2007 19:46:04 +0200
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 31408]
        add test for, and update comments for, old defined($1) oddity.
        
        Some code in regexec.c had a comment to the effect that without
        this code, Dynaloader failed (this is back at 5.6.0). Replace the
        comments with something more specific, and add a test for it
        (basically without the code $1 is '' rather than undefined
        sometimes).
        
        [ 31507]
        Subject: [PATCH regcomp.c] regclass on EBCDIC platforms
        From: Benjamin Carter <[EMAIL PROTECTED]>
        Date: Fri, 29 Jun 2007 23:42:59 -0500
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/maint-5.8/perl/regcomp.c#115 integrate
... //depot/maint-5.8/perl/regexec.c#98 integrate
... //depot/maint-5.8/perl/t/op/re_tests#19 integrate

Differences ...

==== //depot/maint-5.8/perl/regcomp.c#115 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#114~32394~   2007-11-18 14:16:34.000000000 -0800
+++ perl/regcomp.c      2008-02-01 12:32:00.000000000 -0800
@@ -1712,7 +1712,6 @@
 {
     register regexp *r;
     regnode *scan;
-    regnode *first;
     I32 flags;
     I32 minlen = 0;
     I32 sawplus = 0;
@@ -1860,21 +1859,26 @@
        struct regnode_charclass_class ch_class;
        int stclass_flag;
        I32 last_close = 0;
-
-       first = scan;
+        regnode *first= scan;
+        regnode *first_next= regnext(first);
+       
        /* Skip introductions and multiplicators >= 1. */
        while ((OP(first) == OPEN && (sawopen = 1)) ||
               /* An OR of *one* alternative - should not happen now. */
-           (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) ||
+           (OP(first) == BRANCH && OP(first_next) != BRANCH) ||
            (OP(first) == PLUS) ||
            (OP(first) == MINMOD) ||
               /* An {n,m} with n>0 */
-           (PL_regkind[(U8)OP(first)] == CURLY && ARG1(first) > 0) ) {
+           (PL_regkind[(U8)OP(first)] == CURLY && ARG1(first) > 0) ||
+           (OP(first) == NOTHING && PL_regkind[OP(first_next)] != END ))
+       {
+               
                if (OP(first) == PLUS)
                    sawplus = 1;
                else
                    first += regarglen[(U8)OP(first)];
                first = NEXTOPER(first);
+               first_next= regnext(first);
        }
 
        /* Starting-point info. */
@@ -3997,12 +4001,16 @@
                {
                    if (isLOWER(prevvalue)) {
                        for (i = prevvalue; i <= ceilvalue; i++)
-                           if (isLOWER(i))
+                           if (isLOWER(i) && !ANYOF_BITMAP_TEST(ret,i)) {
+                               stored++;
                                ANYOF_BITMAP_SET(ret, i);
+                           }
                    } else {
                        for (i = prevvalue; i <= ceilvalue; i++)
-                           if (isUPPER(i))
+                           if (isUPPER(i) && !ANYOF_BITMAP_TEST(ret,i)) {
+                               stored++;
                                ANYOF_BITMAP_SET(ret, i);
+                           }
                    }
                }
                else

==== //depot/maint-5.8/perl/regexec.c#98 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#97~30927~    2007-04-12 08:03:57.000000000 -0700
+++ perl/regexec.c      2008-02-01 12:32:00.000000000 -0800
@@ -241,9 +241,8 @@
      * requiring null fields (pat.t#187 and split.t#{13,14}
      * (as of patchlevel 7877)  will fail.  Then again,
      * this code seems to be necessary or otherwise
-     * building DynaLoader will fail:
-     * "Error: '*' not in typemap in DynaLoader.xs, line 164"
-     * --jhi */
+     * this erroneously leaves $1 defined: "1" =~ /^(?:(\d)x)?\d$/
+     * --jhi updated by dapm */
     for (i = *PL_reglastparen + 1; (U32)i <= PL_regnpar; i++) {
        if (i > PL_regsize)
            PL_regstartp[i] = -1;
@@ -1484,7 +1483,7 @@
                    if (regtry(prog, s))
                        goto got_it;
                  after_try:
-                   if (s >= end)
+                   if (s > end)
                        goto phooey;
                    if (prog->reganch & RE_USE_INTUIT) {
                        s = re_intuit_start(prog, sv, s + 1, strend, flags, 
NULL);
@@ -1891,13 +1890,12 @@
     /* Tests pat.t#187 and split.t#{13,14} seem to depend on this code.
      * Actually, the code in regcppop() (which Ilya may be meaning by
      * PL_reglastparen), is not needed at all by the test suite
-     * (op/regexp, op/pat, op/split), but that code is needed, oddly
-     * enough, for building DynaLoader, or otherwise this
-     * "Error: '*' not in typemap in DynaLoader.xs, line 164"
-     * will happen.  Meanwhile, this code *is* needed for the
+     * (op/regexp, op/pat, op/split), but that code is needed otherwise
+     * this erroneously leaves $1 defined: "1" =~ /^(?:(\d)x)?\d$/
+     * Meanwhile, this code *is* needed for the
      * above-mentioned test suite tests to succeed.  The common theme
      * on those tests seems to be returning null fields from matches.
-     * --jhi */
+     * --jhi updated by dapm */
 #if 1
     if (prog->nparens) {
        I32 *sp = prog->startp;

==== //depot/maint-5.8/perl/t/op/re_tests#19 (text) ====
Index: perl/t/op/re_tests
--- perl/t/op/re_tests#18~30626~        2007-03-18 16:32:15.000000000 -0700
+++ perl/t/op/re_tests  2008-02-01 12:32:00.000000000 -0800
@@ -1017,3 +1017,6 @@
 (x|y|z[QW]){1,5}(longish|loquatious|excessive|overblown[QW]){1,5}      
xyzQzWlongishoverblownW y       $1-$2   zW-overblownW
 
 a*(?!) aaaab   n       -       -
+
+.*\z   foo\n   y       -       -
+^(?:(\d)x)?\d$ 1       y       ${\(defined($1)?1:0)}   0       
End of Patch.

Reply via email to