@ -27,9 +27,9 @@ use warnings;
$ output = 0 ;
$ skipping = 0 ;
% se cts = ( ) ;
@ se cts_sequence = ( ) ;
$ section = "" ;
% chap ter s = ( ) ;
@ chap ter s_sequence = ( ) ;
$ chapter = "" ;
@ icstack = ( ) ;
@ endwstack = ( ) ;
@ skstack = ( ) ;
@ -116,18 +116,24 @@ INF: while(<$inf>) {
die "cannot open $1: $!\n" ;
} ;
# 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-Za-z ]+)/ and $ sect = $ 1 , push ( @ sects_sequence , $ sect ) , $ output = 1 , next ;
/^\@c\s+man\s+end/ and do {
$ sects { $ sect } = "" unless exists $ sects { $ sect } ;
$ se cts{ $ sect } . = postprocess ( $ section ) ;
$ section = "" ;
$ output = 0 ;
/^\@chapter\s+([A-Za-z ]+)/ and do {
# close old chapter
$ chapters { $ chapter_name } . = postprocess ( $ chapter ) if ( $ chapter_name ) ;
# start new chapter
$ chapter_name = $ 1 , push ( @ chapters_sequence , $ chapter_name ) ;
$ chap ter s { $ chapter_name } = "" unless exists $ chapters { $ chapter_name } ;
$ chapter = "" ;
$ output = 1 ;
next ;
} ;
/^\@bye/ and do {
# close old chapter
$ chapters { $ chapter_name } . = postprocess ( $ chapter ) if ( $ chapter_name ) ;
last INF ;
} ;
# handle variables
/^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
$ defs { $ 1 } = $ 2 ;
@ -293,7 +299,7 @@ INF: while(<$inf>) {
}
} ;
$ section . = $ shift . $ _ . "\n" ;
$ chapter . = $ shift . $ _ . "\n" ;
}
# End of current file.
close ( $ inf ) ;
@ -302,16 +308,15 @@ $inf = pop @instack;
die "No filename or title\n" unless defined $ fn && defined $ tl ;
$ se cts{ NAME } = "$fn \- $tl\n" ;
$ se cts{ FOOTNOTES } . = "=back\n" if exists $ se cts{ FOOTNOTES } ;
$ chap ter s { NAME } = "$fn \- $tl\n" ;
$ chap ter s { FOOTNOTES } . = "=back\n" if exists $ chap ter s { FOOTNOTES } ;
unshift @ sects_sequence , "NAME" ;
for $ sect ( @ sects_sequence ) {
if ( exists $ sects { $ sect } ) {
$ head = $ sect ;
$ head =~ s/SEEALSO/SEE ALSO/ ;
unshift @ chapters_sequence , "NAME" ;
for $ chapter ( @ chapters_sequence ) {
if ( exists $ chapters { $ chapter } ) {
$ head = uc ( $ chapter ) ;
print "=head1 $head\n\n" ;
print scalar unmunge ( $ se cts{ $ se ct} ) ;
print scalar unmunge ( $ chap ter s { $ chap ter } ) ;
print "\n" ;
}
}
@ -409,13 +414,13 @@ sub unmunge
sub add_footnote
{
unless ( exists $ se cts{ FOOTNOTES } ) {
$ se cts{ FOOTNOTES } = "\n=over 4\n\n" ;
unless ( exists $ chap ter s { FOOTNOTES } ) {
$ chap ter s { FOOTNOTES } = "\n=over 4\n\n" ;
}
$ se cts{ FOOTNOTES } . = "=item $fnno.\n\n" ; $ fnno + + ;
$ se cts{ FOOTNOTES } . = $ _ [ 0 ] ;
$ se cts{ FOOTNOTES } . = "\n\n" ;
$ chap ter s { FOOTNOTES } . = "=item $fnno.\n\n" ; $ fnno + + ;
$ chap ter s { FOOTNOTES } . = $ _ [ 0 ] ;
$ chap ter s { FOOTNOTES } . = "\n\n" ;
}
# stolen from Symbol.pm