From c6b2cc1263543e7b84a247c965d21f87c3b8feaf Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 8 Feb 2007 23:04:56 +0100 Subject: [PATCH] More elegant evaluation of #if expressions. --- build/genconf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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]"; -- 2.39.2