From: Rafael Garcia-Suarez Date: Fri, 13 Oct 2006 12:12:04 +0000 (+0000) Subject: Don't bother checking for bad characters in prototypes if we're not X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28cc6278baa5798d61d516dada16b1e45d160952;p=p5sagit%2Fp5-mst-13.2.git Don't bother checking for bad characters in prototypes if we're not going to warn about them. p4raw-id: //depot/perl@29008 --- diff --git a/toke.c b/toke.c index 5c24cca..66defa1 100644 --- a/toke.c +++ b/toke.c @@ -6495,7 +6495,7 @@ Perl_yylex(pTHX) char tmpbuf[sizeof PL_tokenbuf]; SSize_t tboffset = 0; expectation attrful; - bool have_name, have_proto, bad_proto; + bool have_name, have_proto; const int key = tmp; #ifdef PERL_MAD @@ -6574,7 +6574,6 @@ Perl_yylex(pTHX) /* Look for a prototype */ if (*s == '(') { - char *p; s = scan_str(s,!!PL_madskills,FALSE); if (!s) @@ -6582,19 +6581,23 @@ Perl_yylex(pTHX) /* strip spaces and check for bad characters */ d = SvPVX(PL_lex_stuff); tmp = 0; - bad_proto = FALSE; - for (p = d; *p; ++p) { - if (!isSPACE(*p)) { - d[tmp++] = *p; - if (!strchr("$@%*;[]&\\", *p)) - bad_proto = TRUE; + { + char *p; + bool bad_proto = FALSE; + const bool warnsyntax = ckWARN(WARN_SYNTAX); + for (p = d; *p; ++p) { + if (!isSPACE(*p)) { + d[tmp++] = *p; + if (warnsyntax && !strchr("$@%*;[]&\\", *p)) + bad_proto = TRUE; + } } + d[tmp] = '\0'; + if (bad_proto) + Perl_warner(aTHX_ packWARN(WARN_SYNTAX), + "Illegal character in prototype for %"SVf" : %s", + (void*)PL_subname, d); } - d[tmp] = '\0'; - if (bad_proto && ckWARN(WARN_SYNTAX)) - Perl_warner(aTHX_ packWARN(WARN_SYNTAX), - "Illegal character in prototype for %"SVf" : %s", - (void*)PL_subname, d); SvCUR_set(PL_lex_stuff, tmp); have_proto = TRUE;