From: Martin Mares Date: Thu, 8 Feb 2007 22:04:56 +0000 (+0100) Subject: More elegant evaluation of #if expressions. X-Git-Tag: holmes-import~506^2~109^2~1 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=c6b2cc1263543e7b84a247c965d21f87c3b8feaf;p=libucw.git More elegant evaluation of #if expressions. --- diff --git a/build/genconf b/build/genconf index 29565a9c..ac9755f4 100755 --- a/build/genconf +++ b/build/genconf @@ -20,8 +20,11 @@ while () { } close CF; -my $opt_regex = join("|", keys %options); -sub eval_expr { $_ = "@_"; s/\b($opt_regex)\b/ 1 /g if $opt_regex; s/\bCONFIG_\w+\b/ 0 /g; return eval $_; } +sub eval_expr { + $_ = shift @_; + s/\b(CONFIG_\w+)\b/defined($options{$1}) ? 1 : 0/ge; + return eval $_; +} open IN, $ARGV[0] or die "Unable to open $ARGV[0]"; open OUT, ">$ARGV[1]" or die "Unable to create $ARGV[1]";