In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ff4e2b11ab19d0c806a3dc09308d1b393971b8aa?hp=16d1d8bdaf1e7c1c3ad11abc246622d1e5c3b26a>

- Log -----------------------------------------------------------------
commit ff4e2b11ab19d0c806a3dc09308d1b393971b8aa
Author: Dagfinn Ilmari MannsÃ¥ker <[email protected]>
Date:   Mon Nov 14 20:05:31 2016 +0100

    Fix error message for unclosed \N{ in regcomp
    
    An unclosed \N{ that made it through to the regex engine rather than
    being handled by the lexer would erroneously trigger the error for
    "\N{NAME} must be resolved by the lexer".
    
    This separates the check for the missing trailing } and issues the
    correct error message for this.
-----------------------------------------------------------------------

Summary of changes:
 regcomp.c     | 8 +++++---
 t/re/re_tests | 5 ++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index ac66432..332cf00 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12005,13 +12005,15 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
 
     RExC_parse++;      /* Skip past the '{' */
 
-    if (! (endbrace = strchr(RExC_parse, '}'))  /* no trailing brace */
-       || ! (endbrace == RExC_parse            /* nothing between the {} */
+    if (! (endbrace = strchr(RExC_parse, '}'))) { /* no trailing brace */
+        vFAIL2("Missing right brace on \\%c{}", 'N');
+    }
+    else if(!(endbrace == RExC_parse           /* nothing between the {} */
               || (endbrace - RExC_parse >= 2   /* U+ (bad hex is checked... */
                   && strnEQ(RExC_parse, "U+", 2)))) /* ... below for a better
                                                        error msg) */
     {
-       if (endbrace) RExC_parse = endbrace;    /* position msg's '<--HERE' */
+       RExC_parse = endbrace;  /* position msg's '<--HERE' */
        vFAIL("\\N{NAME} must be resolved by the lexer");
     }
 
diff --git a/t/re/re_tests b/t/re/re_tests
index 046beaa..1797ddc 100644
--- a/t/re/re_tests
+++ b/t/re/re_tests
@@ -1478,7 +1478,10 @@ abc\N    abc\n   n
 [\N{U+}]       -       c       -       Invalid hexadecimal number
 \N{U+4AG3}     -       c       -       Invalid hexadecimal number
 [\N{U+4AG3}]   -       c       -       Invalid hexadecimal number
-abc\N{def      -       c       -       \\N{NAME} must be resolved by the lexer
+abc\N{def}     -       c       -       \\N{NAME} must be resolved by the lexer
+abc\N{U+4AG3   -       c       -       Missing right brace on \\N{}
+abc\N{def      -       c       -       Missing right brace on \\N{}
+abc\N{ -       c       -       Missing right brace on \\N{}
 
 # Verify that under /x that still cant have space before left brace
 /abc\N {U+41}/x        -       c       -       Missing braces

--
Perl5 Master Repository

Reply via email to