diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-11 20:37:13 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-11 20:37:13 +0000 |
commit | 278d27f5a00ae2b34df9a46b0cc99990d18d8c83 (patch) | |
tree | 969966a3ac799c7d52b5574f9d1ee0ff46495746 /contrib/texi2pod.pl | |
parent | 0a106a56316034efac09b71c8ba7327944f3c4d1 (diff) | |
download | gcc-278d27f5a00ae2b34df9a46b0cc99990d18d8c83.tar.gz |
* contrib/texi2pod.pl: Handle @include, @ftable, @vtable.
Reformat some code for clarity.
* gcc/Makefile.in: Give texi2pod its input file as a command
line argument, not on stdin.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50592 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'contrib/texi2pod.pl')
-rwxr-xr-x | contrib/texi2pod.pl | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/contrib/texi2pod.pl b/contrib/texi2pod.pl index 770671a17b5..0cae122a788 100755 --- a/contrib/texi2pod.pl +++ b/contrib/texi2pod.pl @@ -30,9 +30,12 @@ $section = ""; @icstack = (); @endwstack = (); @skstack = (); +@instack = (); $shift = ""; %defs = (); $fnno = 1; +$inf = ""; +$ibase = ""; while ($_ = shift) { if (/^-D(.*)$/) { @@ -58,14 +61,19 @@ while ($_ = shift) { } if (defined $in) { - open(STDIN, $in) or die "opening \"$in\": $!\n"; + $inf = gensym(); + open($inf, "<$in") or die "opening \"$in\": $!\n"; + $ibase = $1 if $in =~ m|^(.+)/[^/]+$|; +} else { + $inf = \*STDIN; } + if (defined $out) { open(STDOUT, ">$out") or die "opening \"$out\": $!\n"; } -while(<STDIN>) -{ +while(defined $inf) { +while(<$inf>) { # Certain commands are discarded without further processing. /^\@(?: [a-z]+index # @*index: useful only in complete manual @@ -109,8 +117,14 @@ while(<STDIN>) }; # handle variables - /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and $defs{$1} = $2, next; - /^\@clear\s+([a-zA-Z0-9_-]+)/ and delete $defs{$1}, next; + /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do { + $defs{$1} = $2; + next; + }; + /^\@clear\s+([a-zA-Z0-9_-]+)/ and do { + delete $defs{$1}; + next; + }; next unless $output; @@ -210,8 +224,21 @@ while(<STDIN>) # Single line command handlers. - /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/ and $_ = "\n=head2 $1\n"; - /^\@subsection\s+(.+)$/ and $_ = "\n=head3 $1\n"; + /^\@include\s+(.+)$/ and do { + push @instack, $inf; + $inf = gensym(); + + # Try cwd and $ibase. + open($inf, "<" . $1) + or open($inf, "<" . $ibase . "/" . $1) + or die "cannot open $1 or $ibase/$1: $!\n"; + next; + }; + + /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/ + and $_ = "\n=head2 $1\n"; + /^\@subsection\s+(.+)$/ + and $_ = "\n=head3 $1\n"; # Block command handlers: /^\@itemize\s+(\@[a-z]+|\*|-)/ and do { @@ -234,16 +261,16 @@ while(<STDIN>) $endw = "enumerate"; }; - /^\@table\s+(\@[a-z]+)/ and do { + /^\@([fv]?table)\s+(\@[a-z]+)/ and do { push @endwstack, $endw; push @icstack, $ic; - $ic = $1; + $endw = $1; + $ic = $2; $ic =~ s/\@(?:samp|strong|key|gcctabopt|env)/B/; $ic =~ s/\@(?:code|kbd)/C/; $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; $ic =~ s/\@(?:file)/F/; $_ = "\n=over 4\n"; - $endw = "table"; }; /^\@((?:small)?example|display)/ and do { @@ -266,6 +293,10 @@ while(<STDIN>) $section .= $shift.$_."\n"; } +# End of current file. +close($inf); +$inf = pop @instack; +} die "No filename or title\n" unless defined $fn && defined $tl; @@ -382,3 +413,15 @@ sub add_footnote $sects{FOOTNOTES} .= $_[0]; $sects{FOOTNOTES} .= "\n\n"; } + +# stolen from Symbol.pm +{ + my $genseq = 0; + sub gensym + { + my $name = "GEN" . $genseq++; + my $ref = \*{$name}; + delete $::{$name}; + return $ref; + } +} |