This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Point to error in malformed /x{y,z}/
authorKarl Williamson <khw@cpan.org>
Thu, 7 Jan 2021 14:41:47 +0000 (07:41 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 20 Jan 2021 13:51:49 +0000 (06:51 -0700)
Prior to this comment a curly quantifier that had an error in the bounds
pointed to the left brace.  Now the error message points to the first
bound that has a problem.

regcomp.c
t/re/reg_mesg.t

index 8e5305c..72c0de9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12668,7 +12668,7 @@ S_get_quantifier_value(pTHX_ RExC_state_t *pRExC_state,
     }
     else if (*start == '0') { /* grok_atoUV() fails for only two reasons:
                                  leading zeros or overflow */
-        RExC_parse++;
+        RExC_parse = (char * ) end;
 
         /* Perhaps too generic a msg for what is only failure from having
          * leading zeros, but this is how it's always behaved. */
@@ -12678,7 +12678,7 @@ S_get_quantifier_value(pTHX_ RExC_state_t *pRExC_state,
 
     /* Here, found a quantifier, but was too large; either it overflowed or was
      * too big a legal number */
-    RExC_parse++;
+    RExC_parse = (char * ) end;
     vFAIL2("Quantifier in {,} bigger than %d", REG_INFTY - 1);
 
     NOT_REACHED; /*NOTREACHED*/
index 145a91a..66c98dc 100644 (file)
@@ -174,7 +174,10 @@ my @death =
  '/((x)/' => 'Unmatched ( {#} m/({#}(x)/',
  '/{(}/' => 'Unmatched ( {#} m/{({#}}/',    # [perl #127599]
 
- "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 {#} m/x{{#}$inf_p1}/",
+ "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 {#} m/x{$inf_p1\{#}}/",
+ "/x{$inf_p1,}/" => "Quantifier in {,} bigger than $inf_m1 {#} m/x{$inf_p1\{#},}/",
+ "/x{01,2}/" => "Invalid quantifier in {,} {#} m/x{01{#},2}/",
+ "/x{1,02}/" => "Invalid quantifier in {,} {#} m/x{1,02{#}}/",
 
 
  '/x**/' => 'Nested quantifiers {#} m/x**{#}/',
@@ -456,7 +459,10 @@ my @death_utf8 = mark_as_utf8(
 
  '/ネ((ネ)/' => 'Unmatched ( {#} m/ネ({#}(ネ)/',
 
- "/ネ{$inf_p1}ネ/" => "Quantifier in {,} bigger than $inf_m1 {#} m/ネ{{#}$inf_p1}ネ/",
+ "/ネ{$inf_p1}ネ/" => "Quantifier in {,} bigger than $inf_m1 {#} m/ネ{$inf_p1\{#}}ネ/",
+ "/ネ{$inf_p1,}ネ/" => "Quantifier in {,} bigger than $inf_m1 {#} m/ネ{$inf_p1\{#},}ネ/",
+ "/ネ{01}ネ/" => "Invalid quantifier in {,} {#} m/ネ{01{#}}ネ/",
+ "/ネ{1,02}ネ/" => "Invalid quantifier in {,} {#} m/ネ{1,02{#}}ネ/",
 
 
  '/ネ**ネ/' => 'Nested quantifiers {#} m/ネ**{#}ネ/',