#
# 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 (/^([^=]+)='(.*)'$/) {
my ($var, $val) = ($1, $2);
$define{$var} = $val;
+ $used{$var} = 0;
} else {
warn "config.def: $.: illegal line: $_";
}
# Open the template input file.
#
-unless (open(CONFIG_SH, "config_h.SH_orig")) {
- die "$0: Cannot open config_h.SH_orig: $!";
+$lineno = 0;
+unless (open(CONFIG_SH, "../config_h.SH")) {
+ die "$0: Cannot open ../config_h.SH: $!";
}
#
#
while (<CONFIG_SH>) {
+ $lineno = $lineno + 1;
last if /^sed <<!GROK!THIS!/;
}
#
while (<CONFIG_SH>) {
+ $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@;
+ }
+#
# 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+/) {
- s@^#(\$\w+)@("$define{$1}" eq "undef")?"/*#define":"#$define{$1}"@e;
+ 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}) ? $define{$1} : $1/ge;
+ s/(\$\w+)/(exists $define{$1}) ?
+ (($used{$1}=1),$define{$1}) :
+ ((print "Undefined keyword $1 on line $lineno\n"),$1)/ge;
print CONFIG_H;
}
#
}
close (CONFIG_SH);
+
+while (($key,$value) = each %used) {
+ if ($value == 0) {
+ print "Unused keyword definition: $key\n";
+ }
+}
+