summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2015-10-09 01:12:12 +0000
committerNorbert Preining <preining@logic.at>2015-10-09 01:12:12 +0000
commitc54b5388de1774b390a2da831ad90a9cb7e8e93d (patch)
treea189c4985e6fc209fa33cee40422bee883ee16e2
parente8275efdba4f5df154424b8bd8867f0334bbbcfc (diff)
adjust TLPaper for new pdftexconfig.tex
git-svn-id: svn://tug.org/texlive/trunk@38593 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/TeXLive/TLPaper.pm67
1 files changed, 46 insertions, 21 deletions
diff --git a/Master/tlpkg/TeXLive/TLPaper.pm b/Master/tlpkg/TeXLive/TLPaper.pm
index 06c8dd2e5ca..66c834636d7 100644
--- a/Master/tlpkg/TeXLive/TLPaper.pm
+++ b/Master/tlpkg/TeXLive/TLPaper.pm
@@ -302,8 +302,10 @@ sub paper_xdvi {
# pdftex pdftexconfig.tex format
# /--- pdftexconfig.tex ---
# |...
-# |\pdfpagewidth=NNN true <unit>
-# |\pdfpageheight=NNN true <unit>
+# |\ifx\pdfpagewidth\undefined\else \pdfpagewidth=210 true mm \fi
+# |\ifx\pagewidth\undefined\else \pagewidth=210 true mm \fi
+# |\ifx\pdfpageheight\undefined\else \pdfpageheight=297 true mm \fi
+# |\ifx\pageheight\undefined\else \pageheight=297 true mm \fi
# |...
# \------------------------
#
@@ -324,20 +326,29 @@ sub paper_pdftex {
my @lines = <FOO>;
close(FOO);
+ my @cpwidx;
+ my @cphidx;
my ($cpw, $cph);
- my ($cpwidx, $cphidx);
my $endinputidx;
# read the lines and the last pdfpageswidth/height wins
for my $idx (0..$#lines) {
my $l = $lines[$idx];
- if ($l =~ m/^\s*\\pdfpagewidth\s*=?\s*(.+)\s*$/) {
- $cpw = $1;
- $cpwidx = $idx;
+ if ($l =~ m/\\(pdf|luatex|)pagewidth\s*=?\s*([0-9\.][0-9\.]*\s+true\s+[^\s]*)/) {
+ if (defined($cpw) && $cpw ne $2) {
+ tl_warn("TLPaper: inconsistent paper sizes in $inp for page width! Please fix that.\n");
+ return $F_ERROR;
+ }
+ $cpw = $2;
+ push @cpwidx, $idx;
next;
}
- if ($l =~ m/^\s*\\pdfpageheight\s*=?\s*(.+)\s*$/) {
- $cph = $1;
- $cphidx = $idx;
+ if ($l =~ m/\\(pdf|luatex|)pageheight\s*=?\s*([0-9\.][0-9\.]*\s+true\s+[^\s]*)/) {
+ if (defined($cph) && $cph ne $2) {
+ tl_warn("TLPaper: inconsistent paper sizes in $inp for page height! Please fix that.\n");
+ return $F_ERROR;
+ }
+ $cph = $2;
+ push @cphidx, $idx;
next;
}
if ($l =~ m/^\s*\\endinput\s*/) {
@@ -382,26 +393,40 @@ sub paper_pdftex {
}
}
if ($found) {
- my $newwline =
- '\pdfpagewidth=' . ${$pdftex_papersize{$newpaper}}[0] . "\n";
- my $newhline =
- '\pdfpageheight=' . ${$pdftex_papersize{$newpaper}}[1] . "\n";
- if (defined($cpwidx)) {
- $lines[$cpwidx] = $newwline;
+ my $newwidth = ${$pdftex_papersize{$newpaper}}[0];
+ my $newheight = ${$pdftex_papersize{$newpaper}}[1];
+ if (@cpwidx) {
+ for my $idx (@cpwidx) {
+ ddebug("TLPaper: before line: $lines[$idx]");
+ ddebug("TLPaper: replacement: $newwidth\n");
+ $lines[$idx] =~ s/pagewidth\s*=\s*[0-9\.][0-9\.]*\s+true\s+[^\s]*/pagewidth=$newwidth/;
+ ddebug("TLPaper: after line : $lines[$idx]");
+ }
} else {
+ my $addlines = '\ifx\pdfpagewidth\undefined\else \pdfpagewidth=' . $newwidth . ' \fi' . "\n";
+ $addlines .= '\ifx\luatexpagewidth\undefined\else \luatexpagewidth=' . $newwidth . ' \fi' . "\n";
+ $addlines .= '\ifx\pagewidth\undefined\else \pagewidth=' . $newwidth . ' \fi' . "\n";
if (defined($endinputidx)) {
- $lines[$endinputidx] = $newwline . $lines[$endinputidx];
+ $lines[$endinputidx] = $addlines . $lines[$endinputidx];
} else {
- $lines[$#lines] = $newwline;
+ $lines[$#lines] = $addlines;
}
}
- if (defined($cphidx)) {
- $lines[$cphidx] = $newhline;
+ if (@cphidx) {
+ for my $idx (@cphidx) {
+ ddebug("TLPaper: before line: $lines[$idx]");
+ ddebug("TLPaper: replacement: $newheight\n");
+ $lines[$idx] =~ s/pageheight\s*=\s*[0-9\.][0-9\.]*\s+true\s+[^\s]*/pageheight=$newheight/;
+ ddebug("TLPaper: after line : $lines[$idx]");
+ }
} else {
+ my $addlines = '\ifx\pdfpageheight\undefined\else \pdfpageheight=' . $newheight . ' \fi' . "\n";
+ $addlines .= '\ifx\luatexpageheight\undefined\else \luatexpageheight=' . $newheight . ' \fi' . "\n";
+ $addlines .= '\ifx\pageheight\undefined\else \pageheight=' . $newheight . ' \fi' . "\n";
if (defined($endinputidx)) {
- $lines[$endinputidx] = $newhline . $lines[$endinputidx];
+ $lines[$endinputidx] = $addlines . $lines[$endinputidx];
} else {
- $lines[$#lines] = $newwline;
+ $lines[$#lines] = $addlines;
}
}
info("$0: setting paper size for pdftex to $newpaper.\n");