summaryrefslogtreecommitdiff
path: root/lib/sbin/cpp.pl
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-05-14 12:47:57 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-05-14 12:47:57 +0000
commita168c401bce0bc6db1bd88dd7ab2251a5b5fcd37 (patch)
tree41d5cad58abcdd06f658bcb595bc9fdb40387346 /lib/sbin/cpp.pl
parente516cc441dbaacc6c2a4fa84695f006ba287361b (diff)
Bugfix - whitespace in the argument list of a macro definition ran into
problems. PR 1467 - patch from Ian Hawke. This patch also allows space on a line before a pre-processor directive. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@3216 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/cpp.pl')
-rwxr-xr-xlib/sbin/cpp.pl24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/sbin/cpp.pl b/lib/sbin/cpp.pl
index 752bc83b..ea704de6 100755
--- a/lib/sbin/cpp.pl
+++ b/lib/sbin/cpp.pl
@@ -350,7 +350,7 @@ sub ParseFile
last if(! defined($line));
# If it isn't a preprocessor command, just process it
- if($line !~ m/^\#/)
+ if($line !~ m/^\s*\#/)
{
if($active)
{
@@ -362,7 +362,7 @@ sub ParseFile
next;
}
- if($line =~ m/^\s*#\s*define\s+([^\s]+)(\s+(.*))?/)
+ if($line=~m/^\s*#\s*define\s+([a-zA-Z_][a-zA-Z0-9_]*(?:\(.*?\))?)(\s+(.*))?/)
{
# Define a macro
&Define($1,$3,$filename, $linenumber) if($active);
@@ -708,16 +708,28 @@ sub Define
{
my ($arg1,$arg2,$filename,$linenumber) = @_;
- $arg1 =~ m:^([a-zA-Z_][a-zA-Z0-9_]*)(\(([a-zA-Z0-9_,]+)\))?$:;
+ $arg1 =~ m:^([a-zA-Z_][a-zA-Z0-9_]*)(\(([a-zA-Z0-9_,\s]+)\))?$:;
my $defname = $1;
my $defargs = $3;
my @args = split(/,/, $defargs);
+# Remove any whitespace around an argument name
+ my $arg;
+ foreach $arg (@args)
+ {
+ $arg =~ /\s*(.*)\s*/;
+ $arg = $1;
+ if ($debug)
+ {
+ print "Arg is '$arg'\n";
+ }
+ }
if($debug)
{
- print "Defining '$defname'\n";
+ print "Args are '$arg1' and '$arg2'\n";
+ print "Defining '$defname' with '$defargs'\n";
}
if($defines{$defname})
@@ -1002,6 +1014,10 @@ sub ParseAndExpand
# Is this token a macro ?
if($defines{$token})
{
+ if ($debug)
+ {
+ print "The macro is '$token'\n";
+ }
my $arg = "";
if(@{$defines{$token}{"ARGS"}} > 0 &&
$pos+1 < @splitline)