From 71aa9713eee83e4bb0c1dfcbeb7172791c56d4c0 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Fri, 23 Mar 2012 17:39:53 -0700 Subject: toke.c: "Precedence problem: open %s should be open(%s)" cleanup. --- t/lib/warnings/toke | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ toke.c | 17 ++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 313e5710b5..dd8dc3d517 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -773,6 +773,20 @@ open local *FOO; # should be ok EXPECT Precedence problem: open FOO should be open(FOO) at - line 2. ######## +# toke.c +use utf8; +use open qw( :utf8 :std ); +open FÒÒ || time; +EXPECT +Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4. +######## +# toke.c +use utf8; +use open qw( :utf8 :std ); +open ᒍOO || time; +EXPECT +Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4. +######## # toke.c (and [perl #16184]) open FOO => "<&0"; close FOO; EXPECT @@ -795,6 +809,40 @@ Precedence problem: open FOO should be open(FOO) at - line 10. ######## # toke.c $^W = 0 ; +use utf8; +use open qw( :utf8 :std ); +open FÒÒ || time; +{ + no warnings 'precedence' ; + open FÒÒ || time; + use warnings 'precedence' ; + open FÒÒ || time; +} +open FÒÒ || time; +EXPECT +Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5. +Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10. +Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12. +######## +# toke.c +use utf8; +use open qw( :utf8 :std ); +$^W = 0 ; +open ᒍÒÒ || time; +{ + no warnings 'precedence' ; + open ᒍÒÒ || time; + use warnings 'precedence' ; + open ᒍÒÒ || time; +} +open ᒍÒÒ || time; +EXPECT +Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5. +Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10. +Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12. +######## +# toke.c +$^W = 0 ; *foo *foo ; { no warnings 'ambiguous' ; diff --git a/toke.c b/toke.c index b90d9a85c8..5cfcc6788d 100644 --- a/toke.c +++ b/toke.c @@ -7722,8 +7722,14 @@ Perl_yylex(pTHX) s = SKIPSPACE1(s); if (isIDFIRST_lazy_if(s,UTF)) { const char *t; - for (d = s; isALNUM_lazy_if(d,UTF);) - d++; + for (d = s; isALNUM_lazy_if(d,UTF);) { + d += UTF ? UTF8SKIP(d) : 1; + if (UTF) { + while (UTF8_IS_CONTINUED(*d) && is_utf8_mark((U8*)d)) { + d += UTF ? UTF8SKIP(d) : 1; + } + } + } for (t=d; isSPACE(*t);) t++; if ( *t && strchr("|&*+-=!?:.", *t) && ckWARN_d(WARN_PRECEDENCE) @@ -7732,10 +7738,11 @@ Perl_yylex(pTHX) && !(t[0] == ':' && t[1] == ':') && !keyword(s, d-s, 0) ) { - int parms_len = (int)(d-s); + SV *tmpsv = newSVpvn_flags(s, (STRLEN)(d-s), + SVs_TEMP | (UTF ? SVf_UTF8 : 0)); Perl_warner(aTHX_ packWARN(WARN_PRECEDENCE), - "Precedence problem: open %.*s should be open(%.*s)", - parms_len, s, parms_len, s); + "Precedence problem: open %"SVf" should be open(%"SVf")", + SVfARG(tmpsv), SVfARG(tmpsv)); } } LOP(OP_OPEN,XTERM); -- cgit v1.2.1