X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=vos%2Fconfig.pl;h=c865ba158b6d7def24b68988f7217a4ef73d75a4;hb=158b3652342ca691c9e3b061a1d78456ae1a9b4a;hp=33629d7081eccee09e46dcb0bd7d2cbbd4b84ea0;hpb=c287c78ddec0173e5310e046c5e6d595abe24407;p=p5sagit%2Fp5-mst-13.2.git diff --git a/vos/config.pl b/vos/config.pl index 33629d7..c865ba1 100644 --- a/vos/config.pl +++ b/vos/config.pl @@ -1,48 +1,109 @@ # This file fills in a config_h.SH template based on the data -# of the file config.def and outputs a config.sh. +# of the file config.def and outputs a config.h. +# +# Written January 24, 2000 by Jarkko Hietaniemi [jhi@iki.fi] +# Modified February 2, 2000 by Paul Green [Paul_Green@stratus.com] +# Modified October 23, 2000 by Paul Green [Paul_Green@stratus.com] + +# +# Read in the definitions file +# if (open(CONFIG_DEF, "config.def")) { while () { - if (/^([^=]+)='(.+)'$/) { - my ($var, $val) = ($1, $2); - $define{$var} = $val; - } else { - warn "config.def: $.: illegal line: $_"; - } + if (/^([^=]+)='(.*)'$/) { + my ($var, $val) = ($1, $2); + $define{$var} = $val; + $used{$var} = 0; + } else { + warn "config.def: $.: illegal line: $_"; + } } } else { die "$0: Cannot open config.def: $!"; } -if (open(CONFIG_SH, "config_h.SH_orig")) { - while () { - last if /^sed <config.h.new")) { + die "$0: Cannot open config.h.new for output: $!"; +} + +# +# Skip lines before the first !GROK!THIS! +# + +while () { + $lineno = $lineno + 1; + last if /^sed <) { + $lineno = $lineno + 1; + last if /^!GROK!THIS!/; +# +# The definition of SITEARCH and SITEARCH_EXP has to be commented-out. +# The easiest way to do this is to special-case it here. +# + if (/^#define SITEARCH*/) { + s@(^.*$)@/*$1@; } - while () { - last if /^!GROK!THIS!/; - s/\\\$Id:/\$Id:/; - s/\$package/perl5/; - s/\$cf_time/localtime/e; - s/\$myuname/$define{OSNAME}/; - s/\$seedfunc/$define{seedfunc}/; - if (/^#\$\w+\s+(\w+)/) { - if (exists $define{$1}) { - if ($define{$1} eq 'define') { - print "#define $1\t/**/\n"; - } else { - print "#define $1 $define{$1}\n"; - } - } else { - print "/*#define $1\t/**/\n"; - } - } elsif (/^#define\s+(\S+)/) { - print "#define $1 $define{$1}\n"; - } elsif (s/\$cpp_stuff/$define{cpp_stuff}/g) { - print; - } else { - print; - } +# +# The case of #$d_foo at the BOL has to be handled carefully. +# If $d_foo is "undef", then we must first comment out the entire line. +# + if (/^#(\$\w+)/) { + if (exists $define{$1}) { + $used{$1}=1; + s@^#(\$\w+)@("$define{$1}" eq "undef") ? + "/*#define":"#$define{$1}"@e; + } + } +# +# There could be multiple $variables on this line. +# Find and replace all of them. +# + if (/(\$\w+)/) { + s/(\$\w+)/(exists $define{$1}) ? + (($used{$1}=1),$define{$1}) : + ((print "Undefined keyword $1 on line $lineno\n"),$1)/ge; + print CONFIG_H; + } +# +# There are no variables, just print the line out. +# + else { + print CONFIG_H; } -} else { - die "$0: Cannot open config_h.SH_orig: $!"; } + +unless (close (CONFIG_H)) { + die "$0: Cannot close config.h.new: $!"; + } + +close (CONFIG_SH); + +while (($key,$value) = each %used) { + if ($value == 0) { + print "Unused keyword definition: $key\n"; + } +} +