Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement #ifdef nesting in tools/build/gen-cat.pl.
  • Loading branch information
pmurias committed Mar 10, 2014
1 parent 06ccf9e commit 0772a15
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tools/build/gen-cat.pl
Expand Up @@ -14,20 +14,19 @@

END_HEAD


foreach my $file (@files) {
print "# From $file\n\n";
open(my $fh, "<:utf8", $file) or die "$file: $!";
my $in_cond = 0;
my $in_omit = 0;
my @conds;
while (<$fh>) {
if (/^#\?if\s+(!)?\s*(\w+)\s*$/) {
die "Nested conditionals not supported" if $in_cond;
$in_cond = 1;
$in_omit = $1 && $2 eq $backend || !$1 && $2 ne $backend;
push @conds,$in_omit;
$in_omit = $in_omit || ($1 && $2 eq $backend || !$1 && $2 ne $backend);
}
elsif (/^#\?endif\s*$/) {
$in_cond = 0;
$in_omit = 0;
$in_omit = pop @conds;
}
elsif (!$in_omit) {
print;
Expand Down

0 comments on commit 0772a15

Please sign in to comment.