This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Update etc/texi2pod.pl
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 11 Jun 2002 16:33:58 +0100
- Subject: Update etc/texi2pod.pl
Hi Guys,
I am applying the patch below to update the copy of texi2pod.pl in
the etc/ directory with the changes made to the version in the FSF
GCC source repository.
I am also considering another change - moving the file to a (newly
created) contrib directory. Currently binutils keeps texi2pod.pl in
the etc/ directory whereas gcc keeps it in the contrib/ directory.
This makes making a single combined source tree a bit of a pain.
Are there any objections or suggestions about this ?
Cheers
Nick
2002-06-11 Nick Clifton <nickc@cambridge.redhat.com>
Import the following patches from the FSF GCC sources:
2002-03-25 Zack Weinberg <zack@codesourcery.com>
* texi2pod.pl: Handle @end ftable and @end vtable.
2001-12-12 Matthias Klose <doko@debian.org>
* texi2pod.pl: Merge changes from binutils' texi2pod.pl. Allows
generation of more than one man page from one source.
Add '-' to set of valid chars for an identifier.
Let -D option accept flags of the form <flag>=<value>.
Use \s+ for whitespace detection in '@c man' lines.
Handle @set and @clear independent of $output.
Substitute all @value{}'s in a line.
2001-11-14 Joseph S. Myers <jsm28@cam.ac.uk>
* texi2pod.pl: Handle @ifnottex, @iftex and @display. Handle @var
in verbatim blocks specially. Handle @unnumbered, @unnumberedsec
and @center. Allow [a-z] after @enumerate. Handle 0 and numbers
greater than 9 in enumerations.
Index: etc/texi2pod.pl
===================================================================
RCS file: /cvs/src/src/etc/texi2pod.pl,v
retrieving revision 1.1
diff -c -3 -p -w -r1.1 texi2pod.pl
*** etc/texi2pod.pl 26 Mar 2001 21:42:48 -0000 1.1
--- etc/texi2pod.pl 11 Jun 2002 15:22:37 -0000
*************** $section = "";
*** 30,38 ****
--- 30,41 ----
@icstack = ();
@endwstack = ();
@skstack = ();
+ @instack = ();
$shift = "";
%defs = ();
$fnno = 1;
+ $inf = "";
+ $ibase = "";
while ($_ = shift) {
if (/^-D(.*)$/) {
*************** while ($_ = shift) {
*** 41,55 ****
} else {
$flag = shift;
}
! $value=$flag;
! $value =~ s,^[a-zA-Z0-9_]+,,;
! $value =~ s,.*=,,;
! $flag =~ s,=.*$,,;
die "no flag specified for -D\n"
unless $flag ne "";
! #print STDERR "FL = $flag, V = $value\n";
$defs{$flag} = $value;
-
} elsif (/^-/) {
usage();
} else {
--- 44,56 ----
} else {
$flag = shift;
}
! $value = "";
! ($flag, $value) = ($flag =~ /^([^=]+)(?:=(.+))?/);
die "no flag specified for -D\n"
unless $flag ne "";
! die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
! unless $flag =~ /^[a-zA-Z0-9_-]+$/;
$defs{$flag} = $value;
} elsif (/^-/) {
usage();
} else {
*************** while ($_ = shift) {
*** 60,73 ****
}
if (defined $in) {
! open(STDIN, $in) or die "opening \"$in\": $!\n";
}
if (defined $out) {
open(STDOUT, ">$out") or die "opening \"$out\": $!\n";
}
! while(<STDIN>)
! {
# Certain commands are discarded without further processing.
/^\@(?:
[a-z]+index # @*index: useful only in complete manual
--- 61,79 ----
}
if (defined $in) {
! $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(defined $inf) {
! while(<$inf>) {
# Certain commands are discarded without further processing.
/^\@(?:
[a-z]+index # @*index: useful only in complete manual
*************** while(<STDIN>)
*** 75,80 ****
--- 81,87 ----
|(?:end\s+)?group # @group .. @end group: ditto
|page # @page: ditto
|node # @node: useful only in .info file
+ |(?:end\s+)?ifnottex # @ifnottex .. @end ifnottex: use contents
)\b/x and next;
chomp;
*************** while(<STDIN>)
*** 84,90 ****
/^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next;
# Identify a man title but keep only the one we are interested in.
! /^\@c man title ([A-Za-z0-9]+) (.+)/ and do {
if (exists $defs{$1}) {
$fn = $1;
$tl = postprocess($2);
--- 91,97 ----
/^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next;
# Identify a man title but keep only the one we are interested in.
! /^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do {
if (exists $defs{$1}) {
$fn = $1;
$tl = postprocess($2);
*************** while(<STDIN>)
*** 95,113 ****
# Look for blocks surrounded by @c man begin SECTION ... @c man end.
# This really oughta be @ifman ... @end ifman and the like, but such
# would require rev'ing all other Texinfo translators.
! /^\@c man begin ([A-Z]+) ([A-Za-z0-9]+)/ and do {
$output = 1 if exists $defs{$2};
$sect = $1;
next;
};
! /^\@c man begin ([A-Z]+)/ and $sect = $1, $output = 1, next;
! /^\@c man end/ and do {
$sects{$sect} = "" unless exists $sects{$sect};
$sects{$sect} .= postprocess($section);
$section = "";
$output = 0;
next;
};
next unless $output;
# Discard comments. (Can't do it above, because then we'd never see
--- 102,131 ----
# Look for blocks surrounded by @c man begin SECTION ... @c man end.
# This really oughta be @ifman ... @end ifman and the like, but such
# would require rev'ing all other Texinfo translators.
! /^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do {
$output = 1 if exists $defs{$2};
$sect = $1;
next;
};
! /^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next;
! /^\@c\s+man\s+end/ and do {
$sects{$sect} = "" unless exists $sects{$sect};
$sects{$sect} .= postprocess($section);
$section = "";
$output = 0;
next;
};
+
+ # handle variables
+ /^\@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;
# Discard comments. (Can't do it above, because then we'd never see
*************** while(<STDIN>)
*** 120,139 ****
# Ignore @end foo, where foo is not an operation which may
# cause us to skip, if we are presently skipping.
my $ended = $1;
! next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu)$/;
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
$endw = pop @endwstack;
! if ($ended =~ /^(?:ifset|ifclear|ignore|menu)$/) {
$skipping = pop @skstack;
next;
! } elsif ($ended =~ /^(?:example|smallexample)$/) {
$shift = "";
$_ = ""; # need a paragraph break
! } elsif ($ended =~ /^(?:itemize|enumerate|table)$/) {
$_ = "\n=back\n";
$ic = pop @icstack;
} else {
--- 138,157 ----
# Ignore @end foo, where foo is not an operation which may
# cause us to skip, if we are presently skipping.
my $ended = $1;
! next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
$endw = pop @endwstack;
! if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
$skipping = pop @skstack;
next;
! } elsif ($ended =~ /^(?:example|smallexample|display)$/) {
$shift = "";
$_ = ""; # need a paragraph break
! } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
$_ = "\n=back\n";
$ic = pop @icstack;
} else {
*************** while(<STDIN>)
*** 160,166 ****
next;
};
! /^\@(ignore|menu)\b/ and do {
push @endwstack, $endw;
push @skstack, $skipping;
$endw = $1;
--- 178,184 ----
next;
};
! /^\@(ignore|menu|iftex)\b/ and do {
push @endwstack, $endw;
push @skstack, $skipping;
$endw = $1;
*************** while(<STDIN>)
*** 189,194 ****
--- 207,218 ----
s/\@\{/{/g;
s/\@\}/}/g;
s/\@\@/&at;/g;
+
+ # Inside a verbatim block, handle @var specially.
+ if ($shift ne "") {
+ s/\@var\{([^\}]*)\}/<$1>/g;
+ }
+
# POD doesn't interpret E<> inside a verbatim block.
if ($shift eq "") {
s/</</g;
*************** while(<STDIN>)
*** 199,209 ****
}
# Single line command handlers.
- /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and $defs{$1} = $2, next;
- /^\@clear\s+([a-zA-Z0-9_-]+)/ and delete $defs{$1}, next;
! /^\@section\s+(.+)$/ and $_ = "\n=head2 $1\n";
! /^\@subsection\s+(.+)$/ and $_ = "\n=head3 $1\n";
# Block command handlers:
/^\@itemize\s+(\@[a-z]+|\*|-)/ and do {
--- 223,244 ----
}
# Single line command handlers.
! /^\@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 {
*************** while(<STDIN>)
*** 214,220 ****
$endw = "itemize";
};
! /^\@enumerate(?:\s+([A-Z0-9]+))?/ and do {
push @endwstack, $endw;
push @icstack, $ic;
if (defined $1) {
--- 249,255 ----
$endw = "itemize";
};
! /^\@enumerate(?:\s+([a-zA-Z0-9]+))?/ and do {
push @endwstack, $endw;
push @icstack, $ic;
if (defined $1) {
*************** while(<STDIN>)
*** 226,244 ****
$endw = "enumerate";
};
! /^\@table\s+(\@[a-z]+)/ and do {
push @endwstack, $endw;
push @icstack, $ic;
! $ic = $1;
$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)/ and do {
push @endwstack, $endw;
$endw = $1;
$shift = "\t";
--- 261,279 ----
$endw = "enumerate";
};
! /^\@([fv]?table)\s+(\@[a-z]+)/ and do {
push @endwstack, $endw;
push @icstack, $ic;
! $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";
};
! /^\@((?:small)?example|display)/ and do {
push @endwstack, $endw;
$endw = $1;
$shift = "\t";
*************** while(<STDIN>)
*** 251,262 ****
$_ = "\n=item $ic\<$1\>\n";
} else {
$_ = "\n=item $ic\n";
! $ic =~ y/A-Ya-y1-8/B-Zb-z2-9/;
}
};
$section .= $shift.$_."\n";
}
die "No filename or title\n" unless defined $fn && defined $tl;
--- 286,302 ----
$_ = "\n=item $ic\<$1\>\n";
} else {
$_ = "\n=item $ic\n";
! $ic =~ y/A-Ya-y/B-Zb-z/;
! $ic =~ s/(\d+)/$1 + 1/eg;
}
};
$section .= $shift.$_."\n";
}
+ # End of current file.
+ close($inf);
+ $inf = pop @instack;
+ }
die "No filename or title\n" unless defined $fn && defined $tl;
*************** sub postprocess
*** 284,296 ****
local $_ = $_[0];
# @value{foo} is replaced by whatever 'foo' is defined as.
! if (/\@value\{([a-zA-Z0-9_-]+)\}/) {
! if (! exists $defs{$1}) {
! print STDERR "Option $1 not define\n";
}
-
}
- s/\@value\{([a-zA-Z0-9_-]+)\}/$defs{$1}/g;
# Formatting commands.
# Temporary escape for @r.
--- 324,338 ----
local $_ = $_[0];
# @value{foo} is replaced by whatever 'foo' is defined as.
! while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) {
! if (! exists $defs{$2}) {
! print STDERR "Option $2 not defined\n";
! s/\Q$1\E//;
! } else {
! $value = $defs{$2};
! s/\Q$1\E/$value/;
}
}
# Formatting commands.
# Temporary escape for @r.
*************** sub postprocess
*** 303,311 ****
s/\@w\{([^\}]*)\}/S<$1>/g;
s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
- # Handle @r inside bold.
- 1 while s/B<((?:[^<>]|I<[^<>]*>)*)R<([^>]*)>/B<$1>${2}B</g;
-
# Cross references are thrown away, as are @noindent and @refill.
# (@noindent is impossible in .pod, and @refill is unnecessary.)
# @* is also impossible in .pod; we discard it and any newline that
--- 345,350 ----
*************** sub postprocess
*** 327,335 ****
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
# Turn B<blah I<blah> blah> into B<blah> I<blah> B<blah> to
! # match Texinfo semantics of @emph inside @samp.
s/</</g;
s/>/>/g;
1 while (s/B<([^<>]*)I<([^>]+)>/B<$1>I<$2>B</g);
1 while (s/I<([^<>]*)B<([^>]+)>/I<$1>B<$2>I</g);
s/[BI]<>//g;
--- 366,376 ----
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
# Turn B<blah I<blah> blah> into B<blah> I<blah> B<blah> to
! # match Texinfo semantics of @emph inside @samp. Also handle @r
! # inside bold.
s/</</g;
s/>/>/g;
+ 1 while s/B<((?:[^<>]|I<[^<>]*>)*)R<([^>]*)>/B<$1>${2}B</g;
1 while (s/B<([^<>]*)I<([^>]+)>/B<$1>I<$2>B</g);
1 while (s/I<([^<>]*)B<([^>]+)>/I<$1>B<$2>I</g);
s/[BI]<>//g;
*************** sub add_footnote
*** 373,375 ****
--- 414,427 ----
$sects{FOOTNOTES} .= "\n\n";
}
+ # stolen from Symbol.pm
+ {
+ my $genseq = 0;
+ sub gensym
+ {
+ my $name = "GEN" . $genseq++;
+ my $ref = \*{$name};
+ delete $::{$name};
+ return $ref;
+ }
+ }