summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-05-12 19:43:07 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-05-12 19:43:07 +0000
commit8473848ff8266ad63ce5a45acc5fc8a9e690cc05 (patch)
treea63a68fa697ef9639712b04fefa99a39ca86174a /op.c
parent1bb0a50fd869bf3d7f152d29ec8c8119703266a1 (diff)
downloadperl-8473848ff8266ad63ce5a45acc5fc8a9e690cc05.tar.gz
Use a more sophisticated heuristics to produce the warning
'Parentheses missing around "%s" list'. This fixes bug #22147. Also, the warning is now produced for C<local *a,*b;>. p4raw-id: //depot/perl@19503
Diffstat (limited to 'op.c')
-rw-r--r--op.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/op.c b/op.c
index be05875ca6..86cfe23654 100644
--- a/op.c
+++ b/op.c
@@ -1838,14 +1838,23 @@ Perl_localize(pTHX_ OP *o, I32 lex)
&& PL_bufptr > PL_oldbufptr && PL_bufptr[-1] == ',')
{
char *s = PL_bufptr;
+ int sigil = 0;
- while (*s && (isALNUM(*s) || UTF8_IS_CONTINUED(*s) || strchr("@$%, ", *s)))
+ /* some heuristics to detect a potential error */
+ while (*s && (strchr(", \t\n", *s)
+ || (strchr("@$%*", *s) && ++sigil) ))
s++;
-
- if (*s == ';' || *s == '=')
- Perl_warner(aTHX_ packWARN(WARN_PARENTHESIS),
- "Parentheses missing around \"%s\" list",
- lex ? (PL_in_my == KEY_our ? "our" : "my") : "local");
+ if (sigil) {
+ while (*s && (isALNUM(*s) || UTF8_IS_CONTINUED(*s)
+ || strchr("@$%*, \t\n", *s)))
+ s++;
+
+ if (*s == ';' || *s == '=')
+ Perl_warner(aTHX_ packWARN(WARN_PARENTHESIS),
+ "Parentheses missing around \"%s\" list",
+ lex ? (PL_in_my == KEY_our ? "our" : "my")
+ : "local");
+ }
}
}
if (lex)