Browse Source

make fixupind.pl part of helper.pl

Karel Miko 8 years ago
parent
commit
1300c5ade5
3 changed files with 11 additions and 18 deletions
  1. 0 16
      fixupind.pl
  2. 9 0
      helper.pl
  3. 2 2
      makefile

+ 0 - 16
fixupind.pl

@@ -1,16 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-open(my $in, '<', 'crypt.ind');
-open(my $out, '>', 'crypt.ind.tmp');
-my $a = <$in>;
-print {$out} "$a\n\\addcontentsline{toc}{chapter}{Index}\n";
-while (<$in>) {
-   print {$out} $_;
-}
-close $out;
-close $in;
-system("mv -f crypt.ind.tmp crypt.ind");
-

+ 9 - 0
helper.pl

@@ -287,6 +287,7 @@ sub die_usage {
          $0 --check-makefiles
          $0 --check-all
          $0 --update-makefiles
+         $0 --fixupind crypt.ind
 MARKER
 }
 
@@ -296,9 +297,17 @@ GetOptions( "s|check-source"     => \my $check_source,
             "m|check-makefiles"  => \my $check_makefiles,
             "a|check-all"        => \my $check_all,
             "u|update-makefiles" => \my $update_makefiles,
+            "f|fixupind=s"       => \my $fixupind,
             "h|help"             => \my $help
           ) or die_usage;
 
+if ($fixupind) {
+  my $txt = read_file($fixupind);
+  $txt =~ s/^([^\n]*\n)/$1\n\\addcontentsline{toc}{chapter}{Index}\n/s;
+  write_file($fixupind, $txt);
+  exit 0;
+}
+
 my $failure;
 $failure ||= check_source()       if $check_all || $check_source;
 $failure ||= check_defines()      if $check_all || $check_defines;

+ 2 - 2
makefile

@@ -403,7 +403,7 @@ doc/crypt.pdf: crypt.tex
 	latex crypt $(silent_stdout)
 	latex crypt $(silent_stdout)
 	makeindex crypt.idx $(silent_stdout)
-	perl fixupind.pl
+	perl helper.pl --fixupind crypt.ind
 	pdflatex crypt $(silent_stdout)
 	sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf
 	mv -ivf crypt.pdf doc/crypt.pdf
@@ -415,7 +415,7 @@ docdvi: crypt.tex
 	latex crypt $(silent_stdout)
 	latex crypt $(silent_stdout)
 	makeindex crypt.idx
-	perl fixupind.pl
+	perl helper.pl --fixupind crypt.ind
 	latex crypt $(silent_stdout)
 	latex crypt $(silent_stdout)