On Aug 16 2007 10:21, Andy Whitcroft wrote:
>> + if ($line =~ /\bif\s*\([^\)]*\)\s*\;/) {
>
>Heh, you are the second person to suggest this check today, do I detect
>some ripped out hair due to one of these!
>
>I've taken this idea and expanded it to cover if, for and while which
>can all suffer from this. Using the relative indent to work out which
>are valid combinations:
But. The above regex does not seem to handle
if ((a = b));
oops;
I have tried to come up with a superduper regex that handles multiple
(), but my regex fu seems to stop above two pairs of ().
#!/usr/bin/perl
@check = (
q"if ((ptr = malloc(bong, GFP)) == NULL) ; (oopsie) ;",
q"if ((ptr = malloc(bong, GFP)) == NULL) (alright);",
q"if ( ({ bool evil = (true); evil; }) ) ; (oopsie) ;",
q"if ( ({ bool evil = (true); evil; }) ) (alright);",
q"if((()));",
);
my $r = qr/\s*\(\s*(??{$r})?\s*\)\s*|\s*\(\s*[^()]+\s*\)\s*/;
foreach (@check) {
if ($_ =~ /(if|for|while)$r;/) {
print "ok $_\n";
}
}
Jan
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]