[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/Pod-Simple-Texinfo pod2texi.pl lib/Pod/...
From: |
Patrice Dumas |
Subject: |
texinfo/Pod-Simple-Texinfo pod2texi.pl lib/Pod/... |
Date: |
Sat, 04 Feb 2012 23:26:12 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/02/04 23:26:12
Modified files:
Pod-Simple-Texinfo: pod2texi.pl
Pod-Simple-Texinfo/lib/Pod/Simple: Texinfo.pm
Log message:
Handle better input from stdin, by deferring getting the manual name.
Remove output when there is no content and doing a multi pod file
manual.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/pod2texi.pl?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm?cvsroot=texinfo&r1=1.9&r2=1.10
Patches:
Index: pod2texi.pl
===================================================================
RCS file: /sources/texinfo/texinfo/Pod-Simple-Texinfo/pod2texi.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- pod2texi.pl 4 Feb 2012 15:56:48 -0000 1.7
+++ pod2texi.pl 4 Feb 2012 23:26:11 -0000 1.8
@@ -109,6 +109,8 @@
exit 1 if (!$result_options);
+my $STDOUT_DOCU_NAME = 'stdout';
+
my @manuals;
my @all_manual_names;
@@ -121,7 +123,12 @@
unless (scalar(@input_files) >= 1);
# First gather all the manual names
-foreach my $file (@input_files) {
+if ($base_level > 0) {
+ foreach my $file (@input_files) {
+ # we don't want to read from STDIN, as the input read would be lost
+ # same with named pipe and socket...
+ # FIXME are there other file that have the same problem?
+ next if ($file eq '-' or -p $file or -S $file);
# not really used, only the manual name is used.
my $parser = Pod::Simple::PullParserRun->new();
$parser->parse_file($file);
@@ -133,6 +140,7 @@
} else {
push @all_manual_names, undef;
}
+ }
}
my $file_nr = 0;
@@ -147,10 +155,21 @@
$outfile = Pod::Simple::Texinfo::_pod_title_to_file_name($name);
$outfile .= '.texi';
} else {
+ if ($file eq '-') {
+ $outfile = $STDOUT_DOCU_NAME;
+ } else {
$outfile = $file;
+ }
+ if ($outfile =~ /\.(pm|pod)$/) {
$outfile =~ s/\.(pm|pod)$/.texi/i;
+ } else {
+ $outfile .= '.texi';
}
}
+ }
+
+ my $new = Pod::Simple::Texinfo->new();
+
push @included, [$name, $outfile] if ($base_level > 0);
my $fh;
if ($outfile eq '-') {
@@ -162,7 +181,6 @@
}
# FIXME should use =encoding
binmode($fh, ':encoding(utf8)');
- my $new = Pod::Simple::Texinfo->new();
$new->output_fh($fh);
$new->texinfo_sectioning_base_level($base_level);
if ($unnumbered_sections) {
@@ -177,10 +195,35 @@
close($fh) or die sprintf (__("%s: Close %s: %s.\n"),
$real_command_name, $outfile, $!);
}
+
+ if ($base_level > 0) {
+ if (!$new->content_seen) {
+ warn sprintf(__("%s: removing %s as input file %s has no content\n"),
+ $real_command_name, $outfile, $file);
+ unlink ($outfile);
+ pop @included;
+ # if we didn't gather the short title, try now, and rename out file if
found
+ } elsif (!defined($name)) {
+ my $short_title = $new->texinfo_short_title;
+ if (defined($short_title) and $short_title =~ /\S/) {
+ push @manuals, $short_title;
+ pop @included;
+ my $new_outfile
+ = Pod::Simple::Texinfo::_pod_title_to_file_name($short_title);
+ $new_outfile .= '.texi';
+ if ($new_outfile ne $outfile) {
+ unless (rename ($outfile, $new_outfile)) {
+ die sprintf(__("%s: Rename %s failed: %s\n"),
+ $real_command_name, $outfile, $!);
+ }
+ }
+ push @included, [$short_title, $new_outfile];
+ }
+ }
+ }
$file_nr++;
}
-my $STDOUT_DOCU_NAME = 'stdout';
if ($base_level > 0) {
my $fh;
if ($output ne '-') {
Index: lib/Pod/Simple/Texinfo.pm
===================================================================
RCS file:
/sources/texinfo/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- lib/Pod/Simple/Texinfo.pm 4 Feb 2012 15:56:48 -0000 1.9
+++ lib/Pod/Simple/Texinfo.pm 4 Feb 2012 23:26:12 -0000 1.10
@@ -63,6 +63,7 @@
# from other Pod::Simple modules. Creates accessor subroutine.
__PACKAGE__->_accessorize(
'texinfo_sectioning_base_level',
+ 'texinfo_short_title',
'texinfo_man_url_prefix',
'texinfo_sectioning_style',
'texinfo_add_upper_sectioning_command',
@@ -146,18 +147,21 @@
my $fh = $self->{'output_fh'};
+ if (!defined($self->texinfo_short_title)) {
my $short_title = $self->get_short_title();
if (defined($short_title) and $short_title =~ m/\S/) {
- $self->{'texinfo_short_title'} = $short_title;
+ $self->texinfo_short_title($short_title);
+ }
}
if ($self->texinfo_sectioning_base_level == 0) {
#print STDERR "$fh\n";
print $fh '\input texinfo'."\n";
my $setfilename;
- if (defined($self->{'texinfo_short_title'})) {
- $setfilename = _pod_title_to_file_name($self->{'texinfo_short_title'});
+ if (defined($self->texinfo_short_title)) {
+ $setfilename = _pod_title_to_file_name($self->texinfo_short_title);
} else {
+ # FIXME maybe output filename would be better than source_filename?
my $source_filename = $self->source_filename();
if (defined($source_filename) and $source_filename ne '') {
if ($source_filename eq '-') {
@@ -181,14 +185,14 @@
print $fh "address@hidden "._protect_text($title, 1)."\n\n";
}
print $fh "address@hidden Top\n";
- if (defined($self->{'texinfo_short_title'})) {
- print $fh "address@hidden
"._protect_text($self->{'texinfo_short_title'}, 1)."\n\n";
+ if (defined($self->texinfo_short_title)) {
+ print $fh "address@hidden "._protect_text($self->texinfo_short_title,
1)."\n\n";
}
- } elsif (defined($self->{'texinfo_short_title'})
+ } elsif (defined($self->texinfo_short_title)
and $self->texinfo_add_upper_sectioning_command) {
my $level = $self->texinfo_sectioning_base_level() - 1;
print $fh "address@hidden>{'texinfo_sectioning_commands'}->[$level] "
- ._protect_text($self->{'texinfo_short_title'}, 1)."\n\n";
+ ._protect_text($self->texinfo_short_title, 1)."\n\n";
}
}
@@ -308,7 +312,7 @@
chomp $texinfo_node_name;
$texinfo_node_name
- = $self->_section_manual_to_node_name($self->{'texinfo_short_title'},
+ = $self->_section_manual_to_node_name($self->texinfo_short_title,
$texinfo_node_name,
$self->texinfo_sectioning_base_level);
@@ -483,7 +487,7 @@
} elsif (defined($section) and $section =~ m/\S/) {
$texinfo_node =
$self->_section_manual_to_node_name(
- $self->{'texinfo_short_title'}, $section,
+ $self->texinfo_short_title, $section,
$self->texinfo_sectioning_base_level);
$texinfo_section = _normalize_texinfo_name(
_protect_comma(_protect_text($section)), 'section');