From: Brian Fraser Date: Tue, 19 Jun 2012 20:05:18 +0000 (-0300) Subject: toke.c: Make new error UTF-8 safe X-Git-Tag: upstream/5.20.0~6327 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84159251c92a2b86596502042a94252226c7ba6a;p=platform%2Fupstream%2Fperl.git toke.c: Make new error UTF-8 safe Commit 0da72d5e623b55d88fb3772b9c91e8f2d1ea7c40 introduced a new error message, but did not account for UTF-8 source. --- diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index db4bbee..2a34811 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -163,6 +163,21 @@ Unknown regexp modifier "/q" at - line 3, near "=~ " Execution of - aborted due to compilation errors. ######## # toke.c +use utf8; +use open qw( :utf8 :std ); +$a =~ m/$foo/eネq; +$a =~ s/$foo/fool/seネq; + +EXPECT +OPTION fatal +Unknown regexp modifier "/e" at - line 4, near "=~ " +Unknown regexp modifier "/ネ" at - line 4, near "=~ " +Unknown regexp modifier "/q" at - line 4, near "=~ " +Unknown regexp modifier "/ネ" at - line 5, near "=~ " +Unknown regexp modifier "/q" at - line 5, near "=~ " +Execution of - aborted due to compilation errors. +######## +# toke.c use warnings 'syntax' ; s/(abc)/\1/; no warnings 'syntax' ; diff --git a/toke.c b/toke.c index 99c1e22..6d28ec0 100644 --- a/toke.c +++ b/toke.c @@ -9056,11 +9056,13 @@ S_pmflag(pTHX_ const char* const valid_flags, U32 * pmfl, char** s, char* charse * to allow only one */ const char c = **s; + STRLEN charlen = UTF ? UTF8SKIP(*s) : 1; - if (! strchr(valid_flags, c)) { - if (isALNUM(c)) { - yyerror(Perl_form(aTHX_ "Unknown regexp modifier \"/%c\"", c)); - (*s)++; + if ( charlen != 1 || ! strchr(valid_flags, c) ) { + if (isALNUM_lazy_if(*s, UTF)) { + yyerror_pv(Perl_form(aTHX_ "Unknown regexp modifier \"/%.*s\"", charlen, *s), + UTF ? SVf_UTF8 : 0); + (*s) += charlen; return TRUE; } return FALSE;