diff options
Diffstat (limited to 'Build/source/mswin32/add-info-toc.pl')
-rw-r--r-- | Build/source/mswin32/add-info-toc.pl | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Build/source/mswin32/add-info-toc.pl b/Build/source/mswin32/add-info-toc.pl new file mode 100644 index 00000000000..4cd9899170b --- /dev/null +++ b/Build/source/mswin32/add-info-toc.pl @@ -0,0 +1,60 @@ +$dd = '/'; + +&main; + +exit 0; + +sub main { + local (@files); + @files = @ARGV; + $temp = &get_tmp_dir() . "ait.$$"; + open(OUT, ">$temp") || exit 1; + print OUT "Contents:\n\n"; + while (<>) { + $prevline = $line; + $line = $_; + if ($line =~ m/^\*+$/) { + print OUT "$prevline"; + } + elsif ($line =~ m/^=+$/) { + print OUT " $prevline"; + } + elsif ($line =~ m/^-+$/) { + print OUT " $prevline"; + } + elsif ($line =~ m/^\.+$/) { + print OUT " $prevline"; + } + } + print OUT "\n\n"; + @ARGV = @files; + while (<>) { + print OUT $_; + } + close (OUT); + open (IN, $temp); + open (OUT, ">$files[0]"); + binmode(IN); binmode(OUT); + local($/) = undef; + print OUT <IN>; + close(OUT); + close(IN); +} + +sub get_tmp_dir { + if (!($TMP)) { + local (@l) = ("TMPDIR", "TEMP", "TMP", "c${dd}tmp"); + local ($var, $dir); + foreach $var (@l) { + $dir = $ENV{$var}; + if (-d $dir) { + $TMP = $dir; + last; + } + } + } + $TMP =~ s/\\/$dd/g; + + if ($TMP =~ /$dd$/) { + } else { $TMP .= $dd } +} |