From: Rafael Garcia-Suarez Date: Sun, 8 Jun 2008 09:12:01 +0000 (+0000) Subject: Tweak the "Illegal character in prototype" warning so it's more X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aef2a98a19b5e1de02b2dac2bc5531eec0da8634;p=p5sagit%2Fp5-mst-13.2.git Tweak the "Illegal character in prototype" warning so it's more precise when reporting illegal characters after _ p4raw-id: //depot/perl@34023 --- diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index b82268d..1bd8f8f 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -873,5 +873,5 @@ sub underscore_fail($_$); EXPECT Prototype after '@' for main::proto_after_array : @$ at - line 3. Prototype after '%' for main::proto_after_hash : %$ at - line 7. -Illegal character in prototype for main::underscore_fail : $_$ at - line 12. +Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12. Prototype after '@' for main::underscore_after_at : @_ at - line 13. diff --git a/toke.c b/toke.c index 5f75233..a601c51 100644 --- a/toke.c +++ b/toke.c @@ -6749,6 +6749,7 @@ Perl_yylex(pTHX) bool proto_after_greedy_proto = FALSE; bool must_be_last = FALSE; bool underscore = FALSE; + bool seen_underscore = FALSE; const bool warnsyntax = ckWARN(WARN_SYNTAX); s = scan_str(s,!!PL_madskills,FALSE); @@ -6786,7 +6787,7 @@ Perl_yylex(pTHX) greedy_proto = *p; } else if ( *p == '_' ) { - underscore = TRUE; + underscore = seen_underscore = TRUE; } } } @@ -6799,7 +6800,8 @@ Perl_yylex(pTHX) greedy_proto, SVfARG(PL_subname), d); if (bad_proto) Perl_warner(aTHX_ packWARN(WARN_SYNTAX), - "Illegal character in prototype for %"SVf" : %s", + "Illegal character %sin prototype for %"SVf" : %s", + seen_underscore ? "after '_' " : "", SVfARG(PL_subname), d); SvCUR_set(PL_lex_stuff, tmp); have_proto = TRUE;