2 # Since we use a linear search trought the block and the license and
3 # the warranty are quite big, we leave them at the end of the help file,
4 # the index will be consulted quite frequently, so we put it at the beginning.
6 $man2hlp = './man2hlp';
10 } elsif ($#ARGV == 3) {
12 } elsif ($#ARGV == 2) {
15 die "Usage: gindex.pl man_file tmpl_file out_file [Topic section header] [man2hlp]";
18 $man_file = "$ARGV[0]";
19 $tmpl_file = "$ARGV[1]";
20 $out_file = "$ARGV[2]";
23 open (HELP1
, "$man2hlp $help_width $man_file |") or
24 die "Cannot open read output of man2hlp: $!\n";;
28 open (HELP2
, "< $tmpl_file") or die "Cannot open $tmpl_file: $!\n";
29 push @help_file, <HELP2
>;
33 $Topics = shift (@help_file);
37 foreach $line (@help_file){
38 if ($line =~ /\x04\[(.*)\]/ && $line !~ /\x04\[main\]/){
44 $line =~ s/(\x04\[) */$1/;
45 } elsif (defined ($node)){
47 push @nodes, "$node\x02$line";
49 push @nodes, "$node\x02$node";
57 die "Cannot remove $out_file\n";
60 open (OUTPUT
, "> $out_file") or die "Cannot open $out_file: $!\n";
62 print OUTPUT
"\x04[Contents]\n$Topics\n\n";
63 foreach $node (@nodes){
65 $node =~ m/^( *)(.*)\x02(.*)$/;
66 print OUTPUT
(" $1\x01 $3 \x02$2\x03");
71 print OUTPUT
@help_file;