diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-03-20 11:42:18 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-05-22 13:05:56 -0600 |
commit | 779fedd7c3021f013726c8f53cb9e66c54637ebf (patch) | |
tree | 56aaa2357ba00dac0cc99aa1c2ba5648a72b4418 /regcomp.c | |
parent | 1fdd5e539a93d9e9573e769f06c0f3d3c3d7e3ac (diff) | |
download | perl-779fedd7c3021f013726c8f53cb9e66c54637ebf.tar.gz |
regcomp.c: Actually emit proper warning
Before this commit, /\g/ raised the wrong warning
Reference to invalid group 0
This rearranges the code so that the proper warning is emitted.
Unterminated \g... pattern
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -10673,8 +10673,14 @@ tryagain: goto parse_named_seq; } } num = atoi(RExC_parse); - if (isg && num == 0) - vFAIL("Reference to invalid group 0"); + if (isg && num == 0) { + if (*RExC_parse == '0') { + vFAIL("Reference to invalid group 0"); + } + else { + vFAIL("Unterminated \\g... pattern"); + } + } if (isrel) { num = RExC_npar - num; if (num < 1) @@ -10687,8 +10693,6 @@ tryagain: char * const parse_start = RExC_parse - 1; /* MJD */ while (isDIGIT(*RExC_parse)) RExC_parse++; - if (parse_start == RExC_parse - 1) - vFAIL("Unterminated \\g... pattern"); if (hasbrace) { if (*RExC_parse != '}') vFAIL("Unterminated \\g{...} pattern"); |