This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate prelen from struct regexp. Possibly we are hardcoding a bit
authorNicholas Clark <nick@ccl4.org>
Fri, 28 Dec 2007 23:17:20 +0000 (23:17 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 28 Dec 2007 23:17:20 +0000 (23:17 +0000)
to much, as the replacement assumes that the wrapping string has
exactly 1 character after the wrapped string [specifically ')'].

p4raw-id: //depot/perl@32757

regcomp.c
regexp.h

index 5c7ee09..ff099f5 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4281,7 +4281,6 @@ redo_first_pass:
     RXi_SET( r, ri );
     r->engine= RE_ENGINE_PTR;
     r->refcnt = 1;
-    RX_PRELEN(r) = plen;
     r->extflags = pm_flags;
     {
         bool has_p     = ((r->extflags & RXf_PMf_KEEPCOPY) == RXf_PMf_KEEPCOPY);
index 5b58697..37d92c5 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -98,7 +98,6 @@ typedef struct regexp {
         
         
         /* Information about the match that isn't often used */
-       I32 prelen;             /* length of precomp */
        /* wrapped can't be const char*, as it is returned by sv_2pv_flags */
        char *wrapped;          /* wrapped version of the pattern */
        I32 wraplen;            /* length of wrapped */
@@ -355,7 +354,10 @@ and check for NULL.
 
 /* For source compatibility. We used to store these explicitly.  */
 #define RX_PRECOMP(prog)               ((prog)->wrapped + (prog)->pre_prefix)
-#define RX_PRELEN(prog)                        ((prog)->prelen)
+/* FIXME? Are we hardcoding too much here and constraining plugin extension
+   writers? Specifically, the value 1 assumes that the wrapped version always
+   has exactly one character at the end, a ')'. Will that always be true?  */
+#define RX_PRELEN(prog)                        ((prog)->wraplen - (prog)->pre_prefix - 1)
 
 #endif /* PLUGGABLE_RE_EXTENSION */