From 86fe3f368e07f69cb20296f510fcb1d5ce6b3777 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Sat, 20 Aug 2011 08:33:57 +0100 Subject: toke.c: "Bad name after %s%s" cleanup. --- t/uni/parser.t | 8 +++++++- toke.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/t/uni/parser.t b/t/uni/parser.t index 256864cb80..63c2deba68 100644 --- a/t/uni/parser.t +++ b/t/uni/parser.t @@ -7,7 +7,7 @@ BEGIN { require './test.pl'; } -plan (tests => 45); +plan (tests => 47); use utf8; use open qw( :utf8 :std ); @@ -138,3 +138,9 @@ is ${"main::\345\225\217"}, undef, "..and using the encoded form doesn't"; eval qq!print \x{30cb}, "comma""!; like $@, qr/No comma allowed after filehandle/, "No comma allowed after filehandle triggers correctly for UTF-8 filehandles."; } + +# tests for "Bad name" +eval q{ Foo::$bar }; +like( $@, qr/Bad name after Foo::/, 'Bad name after Foo::' ); +eval q{ Foo''bar }; +like( $@, qr/Bad name after Foo'/, 'Bad name after Foo\'' ); diff --git a/toke.c b/toke.c index e43bc744a8..4dbf00d6d4 100644 --- a/toke.c +++ b/toke.c @@ -6659,7 +6659,9 @@ Perl_yylex(pTHX) s = scan_word(s, PL_tokenbuf + len, sizeof PL_tokenbuf - len, TRUE, &morelen); if (!morelen) - Perl_croak(aTHX_ "Bad name after %s%s", PL_tokenbuf, + Perl_croak(aTHX_ "Bad name after %"SVf"%s", + SVfARG(newSVpvn_flags(PL_tokenbuf, len, + (UTF ? SVf_UTF8 : 0) | SVs_TEMP )), *s == '\'' ? "'" : "::"); len += morelen; pkgname = 1; -- cgit v1.2.1