Describe __PACKAGE__ in perldelta
[p5sagit/p5-mst-13.2.git] / regexec.c
index c55eb97..630b130 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -42,7 +42,7 @@
  *
  ****    Alterations to Henry's code are...
  ****
- ****    Copyright (c) 1991-1994, Larry Wall
+ ****    Copyright (c) 1991-1997, Larry Wall
  ****
  ****    You may distribute under the terms of either the GNU General Public
  ****    License or the Artistic License, as specified in the README file.
@@ -290,7 +290,7 @@ I32 safebase;       /* no need to remember string in subbase */
                s++;
            }
        }
-       else if (SvPOK(prog->regstart) == 3) {
+       else if (SvTYPE(prog->regstart) == SVt_PVBM) {
            /* We know what string it must start with. */
            while ((s = fbm_instr((unsigned char*)s,
              (unsigned char*)strend, prog->regstart)) != NULL)
@@ -300,7 +300,7 @@ I32 safebase;       /* no need to remember string in subbase */
                s++;
            }
        }
-       else {
+       else {                          /* Optimized fbm_instr: */
            c = SvPVX(prog->regstart);
            while ((s = ninstr(s, strend, c, c + SvCUR(prog->regstart))) != NULL)
            {
@@ -529,18 +529,26 @@ got_it:
     prog->exec_tainted = regtainted;
 
     /* make sure $`, $&, $', and $digit will work later */
-    if (!safebase && (strbeg != prog->subbase)) {
-       I32 i = strend - startpos + (stringarg - strbeg);
-       s = savepvn(strbeg, i);
-       Safefree(prog->subbase);
-       prog->subbase = s;
-       prog->subbeg = prog->subbase;
-       prog->subend = prog->subbase + i;
-       s = prog->subbase + (stringarg - strbeg);
-       for (i = 0; i <= prog->nparens; i++) {
-           if (prog->endp[i]) {
-               prog->startp[i] = s + (prog->startp[i] - startpos);
-               prog->endp[i] = s + (prog->endp[i] - startpos);
+    if (strbeg != prog->subbase) {
+       if (safebase) {
+           if (prog->subbase) {
+               Safefree(prog->subbase);
+               prog->subbase = Nullch;
+           }
+       }
+       else {
+           I32 i = strend - startpos + (stringarg - strbeg);
+           s = savepvn(strbeg, i);
+           Safefree(prog->subbase);
+           prog->subbase = s;
+           prog->subbeg = prog->subbase;
+           prog->subend = prog->subbase + i;
+           s = prog->subbase + (stringarg - strbeg);
+           for (i = 0; i <= prog->nparens; i++) {
+               if (prog->endp[i]) {
+                   prog->startp[i] = s + (prog->startp[i] - startpos);
+                   prog->endp[i] = s + (prog->endp[i] - startpos);
+               }
            }
        }
     }
@@ -626,8 +634,11 @@ char *prog;
 #define sayNO goto no
 #define saySAME(x) if (x) goto yes; else goto no
        if (regnarrate) {
-           PerlIO_printf(Perl_debug_log, "%*s%2d%-8.8s\t<%.10s>\n", regindent*2, "",
-               scan - regprogram, regprop(scan), locinput);
+           SV *prop = sv_newmortal();
+           regprop(prop, scan);
+           PerlIO_printf(Perl_debug_log, "%*s%2d%-8.8s\t<%.10s>\n",
+                         regindent*2, "", scan - regprogram,
+                         SvPVX(prop), locinput);
        }
 #else
 #define sayYES return 1
@@ -888,8 +899,8 @@ char *prog;
 
 #ifdef DEBUGGING
                if (regnarrate)
-                   PerlIO_printf(Perl_debug_log, "%*s  %d  %lx\n", regindent*2, "",
-                       n, (long)cc);
+                   PerlIO_printf(Perl_debug_log, "%*s  %ld  %lx\n", regindent*2, "",
+                       (long)n, (long)cc);
 #endif
 
                /* If degenerate scan matches "", assume scan done. */
@@ -1093,7 +1104,8 @@ char *prog;
                sayNO;
            break;
        default:
-           PerlIO_printf(PerlIO_stderr(), "%x %d\n",(unsigned)scan,scan[1]);
+           PerlIO_printf(PerlIO_stderr(), "%lx %d\n",
+                         (unsigned long)scan, scan[1]);
            FAIL("regexp memory corruption");
        }
        scan = next;