1998-02-18 10:52:24 -04:00
|
|
|
#!/depot/gnu/plat/bin/perl -i
|
1998-02-18 09:53:48 -04:00
|
|
|
|
|
|
|
# read the labels, then reverse the mappings
|
|
|
|
require "labels.pl";
|
|
|
|
|
|
|
|
%nodes = ();
|
1998-02-26 14:49:58 -04:00
|
|
|
my $key;
|
1998-02-18 12:10:22 -04:00
|
|
|
# sort so that we get a consistent assignment for nodes with multiple labels
|
|
|
|
foreach $label (sort keys %external_labels) {
|
1998-02-26 14:49:58 -04:00
|
|
|
$key = $external_labels{$label};
|
|
|
|
$key =~ s|^/||;
|
|
|
|
$nodes{$key} = $label;
|
1998-02-18 09:53:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# collect labels that have been used
|
|
|
|
%newnames = ();
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
# don't want to do one s/// per line per node
|
|
|
|
# so look for lines with hrefs, then do s/// on nodes present
|
|
|
|
if (/HREF=\"([^\#\"]*)html[\#\"]/) {
|
|
|
|
@parts = split(/HREF\=\"/);
|
|
|
|
shift @parts;
|
|
|
|
for $node (@parts) {
|
|
|
|
$node =~ s/[\#\"].*$//g;
|
|
|
|
chop($node);
|
|
|
|
if (defined($nodes{$node})) {
|
|
|
|
$label = $nodes{$node};
|
|
|
|
if (s/HREF=\"$node([\#\"])/HREF=\"$label.html$1/g) {
|
|
|
|
s/HREF=\"$label.html#SECTION\d+/HREF=\"$label.html/g;
|
|
|
|
$newnames{$node} = "$label.html";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach $oldname (keys %newnames) {
|
1998-02-18 10:52:24 -04:00
|
|
|
# or ln -s
|
|
|
|
system("mv $oldname $newnames{$oldname}");
|
1998-02-18 09:53:48 -04:00
|
|
|
}
|