diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-04-24 15:55:02 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-04-24 15:55:02 +0000 |
commit | c45e8813934c6b92de0a00aa94f87d2a1c1c9033 (patch) | |
tree | 599969ee23a362268e2324fb6ecf0103a9bbd9cd /lib/sbin/cpp.pl | |
parent | f567c5fc3750c0161d88f461e807139a0014cf30 (diff) |
Fixed to allow #if or #elif <constant|define>.
A couple of bugfixes for diagnostic code.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2750 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/cpp.pl')
-rwxr-xr-x | lib/sbin/cpp.pl | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/sbin/cpp.pl b/lib/sbin/cpp.pl index 70dc5c1e..c1b6a998 100755 --- a/lib/sbin/cpp.pl +++ b/lib/sbin/cpp.pl @@ -379,7 +379,7 @@ sub ParseFile # Parse the if statement and see if the first clause is active if($active) { - $newactive = &ProcessIf($1, $filename, $linumber,$printline); + $newactive = &ProcessIf($1, $filename, $linenumber,$printline); } else { @@ -404,14 +404,14 @@ sub ParseFile # Finished last; } - elsif($currentline =~ m/^#elif\s+(.+)/ && ! $foundelse) + elsif($currentline =~ m/^#elif(\s+.+)/ && ! $foundelse) { # Got #elif, is this next clause active ? if(! $beenactive) { if($active) { - $newactive = &ProcessIf($1, $filename, $linumber); + $newactive = &ProcessIf($1, $filename, $linenumber); } else { @@ -658,9 +658,25 @@ sub ProcessIf { $retval = defined($defines{$1}) ? 0 : 1; } + elsif($line =~ m/^\s+([^\s]+)\s*$/) + { + my $val = $1; + if(defined($defines{$val})) + { + $retval = $defines{$val} + } + elsif($val =~ m/^\d+$/) + { + $retval = $val; + } + else + { + print STDERR "#if <constant> called on non-digit and non-define $val at $filename\::$linenumber !\n"; + } + } else { - print STDERR "#if can currently to #ifdef and #ifndef, sorry !\n"; + print STDERR "#if can currently to #ifdef and #ifndef, sorry ! (At $filename\::$linenumber.)\n"; $retval = 0; } |