diff --git a/fixupind.pl b/fixupind.pl deleted file mode 100755 index ddefbd7..0000000 --- a/fixupind.pl +++ /dev/null @@ -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"); - diff --git a/helper.pl b/helper.pl index bc52302..b71569f 100755 --- a/helper.pl +++ b/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; diff --git a/makefile b/makefile index 217f85e..33d552c 100644 --- a/makefile +++ b/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)