This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Workaround for GNU Autoconf unescaped left brace
authorKarl Williamson <khw@cpan.org>
Mon, 10 Apr 2017 16:41:40 +0000 (10:41 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 18 Apr 2017 00:54:00 +0000 (18:54 -0600)
See [perl #130497]

GNU Autoconf depends on Perl, and will not work on Blead (and the
forthcoming Perl 5.26), due to a single unescaped '{', that has
previously been deprecated and is now fatal.  A patch for it has been in
the Autoconf repository since early 2013, but there has not been a
release since before then.

Because this is depended on by so much code, and because it is simpler
than trying to revert to making the fatality merely deprecated, this
patch simply changes perl to not die when compiled with the exact
pattern that trips up Autoconf.  Thus Autoconf can continue to work, but
any other patterns that use the now illegal construct will continue to
die.  If other code uses the exact pattern, they too will not die, but
the deprecation message continues to get raised.  The use of the left
brace in this particular pattern is not one where we envision using the
construct to mean something else, so a deprecation is suitable for the
foreseeable future.

regcomp.c
t/re/reg_mesg.t

index 810c457..54d641d 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13387,8 +13387,28 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                     * literal string, or when it's the first thing after
                     * something like "\b" */
                    if (len || (p > RExC_start && isALPHA_A(*(p -1)))) {
-                        RExC_parse = p + 1;
-                       vFAIL("Unescaped left brace in regex is illegal here");
+
+                        /* GNU Autoconf is depended on by a lot of code, and
+                         * can't seem to release a new version that avoids the
+                         * deprecation now made fatal.  (A commit to do so has
+                         * been in its repository since early 2013; only one
+                         * pattern is affected.)  As a work-around, don't
+                         * fatalize this if the pattern being compiled is the
+                         * precise one that trips up Autoconf.  See [perl
+                         * #130497] for more details. */
+                        if (memNEs(RExC_start, RExC_end - RExC_start,
+                                   "\\${[^\\}]*}"))
+                        {
+                            RExC_parse = p + 1;
+                            vFAIL("Unescaped left brace in regex is "
+                                  "illegal here");
+                        }
+                        if (PASS2) {
+                            ckWARNregdep(p + 1,
+                                        "Unescaped left brace in regex is "
+                                        "deprecated here (and will be fatal "
+                                        "in Perl 5.30), passed through");
+                        }
                    }
                    goto normal_default;
                 case '}':
index 597df92..b80b692 100644 (file)
@@ -652,6 +652,7 @@ my @deprecated = (
  '/.{/'         => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/.{{#}/',
  '/[x]{/'       => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/[x]{{#}/',
  '/\p{Latin}{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\p{Latin}{{#}/',
+ '/\\${[^\\}]*}/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\\${{#}[^\\}]*}/',
 );
 
 for my $strict ("", "use re 'strict';") {