From b7e6151cbc27942266f736d4706550bc35a29639 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 18 Dec 2014 22:10:49 -0800 Subject: Also allow /\N{}/ See 4cbd7e223 and ticket #123417. If a charnames handler returns the empty string for a particular name, then the regular expression stringifies with an empty \N{} in it. This needs to round-trip properly (eval "/$qr/"), just like \N{U+...}. --- t/re/pat_advanced.t | 6 ++++++ toke.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index ea8974129b..c210e2e06e 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -2356,6 +2356,12 @@ EOP "afoot" =~ eval "qr/$qr/"; is "$1" || $@, "foo", 'multichar \N{...} stringified and retoked'; } + { # empty \N{...} tripping roundly + BEGIN { $^H{charnames} = sub { "" } } + my $qr = qr$(a\N{foo}t)$; + "at" =~ eval "qr/$qr/"; + is "$1" || $@, "at", 'empty \N{...} stringified and retoked'; + } # diff --git a/toke.c b/toke.c index c47e2c2dae..06ec26ab51 100644 --- a/toke.c +++ b/toke.c @@ -2492,6 +2492,9 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e) PERL_ARGS_ASSERT_GET_AND_CHECK_BACKSLASH_N_NAME; + if (!SvCUR(res)) + return res; + if (UTF && ! is_utf8_string_loc((U8 *) backslash_ptr, e - backslash_ptr, &first_bad_char_loc)) -- cgit v1.2.1