mirror of https://github.com/CGAL/cgal
42 lines
1.2 KiB
Perl
Executable File
42 lines
1.2 KiB
Perl
Executable File
#!/opt/gnu/bin/perl -i.nopart
|
|
#
|
|
# ===========================================================================
|
|
#
|
|
# Index preprocessing script -- add_part_num
|
|
#
|
|
# $Revision$
|
|
# $Date$
|
|
#
|
|
# Script for adding part numbers to the page numbers of a CGAL reference
|
|
# manual .idx file. Part numbers are added as a leading digit on the page
|
|
# number without a separating character since makeindex insists on only
|
|
# integers as the page number argument. No other characters are allowed
|
|
# (not even spaces).
|
|
#
|
|
# ===========================================================================
|
|
#
|
|
if ($#ARGV != 1){
|
|
print "Usage: $0 part_num <filename.idx>\n";
|
|
}
|
|
else { # correct usage
|
|
|
|
$p = $ARGV[0]; # part number
|
|
if ($p =~ m/^[0-9]+$/) # test if it's an integer
|
|
{
|
|
$ARGV[0] = $ARGV[1]; # remove part number from argument array since while
|
|
# loop below assumes all arguments in the array are
|
|
# file names
|
|
$#ARGV--;
|
|
|
|
while (<>) {
|
|
s/\{(\d+)\}$/\{$p$1\}/;
|
|
print;
|
|
}
|
|
}
|
|
else {
|
|
print "Usage: $0 part_num <filename.idx>\n";
|
|
print " part_num $p invalid: must be an integer\n";
|
|
}
|
|
} # correct usage
|
|
__END__
|