branch: externals/idlwave
commit 9a2ffd6bb6797cf598da5a198b9bb60a242000cd
Author: jdsmith <jdsmith>
Commit: jdsmith <jdsmith>

    - Load HTML files in current directory.
    - Added "All Contents" links.
---
 addlinks.pl | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/addlinks.pl b/addlinks.pl
index ea81abf128..9cdba98b92 100755
--- a/addlinks.pl
+++ b/addlinks.pl
@@ -1,7 +1,8 @@
-#!/usr/bin/perl -pi -0777
+#!/usr/bin/perl
 #
 # Program to fixup RSI-scanned HTML to contain the previous and next
-# links (in two location), plus some other useful links.
+# links (in two location, top and bottom), plus some other useful
+# links.
 #
 # (c)2003 J.D. Smith <jdsm...@as.arizona.edu>
 #
@@ -11,15 +12,38 @@
 # nav_functions.html, nav_objects.html all exist, or modify below as
 # necessary.
 #
-# Usage: addlinks.pl *.html
+# Usage: addlinks.pl  (in directory containing IDL .html files)
 #
 
+opendir DIR,"." or die "Can't open current directory\n";
+my @files=grep {-f && /\.html$/} readdir(DIR);
+close DIR;
+die "No HTML files found.\n" unless @files;
 
-$others='<div class="CellBody"><a href="funclisting.html">Categories</a> | <a 
href="nav_procedures.html">Procedures</a> | <a 
href="nav_functions.html">Functions</a> | <a 
href="nav_objects.html">Classes</a> | ';
-
-if (s@\<!--\s*\<br\>\s*(\<a href="[^"]+"\>)\<img src="images/prev.gif" 
border="0" alt="PREV"\>\</a\>(\<a href="[^"]+"\>)\<img src="images/next.gif" 
border="0" alt="NEXT"\>(.*?)\s+--\>@<hr>$others${1}[ &lt; ]</a> | ${2}[ &gt; 
]</a></div>@s) {
-  $links="${1}[ &lt; ]</a> | ${2}[ &gt; ]</a>";
-  s|^\<BODY\>|$&\n$others$links</div><hr>|m;
-}
+undef $/;
+my $others=
+  '<div class="CellBody">'.
+  '<a href="funclisting.html">Categories</a> | '.
+  '<a href="nav_procedures.html">Procedures</a> | '.
+  '<a href="nav_functions.html">Functions</a> | '.
+  '<a href="nav_objects.html">Classes</a> | '.
+  '<a href="idl_con.html">All Contents</a> | ';
 
 
+foreach $file (@files) {
+  open FILE, "<$file" or do {warn "Can't open $file... skipping"; next};
+  $_=<FILE>;
+  close FILE;
+  if (s@<!--\s*\<br\>\s*          # Opening comment
+       (\<a[ ]+href="[^"]+"\>)       # The link to the previous entry
+       \<img[ ]+src="images/prev.gif".*?\</a\>
+       (\<a[ ]+href="[^"]+"\>)    # The link to the next entry
+       .*?\s+--\>                # Everything through comment close, discard
+       @<hr>$others${1}[ &lt; ]</a> | ${2}[ &gt; ]</a></div>@sx) {
+    $links="${1}[ &lt; ]</a> | ${2}[ &gt; ]</a>";
+    s|^\<BODY\>|$&\n$others$links</div><hr>|m;
+    open FILE, ">$file" or do {warn "Can't write to $file... skipping"; next};
+    print FILE;
+    close FILE;
+  }
+}

Reply via email to