summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-18 22:10:49 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-18 22:10:49 -0800
commitb7e6151cbc27942266f736d4706550bc35a29639 (patch)
treee2509b6f65b61c4fa8ea231ccc416399acd729d6
parent61a8c39717905c2678b615a1788db98001be8272 (diff)
downloadperl-b7e6151cbc27942266f736d4706550bc35a29639.tar.gz
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+...}.
-rw-r--r--t/re/pat_advanced.t6
-rw-r--r--toke.c3
2 files changed, 9 insertions, 0 deletions
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))