This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make regexp_paren_pair.start_tmp an offset
authorDavid Mitchell <davem@iabyn.com>
Wed, 16 May 2012 09:06:30 +0000 (10:06 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:53 +0000 (13:32 +0100)
Currently the start_tmp field is a pointer into the string, whereas the
the start and end fields are offsets within that string. Make start_tmp
an offset too for consistency.

regexec.c
regexp.h

index 559e061..8013d3f 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -366,12 +366,13 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor)
 /* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
        SSPUSHINT(rex->offs[p].end);
        SSPUSHINT(rex->offs[p].start);
-       SSPUSHPTR(rex->offs[p].start_tmp);
+       SSPUSHINT(rex->offs[p].start_tmp);
        SSPUSHINT(p);
        DEBUG_BUFFERS_r(PerlIO_printf(Perl_debug_log,
          "     saving \\%"UVuf" %"IVdf"(%"IVdf")..%"IVdf"\n",
-                     (UV)p, (IV)rex->offs[p].start,
-                     (IV)(rex->offs[p].start_tmp - PL_bostr),
+                     (UV)p,
+                     (IV)rex->offs[p].start,
+                     (IV)rex->offs[p].start_tmp,
                      (IV)rex->offs[p].end
        ));
     }
@@ -425,7 +426,7 @@ S_regcppop(pTHX_ regexp *rex)
     for ( ; i > 0; i -= REGCP_PAREN_ELEMS) {
        I32 tmps;
        U32 paren = (U32)SSPOPINT;
-       rex->offs[paren].start_tmp = (char *) SSPOPPTR;
+       rex->offs[paren].start_tmp = SSPOPINT;
        rex->offs[paren].start = SSPOPINT;
        tmps = SSPOPINT;
        if (paren <= rex->lastparen)
@@ -433,8 +434,9 @@ S_regcppop(pTHX_ regexp *rex)
        DEBUG_BUFFERS_r(
            PerlIO_printf(Perl_debug_log,
                          "     restoring \\%"UVuf" to %"IVdf"(%"IVdf")..%"IVdf"%s\n",
-                         (UV)paren, (IV)rex->offs[paren].start,
-                         (IV)(rex->offs[paren].start_tmp - PL_bostr),
+                         (UV)paren,
+                         (IV)rex->offs[paren].start,
+                         (IV)rex->offs[paren].start_tmp,
                          (IV)rex->offs[paren].end,
                          (paren > rex->lastparen ? "(no)" : ""));
        );
@@ -4537,14 +4539,14 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
 
        case OPEN:
            n = ARG(scan);  /* which paren pair */
-           rex->offs[n].start_tmp = locinput;
+           rex->offs[n].start_tmp = locinput - PL_bostr;
            if (n > PL_regsize)
                PL_regsize = n;
             lastopen = n;
            break;
        case CLOSE:
            n = ARG(scan);  /* which paren pair */
-           rex->offs[n].start = rex->offs[n].start_tmp - PL_bostr;
+           rex->offs[n].start = rex->offs[n].start_tmp;
            rex->offs[n].end = locinput - PL_bostr;
            /*if (n > PL_regsize)
                PL_regsize = n;*/
@@ -4566,7 +4568,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                         n = ARG(cursor);
                         if ( n <= lastopen ) {
                             rex->offs[n].start
-                                       = rex->offs[n].start_tmp - PL_bostr;
+                                       = rex->offs[n].start_tmp;
                             rex->offs[n].end = locinput - PL_bostr;
                             /*if (n > PL_regsize)
                             PL_regsize = n;*/
index 4782ac6..2f02157 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -61,7 +61,7 @@ typedef struct regexp_paren_pair {
      *   "abc" =~ /(.(?{print "[$1]"}))+/
      *outputs [][a][b]
      * This field is not part of the API.  */
-    char *start_tmp;
+    I32 start_tmp;
 } regexp_paren_pair;
 
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)