Fred Drake | 9acafa8 | 1998-02-18 14:52:24 +0000 | [diff] [blame] | 1 | #!/depot/gnu/plat/bin/perl -i |
Jeremy Hylton | daa2d5d | 1998-02-18 13:53:48 +0000 | [diff] [blame] | 2 | |
| 3 | # read the labels, then reverse the mappings |
| 4 | require "labels.pl"; |
| 5 | |
| 6 | %nodes = (); |
Fred Drake | e817930 | 1998-02-26 18:49:58 +0000 | [diff] [blame] | 7 | my $key; |
Jeremy Hylton | 9caa110 | 1998-02-18 16:10:22 +0000 | [diff] [blame] | 8 | # sort so that we get a consistent assignment for nodes with multiple labels |
| 9 | foreach $label (sort keys %external_labels) { |
Fred Drake | e817930 | 1998-02-26 18:49:58 +0000 | [diff] [blame] | 10 | $key = $external_labels{$label}; |
| 11 | $key =~ s|^/||; |
| 12 | $nodes{$key} = $label; |
Jeremy Hylton | daa2d5d | 1998-02-18 13:53:48 +0000 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | # collect labels that have been used |
| 16 | %newnames = (); |
| 17 | |
| 18 | while (<>) { |
| 19 | # don't want to do one s/// per line per node |
| 20 | # so look for lines with hrefs, then do s/// on nodes present |
| 21 | if (/HREF=\"([^\#\"]*)html[\#\"]/) { |
| 22 | @parts = split(/HREF\=\"/); |
| 23 | shift @parts; |
| 24 | for $node (@parts) { |
| 25 | $node =~ s/[\#\"].*$//g; |
| 26 | chop($node); |
| 27 | if (defined($nodes{$node})) { |
| 28 | $label = $nodes{$node}; |
| 29 | if (s/HREF=\"$node([\#\"])/HREF=\"$label.html$1/g) { |
| 30 | s/HREF=\"$label.html#SECTION\d+/HREF=\"$label.html/g; |
| 31 | $newnames{$node} = "$label.html"; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | print; |
| 37 | } |
| 38 | |
| 39 | foreach $oldname (keys %newnames) { |
Fred Drake | 9acafa8 | 1998-02-18 14:52:24 +0000 | [diff] [blame] | 40 | # or ln -s |
| 41 | system("mv $oldname $newnames{$oldname}"); |
Jeremy Hylton | daa2d5d | 1998-02-18 13:53:48 +0000 | [diff] [blame] | 42 | } |