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
commitc997ca56474dd57942a3245d27f9fd95c3ed129f (patch)
treea63a68fa697ef9639712b04fefa99a39ca86174a /op.c
parentfbb6fbb760b5d49326ee470b3c1747486d3cf1de (diff)
downloadperl-c997ca56474dd57942a3245d27f9fd95c3ed129f.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)