diff options
author | Norbert Preining <preining@logic.at> | 2008-11-28 17:49:39 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-11-28 17:49:39 +0000 |
commit | c1dd01041bdaffa5c34cdc35563d7e8adab21781 (patch) | |
tree | 89fbf28f4fa050e7509600dbd0ee1ddd5b77a170 | |
parent | 6118480a3d5062d2547040178162a3d9e5cf6c94 (diff) |
add test code for perl reimplementation of texconf.tlu
git-svn-id: svn://tug.org/texlive/trunk@11457 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/tlpkg/etc/test-code-for-papersize-in-perl.pl | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/Master/tlpkg/etc/test-code-for-papersize-in-perl.pl b/Master/tlpkg/etc/test-code-for-papersize-in-perl.pl new file mode 100644 index 00000000000..1754614cf12 --- /dev/null +++ b/Master/tlpkg/etc/test-code-for-papersize-in-perl.pl @@ -0,0 +1,137 @@ + +$^W = 1; +use strict; + + +my %pdftex_papersize; +$pdftex_papersize{"letter"} = [ '8.5 true in', '11 true in' ]; +$pdftex_papersize{"a4"} = [ '210 true mm', '297 true mm' ]; + +my %xdvi_papersize; +$xdvi_papersize{'us'}='8.5x11'; +$xdvi_papersize{'usr'}='11x8.5'; +$xdvi_papersize{'legal'}='8.5x14'; +$xdvi_papersize{'foolscap'}='13.5x17.0'; +$xdvi_papersize{'a1'}='59.4x84.0cm'; +$xdvi_papersize{'a2'}='42.0x59.4cm'; +$xdvi_papersize{'a3'}='29.7x42.0cm'; +$xdvi_papersize{'a4'}='21.0x29.7cm'; +$xdvi_papersize{'a5'}='14.85x21.0cm'; +$xdvi_papersize{'a6'}='10.5x14.85cm'; +$xdvi_papersize{'a7'}='7.42x10.5cm'; +$xdvi_papersize{'a1r'}='84.0x59.4cm'; +$xdvi_papersize{'a2r'}='59.4x42.0cm'; +$xdvi_papersize{'a3r'}='42.0x29.7cm'; +$xdvi_papersize{'a4r'}='29.7x21.0cm'; +$xdvi_papersize{'a5r'}='21.0x14.85cm'; +$xdvi_papersize{'a6r'}='14.85x10.5cm'; +$xdvi_papersize{'a7r'}='10.5x7.42cm'; +$xdvi_papersize{'b1'}='70.6x100.0cm'; +$xdvi_papersize{'b2'}='50.0x70.6cm'; +$xdvi_papersize{'b3'}='35.3x50.0cm'; +$xdvi_papersize{'b4'}='25.0x35.3cm'; +$xdvi_papersize{'b5'}='17.6x25.0cm'; +$xdvi_papersize{'b6'}='13.5x17.6cm'; +$xdvi_papersize{'b7'}='8.8x13.5cm'; +$xdvi_papersize{'b1r'}='100.0x70.6cm'; +$xdvi_papersize{'b2r'}='70.6x50.0cm'; +$xdvi_papersize{'b3r'}='50.0x35.3cm'; +$xdvi_papersize{'b4r'}='35.3x25.0cm'; +$xdvi_papersize{'b5r'}='25.0x17.6cm'; +$xdvi_papersize{'b6r'}='17.6x13.5cm'; +$xdvi_papersize{'b7r'}='13.5x8.8cm'; +$xdvi_papersize{'c1'}='64.8x91.6cm'; +$xdvi_papersize{'c2'}='45.8x64.8cm'; +$xdvi_papersize{'c3'}='32.4x45.8cm'; +$xdvi_papersize{'c4'}='22.9x32.4cm'; +$xdvi_papersize{'c5'}='16.2x22.9cm'; +$xdvi_papersize{'c6'}='11.46x16.2cm'; +$xdvi_papersize{'c7'}='8.1x11.46cm'; +$xdvi_papersize{'c1r'}='91.6x64.8cm'; +$xdvi_papersize{'c2r'}='64.8x45.8cm'; +$xdvi_papersize{'c3r'}='45.8x32.4cm'; +$xdvi_papersize{'c4r'}='32.4x22.9cm'; +$xdvi_papersize{'c5r'}='22.9x16.2cm'; +$xdvi_papersize{'c6r'}='16.2x11.46cm'; +$xdvi_papersize{'c7r'}='11.46x8.1cm'; + +my %dvipdfm_papersize = ( 'letter' => 1, 'legal' => 1, 'ledger' => 1, + 'tabloid' => 1, 'a4' => 1, 'a3' => 1 ); + +my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`; +chomp($texmfsysvar); +my $texmfsysconfig = `kpsewhich -var-value=TEXMFSYSCONFIG`; +chomp($texmfsysconfig); + +# we are doing -sys variants +$ENV{"TEXMFVAR"} = $texmfsysvar; +$ENV{"TEXMFCONFIG"} = $texmfsysconfig; + +my $what = shift; + +if (!$what) { + print "need an argument\n"; + exit 1; +} + +if ($what eq "dvips") { + do_dvips(); +} elsif ($what eq "dvipdfm") { + do_dvipdfm(); +} elsif ($what eq "xdvi") { + do_xdvi(); +} else { + print "Unknown what $what!\n"; + exit 1; +} +exit 0; + +sub do_dvips { + my $configps = `kpsewhich --progname=dvips --format='dvips config' config.ps`; + chomp($configps); + print "file used: $configps\n"; + + open(FOO, "<$configps") or die("cannot open file: $!"); + my @lines = <FOO>; + close(FOO); + + my @papersizes = map { +s/^@ (\w+) .*$/$1/; $_; } grep (m/^@ /, @lines); + + chomp(@papersizes); + + for (@papersizes) { print "...$_...\n"; } +} + +sub do_xdvi { + my $xdvi = `kpsewhich --progname=xdvi --format='other text files' XDvi`; + chomp($xdvi); + print "file used: $xdvi\n"; + + open(FOO, "<$xdvi") or die("cannot open file: $!"); + my @lines = <FOO>; + close(FOO); + + my @hit = map { +s/^\*paper:\s+(\w+)\s*$/$1/; $_; } grep (m/^\*paper: /,@lines); + my $hit; + if (!@hit) { + print "paper config not found\n"; + } else { + if ($#hit > 0) { + print "Strange, more than one paper definiton, using the first one!\n"; + } + $hit = $hit[0]; + } + chomp($hit); + + print "current xdvi paper size: $hit\n"; + + + + + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2 expandtab: # |