[xml/sgml-commit] [SCM] linuxdoc-tools package for Debian. branch, master, updated. debian/0.9.31-5-g870695b
Agustin Martin Domingo
agmartin at debian.org
Mon Jun 9 10:20:30 UTC 2008
The following commit has been merged in the master branch:
commit ccb691cc416765f3cd626d125d528bb1f512e3ce
Author: Agustin Martin Domingo <agmartin at debian.org>
Date: Tue Jun 3 20:10:25 2008 +0200
Improve indirect filehandles. Use perl>=5.006
* Make sure we use at least perl 5.006
* More indirect filehandles
* Scope indirect filehandles closer to their use
* Do not use '&' when calling functions
* Cosmetic changes
diff --git a/lib/LinuxDocTools.pm b/lib/LinuxDocTools.pm
index 4c664f9..6e92f90 100755
--- a/lib/LinuxDocTools.pm
+++ b/lib/LinuxDocTools.pm
@@ -2,8 +2,6 @@
#
# LinuxDocTools.pm
#
-# $Id: LinuxDocTools.pm,v 1.5 2001/10/18 13:38:03 sano Exp $
-#
# LinuxDoc-Tools driver core. This contains all the basic functionality
# we need to control all other components.
#
@@ -14,7 +12,7 @@
package LinuxDocTools;
-require 5.004;
+require 5.006;
use strict;
=head1 NAME
@@ -42,12 +40,6 @@ but the encapsulation should provide for a simple interface for other users as w
=cut
-# use FileHandle;
-# use DirHandle;
-# use File::Find;
-# use IPC::Open2;
-# use Cwd;
-
use File::Basename;
use File::Copy;
use LinuxDocTools::Lang;
@@ -81,12 +73,11 @@ sub ldt_getdtd_v1 {
# -----------------------------------------------------------------------------------
# Get the dtd
# -----------------------------------------------------------------------------------
- my $file = shift;
+ my $file = shift;
my $error_header = "LinuxdocTools::ldt_getdtd_v1";
my $dtd;
- my $FILE;
- open ($FILE, "< $file")
+ open ( my $FILE, "< $file")
or die "$error_header: Could not open \"$file\" for reading. Aborting ...\n";
while ( <$FILE> ) {
@@ -139,12 +130,11 @@ sub ldt_getdtd_v2 {
# -----------------------------------------------------------------------------------
# Second way of getting dtd, fron nsgmls output.
# -----------------------------------------------------------------------------------
- my $preaspout = shift;
+ my $preaspout = shift;
my $error_header = "LinuxdocTools::ldt_getdtd_v2";
my $dtd2;
- my $TMP;
- open ($TMP,"< $preaspout")
+ open (my $TMP,"< $preaspout")
or die "%error_header: Could not open $preaspout for reading. Aborting ...\n";
while ( ($dtd2 = <$TMP>) && ! ( $dtd2 =~ /^\(/) ) { };
close $TMP;
@@ -294,6 +284,7 @@ sub init {
$global->{include} = "";
$global->{pass} = "";
$global->{InFiles} = [];
+ $global->{fmtlist} = ""; # List of loaded fmt files
$Formats{$global->{NAME}} = $global; # All formats we know.
$FmtList{$global->{NAME}} = $global; # List of formats for help msgs.
@@ -301,11 +292,11 @@ sub init {
my $error_header = "LinuxdocTools::init";
if ( -e "/etc/papersize" ){
- open (PAPERSIZE,"< /etc/papersize") ||
+ open (my $PAPERSIZE,"< /etc/papersize") ||
die "$error_header: Count not open \"/etc/papersize\" for reading\n";
- chomp (my $paper = <PAPERSIZE>);
+ chomp (my $paper = <$PAPERSIZE>);
$global->{papersize} = "letter" if ( $paper eq "letter");
- close PAPERSIZE;
+ close $PAPERSIZE;
}
# automatic language detection: disabled by default
@@ -345,7 +336,7 @@ sub init {
}
foreach my $fmt ( keys %locations ){
- # print STDERR "Loading \'$locations{$fmt}\' for format \'$fmt\'\n";
+ $global->{fmtlist} .= " Loading $locations{$fmt}\n";
require $locations{$fmt};
}
}
@@ -387,7 +378,7 @@ sub process_options {
}
unless ( $format ){
- my ($tmpfmt, $dummy1, $dummy2) = &fileparse($progname, "");
+ my ($tmpfmt, $dummy1, $dummy2) = fileparse($progname, "");
if ( $tmpfmt =~ s/^sgml2// ) { # Calling program through sgml2xx symlinks
$format = $tmpfmt;
} elsif ( $tmpfmt eq "sgmlcheck" ) { # Calling program through sgmlcheck symlink
@@ -402,20 +393,20 @@ sub process_options {
$format = "latex2e";
}
$FmtList{$format} = $Formats{$format} or
- &usage ("$format: Unknown format");
+ usage("$format: Unknown format");
$global->{format} = $format;
} else {
- &usage("");
+ usage("");
}
# Parse all the options from @args, and return files.
- my @files = LinuxDocTools::Utils::process_options (@args);
+ my @files = LinuxDocTools::Utils::process_options(@args);
# Check the number of given files
- $#files > -1 || usage ("No filenames given");
+ $#files > -1 || usage("No filenames given");
# Normalize language string
- $global->{language} = Any2ISO ($global->{language});
+ $global->{language} = Any2ISO($global->{language});
# Setup the SGML environment.`iso-entites' sub directory will be removed for Debian package
# and entities from Debian sgml-data package used if present (first entry below).
@@ -429,9 +420,12 @@ sub process_options {
$ENV{SGML_CATALOG_FILES} = join(':', @sgmlcatalogs);
# Set to one of these if readable, nil otherwise
- $ENV{SGMLDECL} = &ldt_searchfile (["$main::DataDir/dtd/$global->{format}.dcl",
- "$main::DataDir/dtd/$global->{style}.dcl",
- "$main::DataDir/dtd/sgml.dcl"]);
+ $ENV{SGMLDECL} = ldt_searchfile(["$main::DataDir/dtd/$global->{format}.dcl",
+ "$main::DataDir/dtd/$global->{style}.dcl",
+ "$main::DataDir/dtd/sgml.dcl"]);
+
+ # Show the list of loaded fmt_*.pl files if debugging
+ print STDERR $global->{fmtlist} if $global->{debug};
# Return the list of files to be processed
return @files;
@@ -470,26 +464,21 @@ etcetera. See the code for details.
# ------------------------------------------------------------------------
sub process_file {
# ------------------------------------------------------------------------
- my $file = shift (@_);
- my $saved_umask = umask;
- my $error_header = "LinuxdocTools::process_file";
- my $IFILE;
- my $WRITENSGMLS;
- my $PREASP_IN;
- my $PREASP_OUT;
- my $INPOSTASP;
+ my $file = shift (@_);
+ my $saved_umask = umask;
+ my $error_header = "LinuxdocTools::process_file";
print "Processing file $file\n";
umask 0077;
- my ($filename, $filepath, $filesuffix) = fileparse ($file, "\.sgml");
+ my ($filename, $filepath, $filesuffix) = fileparse($file, "\.sgml");
$global->{filename} = $filename;
$global->{filepath} = $filepath;
- $global->{file} = &ldt_searchfile(["$filepath/$filename.sgml",
- "$filepath/$filename.SGML"])
+ $global->{file} = ldt_searchfile(["$filepath/$filename.sgml",
+ "$filepath/$filename.SGML"])
or die "$error_header: Cannot find $file. Aborting ...\n";
- my $dtd = &ldt_getdtd_v1("$global->{file}");
+ my $dtd = ldt_getdtd_v1("$global->{file}");
print STDERR "DTD: " . $dtd . "\n" if $global->{debug};
# Prepare temporary directory
@@ -498,7 +487,7 @@ sub process_file {
if ( -e $tmpdir ) {
die "$error_header: $tmpdir already exists. Aborting ...\n";
} else {
- mkdir ($tmpdir, 0700) ||
+ mkdir($tmpdir, 0700) ||
die "$error_header: Temporary files can not be created. Aborting ...\n";
}
@@ -532,6 +521,7 @@ sub process_file {
# If a preNSGMLS function is defined in the fmt file, pipe its output to $FILE,
# otherwise just open $global->{file} as $IFILE
# ----------------------------------------------------------------------------
+ my $IFILE;
if ( defined $Formats{$global->{format}}{preNSGMLS} ) {
$global->{NsgmlsPrePipe} = &{$Formats{$global->{format}}{preNSGMLS}};
open ($IFILE,"$global->{NsgmlsPrePipe} |")
@@ -541,12 +531,12 @@ sub process_file {
|| die "$error_header: Could not open $global->{file} for reading. Aborting ...\n";
}
- open ($WRITENSGMLS,
+ open (my $WRITENSGMLS,
"$precmd | $main::progs->{NSGMLS} $global->{NsgmlsOpts} $ENV{SGMLDECL} > $nsgmlsout")
or die "$error_header: Could not open pipe to $nsgmlsout. Aborting ...\n";
if ($global->{charset} eq "latin") {
- print $WRITENSGMLS &ldt_latin1tosgml($IFILE);
+ print $WRITENSGMLS ldt_latin1tosgml($IFILE);
} else {
copy($IFILE,$WRITENSGMLS);
}
@@ -555,7 +545,7 @@ sub process_file {
close $WRITENSGMLS;
# Special case: if format is global, we're just checking.
- &cleanup if ( $global->{format} eq "global");
+ cleanup if ( $global->{format} eq "global");
# If output file does not exists or is empty, something went wrong.
if ( ! -e "$nsgmlsout" ) {
@@ -568,13 +558,13 @@ sub process_file {
# If a preASP stage is defined, let the format handle it.
# --------------------------------------------------------
- open ($PREASP_IN, "< $nsgmlsout")
+ open (my $PREASP_IN, "< $nsgmlsout")
or die "$error_header: Could not open $nsgmlsout for reading. Aborting ...\n";
- open ($PREASP_OUT, "> $preaspout")
+ open (my $PREASP_OUT, "> $preaspout")
or die "$error_header: Could not open $preaspout for writing. Aborting ...\n";
if (defined $Formats{$global->{format}}{preASP}) {
- # preASP ($INHANDLE, $OUTHANDLE);
+ # Usage: preASP ($INHANDLE, $OUTHANDLE);
&{$Formats{$global->{format}}{preASP}}($PREASP_IN, $PREASP_OUT) == 0
or die "$error_header: Error pre-processing $global->{format}.\n";
} else {
@@ -583,6 +573,7 @@ sub process_file {
close $PREASP_IN;
close $PREASP_OUT;
+
die "$error_header: Can't create $preaspout file. Aborting ...\n"
unless -e "$preaspout";
@@ -590,7 +581,7 @@ sub process_file {
# Run sgmlsasp, with an optional style if specified.
# -----------------------------------------------------------
- my $dtd2 = &ldt_getdtd_v2($preaspout)
+ my $dtd2 = ldt_getdtd_v2($preaspout)
or die "$error_header: Could not read dtd from $preaspout. Aborting ...\n";
unless ( $dtd eq $dtd2 ){
@@ -603,13 +594,13 @@ sub process_file {
# - datadir/dist/<dtd>/<format>
my $style = ($global->{style}) ?
- &ldt_searchfile(["$main::DataDir/site/$dtd/$global->{format}/$global->{style}mapping",
- "$main::DataDir/dist/$dtd/$global->{format}/$global->{style}mapping"])
+ ldt_searchfile(["$main::DataDir/site/$dtd/$global->{format}/$global->{style}mapping",
+ "$main::DataDir/dist/$dtd/$global->{format}/$global->{style}mapping"])
:
'';
- my $mapping = &ldt_searchfile(["$main::DataDir/site/$dtd/$global->{format}/mapping",
- "$main::DataDir/dist/$dtd/$global->{format}/mapping"])
+ my $mapping = ldt_searchfile(["$main::DataDir/site/$dtd/$global->{format}/mapping",
+ "$main::DataDir/dist/$dtd/$global->{format}/mapping"])
or die "$error_header: Could not find mapping file for $dtd/$global->{format}. Aborting ...\n";
$mapping = "$style $mapping" if $style;
@@ -645,10 +636,10 @@ sub process_file {
# ----------------------------------------------------------------
umask $saved_umask;
- open ($INPOSTASP, "< $aspout" )
+ open (my $INPOSTASP, "< $aspout" )
or die "$error_header: Could not open $aspout for reading. Aborting ...\n";
if (defined $Formats{$global->{format}}{postASP}) {
- # postASP ($INHANDLE)
+ # Usage: postASP ($INHANDLE)
# Should leave whatever it thinks is right based on $INHANDLE.
&{$Formats{$global->{format}}{postASP}}($INPOSTASP) == 0
or die "$error_header: Error post-processing $global->{format}. Aborting ...\n";
@@ -658,7 +649,7 @@ sub process_file {
print "- postASP stage finished.\n" if ( $global->{debug} );
# All done, remove the temporaries.
- &remove_tmpfiles($tmpbase) unless ( $global->{debug} );
+ remove_tmpfiles($tmpbase) unless ( $global->{debug} );
}
=pod
--
linuxdoc-tools package for Debian.
More information about the debian-xml-sgml-commit
mailing list