1998-03-19 01:17:49 -04:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
|
|
|
|
use English;
|
|
|
|
$INPLACE_EDIT = '';
|
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
|
|
|
}
|
|
|
|
|
1998-03-27 01:24:53 -04:00
|
|
|
# This adds the "internal" labels added for indexing. These labels will not
|
|
|
|
# be used for file names.
|
|
|
|
require "intlabels.pl";
|
|
|
|
foreach $label (keys %internal_labels) {
|
|
|
|
$key = $internal_labels{$label};
|
|
|
|
$key =~ s|^/||;
|
|
|
|
if (defined($nodes{$key})) {
|
|
|
|
$nodes{$label} = $nodes{$key};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
1998-03-27 01:24:53 -04:00
|
|
|
if (/(HREF|href)=\"([^\#\"]*)html[\#\"]/) {
|
|
|
|
@parts = split(/(HREF|href)\=\"/);
|
1998-02-18 09:53:48 -04:00
|
|
|
shift @parts;
|
|
|
|
for $node (@parts) {
|
|
|
|
$node =~ s/[\#\"].*$//g;
|
|
|
|
chop($node);
|
|
|
|
if (defined($nodes{$node})) {
|
|
|
|
$label = $nodes{$node};
|
1998-03-27 01:24:53 -04:00
|
|
|
if (s/(HREF|href)=\"$node([\#\"])/$1=\"$label.html$2/g) {
|
1999-02-02 14:57:12 -04:00
|
|
|
s/(HREF|href)=\"$label.html#l2h-\d+/$1=\"$label.html/g;
|
1998-02-18 09:53:48 -04:00
|
|
|
$newnames{$node} = "$label.html";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach $oldname (keys %newnames) {
|
1998-08-11 15:17:47 -03:00
|
|
|
rename($oldname, $newnames{$oldname});
|
1998-02-18 09:53:48 -04:00
|
|
|
}
|