From 760d6a8115ede5a7f69f92f7aa7a10cb988c9516 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Thu, 28 Feb 2002 16:49:26 +0000 Subject: [PATCH] * gindex.pl: Use [nodename] as user visible section name only if next line is empty. Elsewhere use this nonempty line. --- src/ChangeLog | 3 +++ src/gindex.pl | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bac970db2..65d98bfdc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -14,6 +14,9 @@ (handle_command): Handle '.\"NODE' comment. Use it for nodename in translated manual pages. + * gindex.pl: Use [nodename] as user visible section name + only if next line is empty. Elsewhere use this nonempty line. + * find.c (find_parameters): Compile content_pattern here. Inform user about malformed regular expression. (search_content): Use compiled regular expression. diff --git a/src/gindex.pl b/src/gindex.pl index 8c332e5ca..6388bbbe7 100755 --- a/src/gindex.pl +++ b/src/gindex.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#! /usr/bin/perl -w # Since we use a linear search trought the block and the license and # the warranty are quite big, we leave them at the end of the help file, # the index will be consulted quite frequently, so we put it at the beginning. @@ -24,8 +24,19 @@ close (HELP2); foreach $line (@help_file){ if ($line =~ /\x04\[(.*)\]/ && $line !~ /\x04\[main\]/){ - push @nodes, $1; + if (length $1) { + $node = $1; + } else { + push @nodes, ''; + } $line =~ s/(\x04\[) */$1/; + } elsif (defined ($node)){ + if ($line ne "\n") { + push @nodes, "$node\x02$line"; + } else { + push @nodes, "$node\x02$node"; + } + undef ($node); } } @@ -39,8 +50,8 @@ open (OUTPUT, "> $out_file") or die "Cannot open $out_file: $!\n"; print OUTPUT "\x04[Contents]\nTopics:\n\n"; foreach $node (@nodes){ if (length $node){ - $node =~ m/^( *)(.*)$/; - printf OUTPUT (" %s\x01 %s \x02%s\x03", $1, $2, $2); + $node =~ m/^( *)(.*)\x02(.*)$/; + printf OUTPUT (" %s\x01 %s \x02%s\x03", $1, $3, $2); } print OUTPUT "\n"; }