summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-04-25 16:04:38 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-04-25 16:04:38 +0000
commite87c7547822a9e80c5f92721e437eda398c6cf48 (patch)
tree01fe0fcd71251693c7e0830643007edf71e30c62
parentb27d1f0e4b44be323acc826429ca8b3e2d990a3d (diff)
Don't get confused by ( and ) in strings in macro arguments.
Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@2754 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rwxr-xr-xlib/sbin/cpp.pl14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sbin/cpp.pl b/lib/sbin/cpp.pl
index c1b6a998..b3e545dd 100755
--- a/lib/sbin/cpp.pl
+++ b/lib/sbin/cpp.pl
@@ -1022,16 +1022,26 @@ sub ParseAndExpand
# Find any arguments
if($splitline[$pos+1] eq "(")
{
+ my $insstring = 0;
+ my $indstring = 0;
$pos++;
my $depth = 1;
$pos++;
while($pos < @splitline && $depth > 0)
{
- if($splitline[$pos] eq "(")
+ if($splitline[$pos] eq '\'' && ! $indstring)
+ {
+ $insstring = 1 - $insstring;
+ }
+ if($splitline[$pos] eq '"'&& ! $insstring)
+ {
+ $indstring = 1 - $indstring;
+ }
+ if($splitline[$pos] eq "(" && ! $insstring && ! $indstring)
{
$depth++;
}
- elsif($splitline[$pos] eq ")")
+ elsif($splitline[$pos] eq ")" && ! $insstring && ! $indstring)
{
$depth--;
}