b8876f
From 86a48d83a7caf38c553000a250ed1359c235f55e Mon Sep 17 00:00:00 2001
b8876f
From: Tony Cook <tony@develop-help.com>
b8876f
Date: Thu, 19 Oct 2017 10:46:04 +1100
b8876f
Subject: [PATCH] (perl #132245) don't try to process a char range with no
b8876f
 preceding char
b8876f
MIME-Version: 1.0
b8876f
Content-Type: text/plain; charset=UTF-8
b8876f
Content-Transfer-Encoding: 8bit
b8876f
b8876f
A range like \N{}-0 eventually results in compilation failing, but
b8876f
before that, get_and_check_backslash_N_name() attempts to treat
b8876f
the memory before the empty output of \N{} as a character.
b8876f
b8876f
Petr Písař: Ported to 5.24.3.
b8876f
b8876f
Signed-off-by: Petr Písař <ppisar@redhat.com>
b8876f
---
b8876f
 t/lib/warnings/toke | 5 +++++
b8876f
 toke.c              | 4 ++--
b8876f
 2 files changed, 7 insertions(+), 2 deletions(-)
b8876f
b8876f
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
b8876f
index 493c8a2..4a521e0 100644
b8876f
--- a/t/lib/warnings/toke
b8876f
+++ b/t/lib/warnings/toke
b8876f
@@ -1509,3 +1509,8 @@ my $v = 𝛃 - 5;
b8876f
 EXPECT
b8876f
 OPTION regex
b8876f
 (Wide character.*\n)?Warning: Use of "𝛃" without parentheses is ambiguous
b8876f
+########
b8876f
+# NAME tr/// range with empty \N{} at the start
b8876f
+tr//\N{}-0/;
b8876f
+EXPECT
b8876f
+Unknown charname '' is deprecated at - line 1.
b8876f
diff --git a/toke.c b/toke.c
b8876f
index f2310cc..3d93fac 100644
b8876f
--- a/toke.c
b8876f
+++ b/toke.c
b8876f
@@ -2906,8 +2906,8 @@ S_scan_const(pTHX_ char *start)
b8876f
                  * at least one character, then see if this next one is a '-',
b8876f
                  * indicating the previous one was the start of a range.  But
b8876f
                  * don't bother if we're too close to the end for the minus to
b8876f
-                 * mean that. */
b8876f
-                if (*s != '-' || s >= send - 1 || s == start) {
b8876f
+                 * mean that, or if we haven't output any characters yet. */
b8876f
+                if (*s != '-' || s >= send - 1 || s == start || d == SvPVX(sv)) {
b8876f
 
b8876f
                     /* A regular character.  Process like any other, but first
b8876f
                      * clear any flags */
b8876f
-- 
b8876f
2.13.6
b8876f