summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2015-06-23 04:33:46 +0000
committerNorbert Preining <preining@logic.at>2015-06-23 04:33:46 +0000
commit71ee50ca13287166e738dad2c16fb99cf874461c (patch)
treea04a1ce8f1f0d69462a4307776aab1982950e259
parent6af117183deee7cbe17905fb246b425bd7f645e7 (diff)
error handling for TLPaper
git-svn-id: svn://tug.org/texlive/trunk@37643 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl14
-rw-r--r--Master/tlpkg/TeXLive/TLConfig.pm15
-rw-r--r--Master/tlpkg/TeXLive/TLPaper.pm57
3 files changed, 51 insertions, 35 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index 12ff8c373dc..71cddb4a763 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -125,20 +125,6 @@ our $FLAG_REINSTALL = "I";
our $common_fmtutil_args =
"--no-error-if-no-engine=$TeXLive::TLConfig::PartialEngineSupport";
-# return flags for error handling
-#
-# all fine
-our $F_OK = 0;
-#
-# some warnings, but we still try to run post actions
-our $F_WARNING = 1;
-#
-# error, terminating
-our $F_ERROR = 2;
-#
-# all fine, but no need to run post actions
-our $F_NOPOSTACTION = 4;
-
# option variables
$::gui_mode = 0;
$::machinereadable = 0;
diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm
index ed8a060ade7..8616de028c0 100644
--- a/Master/tlpkg/TeXLive/TLConfig.pm
+++ b/Master/tlpkg/TeXLive/TLConfig.pm
@@ -49,6 +49,7 @@ BEGIN {
%TLPDBConfigs
$NetworkTimeout
$PartialEngineSupport
+ $F_OK $F_WARNING $F_ERROR $F_NOPOSTACTION
);
@EXPORT = @EXPORT_OK;
}
@@ -198,6 +199,20 @@ our $PartialEngineSupport = "luajittex";
# timeout for network connections (wget, LWP) in seconds
our $NetworkTimeout = 30;
+# Flags for error handling across the scripts and modules
+# all fine
+our $F_OK = 0;
+#
+# some warnings, but we still try to run post actions
+our $F_WARNING = 1;
+#
+# error, terminating
+our $F_ERROR = 2;
+#
+# all fine, but no need to run post actions
+our $F_NOPOSTACTION = 4;
+
+
1;
diff --git a/Master/tlpkg/TeXLive/TLPaper.pm b/Master/tlpkg/TeXLive/TLPaper.pm
index aebe57598b5..e63419b0a6f 100644
--- a/Master/tlpkg/TeXLive/TLPaper.pm
+++ b/Master/tlpkg/TeXLive/TLPaper.pm
@@ -50,6 +50,7 @@ C<TeXLive::TLPaper> -- paper size setting
=cut
use TeXLive::TLUtils qw(:DEFAULT dirname merge_into mkdirhier);
+use TeXLive::TLConfig;
#
# removed the entry for dvipdfm
@@ -182,41 +183,46 @@ Returns the currently selected paper size for program C<$prog>.
=cut
sub get_paper {
- my @pps = get_paper_list(shift);
- return $pps[0];
+ my $pps = get_paper_list(shift);
+ return $pps->[0];
}
=item C<do_paper($prog,$texmfsysconfig,@args)>
Call the paper subroutine for C<$prog>, passing args.
+Returns a reference to a list of papers if called with C<--returnlist>,
+otherwise one of the standard flags (see TeXLive::TLConfig).
+
=cut
sub do_paper {
my ($prog,$texmfsysconfig,@args) = @_;
- my @ret = ();
if (exists $paper_sub{$prog}) {
my $sub = $paper_sub{$prog};
- @ret = &$sub($texmfsysconfig, @args);
+ return(&$sub($texmfsysconfig, @args));
} else {
tlwarn("$0: unknown paper program $prog ($texmfsysconfig,@args)\n");
+ return($F_ERROR);
}
- return @ret;
+ return ($F_OK); # not reached
}
=item C<paper_all($texmfsysconfig, $newpaper)>
Pass all C<@args> to each paper subroutine in turn, thus setting the
-paper size for all supported programs. Return merge of all returned
-hashes.
+paper size for all supported programs. Returns the bit-mapped return
+values of the single subroutine returns.
=cut
sub paper_all {
+ my $ret = $F_OK;
for my $p (sort keys %paper_sub) {
- &{$paper_sub{$p}} (@_);
+ $ret |= &{$paper_sub{$p}} (@_);
}
+ return($ret);
}
@@ -271,7 +277,7 @@ sub paper_xdvi {
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("xdvi", "other text files", $filecomp, $dftfile);
- return unless $inp;
+ return($F_ERROR) unless $inp;
my @sizes = keys %xdvi_papersize;
@@ -304,7 +310,7 @@ sub paper_pdftex {
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("pdftex", "tex", $filecomp, $dftfile);
- return unless $inp;
+ return($F_ERROR) unless $inp;
open(FOO, "<$inp") || die "$0: open($inp) failed: $!";
my @lines = <FOO>;
@@ -358,7 +364,7 @@ sub paper_pdftex {
for my $p (keys %pdftex_papersize) {
push @ret, $p unless ($p eq $currentpaper);
}
- return @ret;
+ return \@ret;
} else {
my $found = 0;
for my $p (keys %pdftex_papersize) {
@@ -398,18 +404,22 @@ sub paper_pdftex {
if (!open(TMP, ">$outfile")) {
tlwarn("$0: Cannot write to $outfile: $!\n");
tlwarn("Not setting paper size for pdftex.\n");
- return;
+ return($F_ERROR);
}
for (@lines) { print TMP; }
close(TMP) || warn "$0: close(>$outfile) failed: $!";
TeXLive::TLUtils::announce_execute_actions("regenerate-formats");
+ # TODO should we return the value of announce_execute action?
+ return($F_OK);
} else {
tlwarn("$0: Not a valid paper size for pdftex: $newpaper\n");
+ return($F_WARNING);
}
}
} else {
info("Current pdftex paper size (from $inp): $currentpaper\n");
}
+ return($F_OK);
}
@@ -449,7 +459,7 @@ sub paper_dvips {
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("dvips", "dvips config", $filecomp, $dftfile);
- return unless $inp;
+ return($F_ERROR) unless $inp;
open(FOO, "<$inp") || die "$0: open($inp) failed: $!";
my @lines = <FOO>;
@@ -485,7 +495,7 @@ sub paper_dvips {
info("$p\n"); # first is already the selected one
}
} elsif ($newpaper eq "--returnlist") {
- return(@papersizes);
+ return(\@papersizes);
} else {
my $found = 0;
for my $p (@papersizes) {
@@ -520,17 +530,19 @@ sub paper_dvips {
if (!open(TMP, ">$outfile")) {
tlwarn("$0: Cannot write to $outfile: $!\n");
tlwarn("Not setting paper size for dvips.\n");
- return ();
+ return ($F_ERROR);
}
for (@newlines) { print TMP; }
close(TMP) || warn "$0: close(>$outfile) failed: $!";
} else {
tlwarn("$0: Not a valid paper size for dvips: $newpaper\n");
+ return($F_WARNING);
}
}
} else {
info("Current dvips paper size (from $inp): $papersizes[0]\n");
}
+ return($F_OK);
}
@@ -569,7 +581,7 @@ sub paper_dvipdfm {
my ($outcomp, $filecomp) = setup_names("dvipdfm");
my $dftfile = $default_paper_config_name{"dvipdfm"};
my $inp = &find_paper_file("dvipdfm", "other text files", $filecomp, $dftfile);
- return () unless $inp;
+ return ($F_ERROR) unless $inp;
my @sizes = keys %dvipdfm_papersize;
return &do_dvipdfm_and_x($inp, "dvipdfm", $outtree, \@sizes, $newpaper);
@@ -583,7 +595,7 @@ sub paper_dvipdfmx {
my $dftfile = $default_paper_config_name{"dvipdfmx"};
my $inp = &find_paper_file("dvipdfmx", "other text files", $filecomp, $dftfile);
- return () unless $inp;
+ return ($F_ERROR) unless $inp;
my @sizes = keys %dvipdfm_papersize;
return &do_dvipdfm_and_x($inp, "dvipdfmx", $outtree, \@sizes, $newpaper);
@@ -605,7 +617,7 @@ sub paper_context {
my $dftfile = $default_paper_config_name{"context"};
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("context", "tex", $filecomp, "cont-sys.rme", $dftfile);
- return () unless $inp;
+ return ($F_ERROR) unless $inp;
my @sizes = keys %pdftex_papersize;
# take care here, the \\\\ are necessary in some places and not in
@@ -637,7 +649,7 @@ sub paper_psutils {
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("psutils", "other text files", $filecomp, $dftfile);
- return unless $inp;
+ return ($F_ERROR) unless $inp;
my @sizes = keys %psutils_papersize;
@@ -705,7 +717,7 @@ sub paper_do_simple {
for my $p (@$paplist) {
push @ret, $p unless ($p eq $currentpaper);
}
- return(@ret);
+ return(\@ret);
} else {
my $found = 0;
for my $p (@$paplist) {
@@ -737,20 +749,23 @@ sub paper_do_simple {
if (!open(TMP, ">$outp")) {
tlwarn("$0: Cannot write to $outp: $!\n");
tlwarn("Not setting paper size for $prog.\n");
- return;
+ return ($F_ERROR);
}
for (@newlines) { print TMP; }
close(TMP) || warn "$0: close(>$outp) failed: $!";
TeXLive::TLUtils::announce_execute_actions("regenerate-formats")
if ($prog eq "context");
+ return($F_OK);
} else {
tlwarn("$0: Not a valid paper size for $prog: $newpaper\n");
+ return($F_WARNING);
}
}
} else {
# return the current value
info("Current $prog paper size (from $inp): $currentpaper\n");
}
+ return($F_OK);
}
=back