This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Combine common code
authorKarl Williamson <khw@cpan.org>
Tue, 21 Apr 2020 12:41:22 +0000 (06:41 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 12 Oct 2020 15:45:46 +0000 (09:45 -0600)
This bit of code occurs in two places.  Move it so that it gets executed
before the split, so it only has to be specified once.

regcomp.c

index a3186dd..052da88 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12633,12 +12633,13 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
 
     op = *RExC_parse;
 
+#ifdef RE_TRACK_PATTERN_OFFSETS
+    parse_start = RExC_parse;
+#endif
+
     if (op == '{') {
         const char* endptr;
        maxpos = NULL;
-#ifdef RE_TRACK_PATTERN_OFFSETS
-        parse_start = RExC_parse; /* MJD */
-#endif
        next = RExC_parse + 1;
        while (isDIGIT(*next) || *next == ',') {
            if (*next == ',') {
@@ -12791,9 +12792,6 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
       vFAIL("Regexp *+ operand could be empty");
 #endif
 
-#ifdef RE_TRACK_PATTERN_OFFSETS
-    parse_start = RExC_parse;
-#endif
     nextchar(pRExC_state);
 
     *flagp = HASWIDTH;