diff options
author | Brian Fraser <fraserbn@gmail.com> | 2011-08-06 06:16:29 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-03-22 20:23:52 -0700 |
commit | 734ab32188dca45b1704abc89cd0f08809758da3 (patch) | |
tree | 359fa2a67dbba57783491070eed675385c03a2ac | |
parent | 7350962f469ccd5aa91df76014fab15c0a785530 (diff) | |
download | perl-734ab32188dca45b1704abc89cd0f08809758da3.tar.gz |
toke.c: S_no_op cleanup
-rw-r--r-- | t/lib/subs/subs | 25 | ||||
-rw-r--r-- | toke.c | 14 |
2 files changed, 34 insertions, 5 deletions
diff --git a/t/lib/subs/subs b/t/lib/subs/subs index d4539dbf3a..e0bb16eadb 100644 --- a/t/lib/subs/subs +++ b/t/lib/subs/subs @@ -80,3 +80,28 @@ Fred 1, 2; sub Fred { print $_[0] + $_[1], "\n" } EXPECT 3 +######## + +# Error - not predeclaring a sub +use utf8; +use open qw( :utf8 :std ); +Frèd 1,2 ; +sub Frèd {} +EXPECT +Number found where operator expected at - line 5, near "Frèd 1" + (Do you need to predeclare Frèd?) +syntax error at - line 5, near "Frèd 1" +Execution of - aborted due to compilation errors. +######## + +# Error - not predeclaring a sub in time +use utf8; +use open qw( :utf8 :std ); +ふれど 1,2 ; +use subs qw( ふれど ) ; +sub ふれど {} +EXPECT +Number found where operator expected at - line 5, near "ふれど 1" + (Do you need to predeclare ふれど?) +syntax error at - line 5, near "ふれど 1" +BEGIN not safe after errors--compilation aborted at - line 6. @@ -537,24 +537,28 @@ S_no_op(pTHX_ const char *const what, char *s) s = oldbp; else PL_bufptr = s; - yywarn(Perl_form(aTHX_ "%s found where operator expected", what), 0); + yywarn(Perl_form(aTHX_ "%s found where operator expected", what), UTF ? SVf_UTF8 : 0); if (ckWARN_d(WARN_SYNTAX)) { if (is_first) Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "\t(Missing semicolon on previous line?)\n"); else if (PL_oldoldbufptr && isIDFIRST_lazy_if(PL_oldoldbufptr,UTF)) { const char *t; - for (t = PL_oldoldbufptr; (isALNUM_lazy_if(t,UTF) || *t == ':'); t++) + for (t = PL_oldoldbufptr; (isALNUM_lazy_if(t,UTF) || *t == ':'); + t += UTF ? UTF8SKIP(t) : 1) NOOP; if (t < PL_bufptr && isSPACE(*t)) Perl_warner(aTHX_ packWARN(WARN_SYNTAX), - "\t(Do you need to predeclare %.*s?)\n", - (int)(t - PL_oldoldbufptr), PL_oldoldbufptr); + "\t(Do you need to predeclare %"SVf"?)\n", + SVfARG(newSVpvn_flags(PL_oldoldbufptr, (STRLEN)(t - PL_oldoldbufptr), + SVs_TEMP | (UTF ? SVf_UTF8 : 0)))); } else { assert(s >= oldbp); Perl_warner(aTHX_ packWARN(WARN_SYNTAX), - "\t(Missing operator before %.*s?)\n", (int)(s - oldbp), oldbp); + "\t(Missing operator before %"SVf"?)\n", + SVfARG(newSVpvn_flags(oldbp, (STRLEN)(s - oldbp), + SVs_TEMP | (UTF ? SVf_UTF8 : 0)))); } } PL_bufptr = oldbp; |