summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Manfredi <Raphael_Manfredi@pobox.com>2017-10-24 22:43:40 +0200
committerGitHub <noreply@github.com>2017-10-24 22:43:40 +0200
commitf8e6e03cbfcecfd577555326c0775b109eb894a8 (patch)
treeb46b4e25cfff5f4c13a330b8428ceed343e3796c
parent06e93d9d534a84de9902164cc75d9b98bfadc452 (diff)
parent890ae3e3f8b39b90d53e57455bbbf99795511225 (diff)
Merge pull request #14 from arc/master
Added "-X exclusions-file" to ignore symbols. Symbols like "index" may be present in source files but only accidentally. This may occur in a comment, and not because index() is used and needs to be dealt-with by metaconfig. The -X option provides the ability to list symbols like "index" that we do not want processed by metaconfig (and metaxref). To avoid having to always remember to supply -X when running metaconfig or metaxref, packinit was improved to record the name of the file that is holding the symbols we wish to exclude: when an exclusion file is recorded, it will be automatically picked by metaconfig (and metaxref). It is still possible to use the -X option on the command line to supersede any setting in the .package file.
-rwxr-xr-xbin/packinit.SH15
-rwxr-xr-xkit/makedist.SH2
-rwxr-xr-xmcon/man/mconfig.SH13
-rwxr-xr-xmcon/man/mxref.SH13
-rwxr-xr-xmcon/mconfig.SH7
-rwxr-xr-xmcon/mxref.SH7
-rw-r--r--mcon/pl/depend.pl3
-rw-r--r--mcon/pl/files.pl26
-rw-r--r--mcon/pl/xref.pl3
-rw-r--r--mcon/pl/xwant.pl8
10 files changed, 88 insertions, 9 deletions
diff --git a/bin/packinit.SH b/bin/packinit.SH
index a3e8f25..578b8d8 100755
--- a/bin/packinit.SH
+++ b/bin/packinit.SH
@@ -191,6 +191,19 @@ EOM
$shext = &myread('Additional file extensions to identify SH files?', $dflt);
$shext = '' if $shext eq 'none';
+$dflt = 'none';
+print <<'EOM';
+
+If your package sources contains symbols that metaconfig will mistake for the
+names of symbols defined by its units, you can list them in an exclusions file.
+(See the documentation of "metaconfig -X".) What file would you like metaconfig
+to consult for those symbols? Say "none" if you don't need to exclude any
+symbols.
+
+EOM
+$exclusions_file = &myread('File to consult for excluded symbols?', $dflt);
+$exclusions_file = '' if $exclusions_file eq 'none';
+
$dflt = $copyright eq ' ' ? 'n' : 'y';
print <<'EOM';
@@ -426,6 +439,8 @@ changercs=$changercs
: File lookup extensions
cext='$cext'
shext='$shext'
+: File to consult for symbol exclusions
+exclusions_file='$exclusions_file'
: Mailing list variables
list_users='$list_users'
list_name='$list_name'
diff --git a/kit/makedist.SH b/kit/makedist.SH
index 2c41a4a..f40d5c5 100755
--- a/kit/makedist.SH
+++ b/kit/makedist.SH
@@ -273,7 +273,7 @@ sub manimake {
Filename Kit Description
-------- --- -----------
";
- for (sort keys(comment)) {
+ for (sort keys(%comment)) {
printf PACKLIST "%-27s %2s %.47s\n", $_, $kit{$_}, $comment{$_};
}
close PACKLIST;
diff --git a/mcon/man/mconfig.SH b/mcon/man/mconfig.SH
index f205fb7..e749330 100755
--- a/mcon/man/mconfig.SH
+++ b/mcon/man/mconfig.SH
@@ -528,6 +528,19 @@ option permanently.
.TP
.B \-V
Print version number and exit.
+.TP
+\fB\-X\fI file\fR
+When examining the source files, ignore any symbols listed in the \fIfile\fR.
+This is useful in situations where a particular unit is known not to be needed
+for your package's portability targets, but your source files nevertheless
+contain occurrences of words that look to \fImetaconfig\fR like symbols defined
+in that unit. (For example, you might need the word "index" in a source file,
+but not need the unit that determines whether \fIstrcpy\fR or \fIindex\fR
+should be used.)
+The \fIfile\fR can contain blank lines, comment lines introduced with '#', and
+lines containing a single symbol.
+If this option is not supplied, any \fI$exclusions_file\fR variable in
+\fI.package\fR is honored instead.
'''
''' T u t o r i a l
'''
diff --git a/mcon/man/mxref.SH b/mcon/man/mxref.SH
index b0dbbad..491bf1d 100755
--- a/mcon/man/mxref.SH
+++ b/mcon/man/mxref.SH
@@ -99,6 +99,19 @@ can be found).
.TP
.B \-V
Print version number and exit.
+.TP
+\fB\-X\fI file\fR
+When examining the source files, ignore any symbols listed in the \fIfile\fR.
+This is useful in situations where a particular unit is known not to be needed
+for your package's portability targets, but your source files nevertheless
+contain occurrences of words that look to \fImetaconfig\fR like symbols defined
+in that unit. (For example, you might need the word "index" in a source file,
+but not need the unit that determines whether \fIstrcpy\fR or \fIindex\fR
+should be used.)
+The \fIfile\fR can contain blank lines, comment lines introduced with '#', and
+lines containing a single symbol.
+If this option is not supplied, any \fI$exclusions_file\fR variable in
+\fI.package\fR is honored instead.
.SH AUTHOR
Harlan Stenn <harlan@mumps.pfcs.com>
.SH FILES
diff --git a/mcon/mconfig.SH b/mcon/mconfig.SH
index c9c295f..4917e43 100755
--- a/mcon/mconfig.SH
+++ b/mcon/mconfig.SH
@@ -68,8 +68,10 @@ chop($date = `date`);
&profile; # Read ~/.dist_profile
use Getopt::Std;
-&usage unless getopts("dhkmostvwGMVL:");
+&usage unless getopts("dhkmostvwGMVL:X:");
+my %excluded_symbol;
+read_exclusions($opt_X);
$MC = $opt_L if $opt_L; # May override public library path
$MC = &tilda_expand($MC); # ~name expansion
chop($WD = `pwd`); # Working directory
@@ -150,7 +152,7 @@ sub init_except {
# Print out metaconfig's usage and exits
sub usage {
print STDERR <<'EOH';
-Usage: metaconfig [-dhkmostvwGMV] [-L dir]
+Usage: metaconfig [-dhkmostvwGMV] [-L dir] [-X file]
-d : debug mode.
-h : print this help message and exits.
-k : keep temporary directory.
@@ -164,6 +166,7 @@ Usage: metaconfig [-dhkmostvwGMV] [-L dir]
-L : specify main units repository.
-M : activate production of confmagic.h.
-V : print version number and exits.
+ -X : read symbol exclusions from file (overriding .package)
EOH
exit 1;
}
diff --git a/mcon/mxref.SH b/mcon/mxref.SH
index 5c45c1e..3433edc 100755
--- a/mcon/mxref.SH
+++ b/mcon/mxref.SH
@@ -60,10 +60,12 @@ $spitshell >>mxref <<'!NO!SUBS!'
&profile; # Read ~/.dist_profile
use Getopt::Std;
-&usage unless getopts("df:hkmsVL:");
+&usage unless getopts("df:hkmsVL:X:");
chop($date = `date`);
chop($WD = `pwd`); # Working directory
+my %excluded_symbol;
+read_exclusions($opt_X);
$MC = $opt_L if $opt_L; # May override library path
$MC = &tilda_expand($MC); # ~name expansion
chdir $MC || die "Can't chdir to $MC: $!\n";
@@ -119,7 +121,7 @@ sub init_except {
# Print out metaxref's usage and exits
sub usage {
print STDERR <<EOM;
-Usage: metaxref [-dhkmsV] [-f manifest] [-L dir]
+Usage: metaxref [-dhkmsV] [-f manifest] [-L dir] [-X file]
-d : debug mode.
-f : use that file as manifest instead of MANIFEST.new.
-h : print this help message and exits.
@@ -128,6 +130,7 @@ Usage: metaxref [-dhkmsV] [-f manifest] [-L dir]
-s : silent mode.
-L : specify main units repository.
-V : print version number and exits.
+ -X : read symbol exclusions from file (overriding .package)
EOM
exit 1;
}
diff --git a/mcon/pl/depend.pl b/mcon/pl/depend.pl
index fc88f1a..e31eded 100644
--- a/mcon/pl/depend.pl
+++ b/mcon/pl/depend.pl
@@ -52,6 +52,9 @@ sub p_wanted {
$cmaster{$_} = undef; # Asks for look-up in C files
$cwanted{$_} = "$active" if $active; # Shell symbols to activate
}
+
+ delete @cmaster{keys %excluded_symbol};
+ delete @cwanted{keys %excluded_symbol};
}
# Process the ?INIT: lines
diff --git a/mcon/pl/files.pl b/mcon/pl/files.pl
index 3962fa6..a7d26a6 100644
--- a/mcon/pl/files.pl
+++ b/mcon/pl/files.pl
@@ -29,6 +29,9 @@
;# extensions to their packages. For instance, perl5 adds .xs files holding
;# some C symbols.
;#
+;# The read_exclusions() routine honours the .package $exclusions_file
+;# variable if its argument is undefined.
+;#
# Extract filenames from manifest
sub extract_filenames {
&build_filext; # Construct &is_cfile and &is_shfile
@@ -106,3 +109,26 @@ sub q {
$_;
}
+sub read_exclusions {
+ my ($filename) = @_;
+ if (!defined $filename) {
+ $filename = $exclusions_file; # default to name from .package
+ return if !defined $filename || $filename eq '';
+ }
+ print "Reading exclusions from $filename...\n" unless $opt_s;
+ open(EXCLUSIONS, "< $filename\0") || die "Can't read $filename: $!\n";
+ local $_;
+ while (<EXCLUSIONS>) {
+ if (/^\s*#|^\s*$/) {
+ # comment or blank line, ignore
+ }
+ elsif (/^\s*(\w+)\s*$/) {
+ $excluded_symbol{$1} = 1;
+ }
+ else {
+ die "$filename:$.: unrecognised line\n";
+ }
+ }
+ close(EXCLUSIONS) || die "Can't close $filename: $!\n";
+}
+
diff --git a/mcon/pl/xref.pl b/mcon/pl/xref.pl
index 02f4164..f077139 100644
--- a/mcon/pl/xref.pl
+++ b/mcon/pl/xref.pl
@@ -55,6 +55,9 @@ sub p_wanted {
$cwanted{$_} = "$fake"; # Attached to this symbol
push(@Master, "?$unit:$fake=''"); # Fake initialization
}
+
+ delete @cmaster{keys %excluded_symbol};
+ delete @cwanted{keys %excluded_symbol};
}
# Ingnore the following:
diff --git a/mcon/pl/xwant.pl b/mcon/pl/xwant.pl
index 31508eb..e1bbf20 100644
--- a/mcon/pl/xwant.pl
+++ b/mcon/pl/xwant.pl
@@ -49,7 +49,7 @@ sub build_xref {
print " Scanning .[chyl] files for symbols...\n" unless $opt_s;
$search = ' ' x (40 * (@cmaster + @ocmaster)); # Pre-extend
$search = "while (<>) {study;\n"; # Init loop over ARGV
- foreach $key (keys(cmaster)) {
+ foreach $key (keys(%cmaster)) {
$search .= "\$cmaster{'$key'} .= \"\$ARGV#\" if /\\b$key\\b/;\n";
}
foreach $key (grep(!/^\$/, keys %Obsolete)) {
@@ -63,7 +63,7 @@ sub build_xref {
eval $search;
eval '';
$/ = "\n";
- while (($key,$value) = each(cmaster)) {
+ while (($key,$value) = each(%cmaster)) {
next if $value eq '';
foreach $file (sort(split(/#/, $value))) {
next if $file eq '';
@@ -94,7 +94,7 @@ sub build_xref {
$search = ' ' x (40 * (@shmaster + @oshmaster)); # Pre-extend
$search = "while (<>) {study;\n";
# All the keys already have a leading '$'
- foreach $key (keys(shmaster)) {
+ foreach $key (keys(%shmaster)) {
$search .= "\$shmaster{'$key'} .= \"\$ARGV#\" if /\\$key\\b/;\n";
}
foreach $key (grep (/^\$/, keys %Obsolete)) {
@@ -108,7 +108,7 @@ sub build_xref {
eval $search;
eval '';
$/ = "\n";
- while (($key,$value) = each(shmaster)) {
+ while (($key,$value) = each(%shmaster)) {
next if $value eq '';
foreach $file (sort(split(/#/, $value))) {
next if $file eq '';