From bfab19a52f61b3eb0f93cff5bb0e5aff3eda9fa0 Mon Sep 17 00:00:00 2001
From: Alex Vandiver <alex@chmrr.net>
Date: Sun, 22 Mar 2015 23:08:24 -0400
Subject: Fix "...without parentheses is ambuguous" warning for UTF-8 function
 names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

While isWORDCHAR_lazy_if is UTF-8 aware, checking advanced byte-by-byte.
This lead to errors of the form:

   Passing malformed UTF-8 to "XPosixWord" is deprecated
   Malformed UTF-8 character (unexpected continuation byte 0x9d, with
     no preceding start byte)
   Warning: Use of "�" without parentheses is ambiguous

Use UTF8SKIP to advance character-by-character, not byte-by-byte.

(cherry picked from commit 8ce2ba821761a7ada1e1def512c0374977759cf7)

Bug-Debian: https://bugs.debian.org/822336
Patch-Name: fixes/5.20.3/parentheses_ambiguous_warning_utf8_functions.diff
---
 t/lib/warnings/toke | 10 ++++++++++
 toke.c              |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index aabdda0ed3..c880f07992 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -1531,3 +1531,13 @@ EnFraçais
 print $v;
 EXPECT
 Comme ca!
+########
+# toke.c
+# Fix 'Use of "..." without parentheses is ambiguous' warning for
+# Unicode function names
+use utf8;
+use warnings;
+sub 𝛃(;$) { return 0; }
+my $v = 𝛃 - 5;
+EXPECT
+Warning: Use of "𝛃" without parentheses is ambiguous at - line 7.
diff --git a/toke.c b/toke.c
index c4657ebb53..899712b8ac 100644
--- a/toke.c
+++ b/toke.c
@@ -1997,7 +1997,7 @@ S_check_uni(pTHX)
 	PL_last_uni++;
     s = PL_last_uni;
     while (isWORDCHAR_lazy_if(s,UTF) || *s == '-')
-	s++;
+	s += UTF ? UTF8SKIP(s) : 1;
     if ((t = strchr(s, '(')) && t < PL_bufptr)
 	return;
 
