From 9ef0ad52f596026c1e545be621232e76cf2ef45a Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 28 Apr 2014 13:32:45 +0000 Subject: Update scripts from source tree git-svn-id: svn://tug.org/texlive/trunk@33721 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/psutils/extractres.pl | 170 ++++++----- Master/texmf-dist/scripts/psutils/fixdlsrps.pl | 54 ---- Master/texmf-dist/scripts/psutils/fixfmps.pl | 21 -- Master/texmf-dist/scripts/psutils/fixpsditps.pl | 25 -- Master/texmf-dist/scripts/psutils/fixpspps.pl | 58 ---- Master/texmf-dist/scripts/psutils/fixscribeps.pl | 19 -- Master/texmf-dist/scripts/psutils/fixtpps.pl | 28 -- Master/texmf-dist/scripts/psutils/fixwfwps.pl | 33 --- Master/texmf-dist/scripts/psutils/fixwpps.pl | 31 -- Master/texmf-dist/scripts/psutils/fixwwps.pl | 20 -- Master/texmf-dist/scripts/psutils/getafm.sh | 358 ----------------------- Master/texmf-dist/scripts/psutils/includeres.pl | 132 +++++++-- Master/texmf-dist/scripts/psutils/psmerge.pl | 86 ------ Master/texmf-dist/scripts/psutils/showchar.sh | 118 -------- Master/texmf-dist/scripts/xindy/texindy.pl | 52 +++- Master/texmf-dist/scripts/xindy/xindy.pl | 82 ++++-- 16 files changed, 299 insertions(+), 988 deletions(-) delete mode 100755 Master/texmf-dist/scripts/psutils/fixdlsrps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixfmps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixpsditps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixpspps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixscribeps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixtpps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixwfwps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixwpps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/fixwwps.pl delete mode 100755 Master/texmf-dist/scripts/psutils/getafm.sh delete mode 100755 Master/texmf-dist/scripts/psutils/psmerge.pl delete mode 100755 Master/texmf-dist/scripts/psutils/showchar.sh (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/scripts/psutils/extractres.pl b/Master/texmf-dist/scripts/psutils/extractres.pl index adee938c95d..87f8377b34d 100755 --- a/Master/texmf-dist/scripts/psutils/extractres.pl +++ b/Master/texmf-dist/scripts/psutils/extractres.pl @@ -1,101 +1,117 @@ #!/usr/bin/env perl # extractres: extract resources from PostScript file +# includeres: add resources to a PostScript file # -# Copyright (C) Angus J. C. Duggan 1991-1995 +# (c) Reuben Thomas 2012 +# (c) Angus J. C. Duggan 1991-1997 # See file LICENSE for details. -$0 =~ s=.*/==; -$prog = $0; +use strict; +use warnings; -%resources = (); # list of resources included -%merge = (); # list of resources extracted this time -%extn = ("font", ".pfa", "file", ".ps", "procset", ".ps", # resource extns - "pattern", ".pat", "form", ".frm", "encoding", ".enc"); -%type = ("%%BeginFile:", "file", "%%BeginProcSet:", "procset", - "%%BeginFont:", "font"); # resource types +use File::Basename; +use Getopt::Long; -while (@ARGV) { - $_ = shift; - if (/^-m(erge)?$/) { $merge = 1; } - elsif (/^-/) { - print STDERR "Usage: $prog [-merge] [file]\n"; - exit 1; - } else { - unshift(@ARGV, $_); - last; - } -} - -if (defined($ENV{TMPDIR})) { # set body file name - $body = "$ENV{TMPDIR}/body$$.ps"; -} elsif (defined($ENV{TEMP})) { - $body = "$ENV{TEMP}/body$$.ps"; -} elsif (defined($ENV{TMP})) { - $body = "$ENV{TMP}/body$$.ps"; -} else { - $body = "body$$.ps"; -} +my $prog = basename($0); -open(BODY, $body) && die "Temporary file $body already exists"; -open(BODY, ">$body") || die "Can't write file $body"; +# Resource extensions +my %extn = ("font" => ".pfa", "file" => ".ps", "procset" => ".ps", + "pattern" => ".pat", "form" => ".frm", "encoding" => ".enc"); +# Resource types +my %type = ("%%BeginFile:" => "file", "%%BeginProcSet:" => "procset", + "%%BeginFont:" => "font"); sub filename { # make filename for resource in @_ - local($name); - foreach (@_) { # sanitise name - s/[!()\$\#*&\\\|\`\'\"\~\{\}\[\]\<\>\?]//g; - $name .= $_; - } - $name =~ s@.*/@@; # drop directories - die "Filename not found for resource ", join(" ", @_), "\n" - if $name =~ /^$/; - $name; + my $name; + foreach (@_) { # sanitise name + s/[!()\$\#*&\\\|\`\'\"\~\{\}\[\]\<\>\?]//g; + $name .= $_; + } + $name =~ s@.*/@@; # drop directories + die "$prog: filename not found for resource ", join(" ", @_), "\n" + if $name =~ /^$/; + return $name; } -$output = STDOUT; # start writing header out -while (<>) { - if (/^%%BeginResource:/ || /^%%BeginFont:/ || /^%%BeginProcSet:/) { - local($comment, @res) = split(/\s+/); # look at resource type - local($type) = defined($type{$comment}) ? $type{$comment} : shift(@res); - local($name) = &filename(@res, $extn{$type}); # make file name +sub extract { + my %resources = (); # list of resources included + my %merge = (); # list of resources extracted this time + + my $merge; + unless (GetOptions('merge' => \$merge)) { + print STDERR "Usage: $prog [-merge] [FILE]\n"; + exit 1; + } + + my $prolog = ""; + my $body = ""; + my $resource = ""; + my $output = \$prolog; + my $saveout; + while (<>) { + if (/^%%BeginResource:/ || /^%%BeginFont:/ || /^%%BeginProcSet:/) { + my ($comment, @res) = split(/\s+/); # look at resource type + my $type = defined($type{$comment}) ? $type{$comment} : shift(@res); + my $name = filename(@res, $extn{$type}); # make file name $saveout = $output; - if (!$resources{$name}) { - print "%%IncludeResource: $type ", join(" ", @res), "\n"; - if (!open(RES, $name)) { - open(RES, ">$name") || die "Can't write file $name"; - $resources{$name} = $name; - $merge{$name} = $merge; - $output = RES; - } else { # resource already exists - close(RES); - undef $output; - } + if (!defined($resources{$name})) { + $prolog .= "%%IncludeResource: $type " . join(" ", @res) . "\n"; + if (!-e $name) { + open RES, ">$name" || die "$prog: can't write file `$name'\n"; + $resources{$name} = ""; + $merge{$name} = $merge; + $output = \$resources{$name}; + } else { # resource already exists + close(RES); + undef $output; + } } elsif ($merge{$name}) { - open(RES, ">>$name") || die "Can't append to file $name"; - $output = RES; + open RES, ">>$name" || die "$prog: can't append to file `$name'\n"; + $resources{$name} = ""; + $output = \$resources{$name}; } else { # resource already included - undef $output; + undef $output; } - } elsif (/^%%EndResource/ || /^%%EndFont/ || /^%%EndProcSet/) { + } elsif (/^%%EndResource/ || /^%%EndFont/ || /^%%EndProcSet/) { if (defined $output) { - print $output $_; - close($output); + $$output .= $_; + print RES $$output; } $output = $saveout; next; - } elsif ((/^%%EndProlog/ || /^%%BeginSetup/ || /^%%Page:/)) { - $output = BODY; - } - print $output $_ - if defined $output; -} - -close(BODY); # close body output file + } elsif ((/^%%EndProlog/ || /^%%BeginSetup/ || /^%%Page:/)) { + $output = \$body; + } + $$output .= $_ if defined $output; + } -open(BODY, $body); # reopen body for input -while () { # print it all - print $_; + print $prolog . $body; } -close(BODY); -unlink($body); # dispose of body file +sub include { + while (<>) { + if (/^%%IncludeResource:/ || /^%%IncludeFont:/ || /^%%IncludeProcSet:/) { + my ($comment, @res) = split(/\s+/); + my $type = defined($type{$comment}) ? $type{$comment} : shift(@res); + my $name = filename(@res); + if (open(RES, $name) || open(RES, "$name$extn{$type}")) { + print do { local $/; }; + close(RES); + } else { + print "%%IncludeResource: ", join(" ", $type, @res), "\n"; + print STDERR "$prog: resource `$name' not found\n"; + } + } else { + print $_; + } + } +} +# Perform function according to name +if ($prog eq "extractres") { + extract(); +} elsif ($prog eq "includeres") { + include(); +} else { + die "$prog: I need to be called `extractres' or `includeres'\n"; +} diff --git a/Master/texmf-dist/scripts/psutils/fixdlsrps.pl b/Master/texmf-dist/scripts/psutils/fixdlsrps.pl deleted file mode 100755 index 2a1d85a654c..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixdlsrps.pl +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env perl -# fixdlsrps: fix DviLaser/PS document to work with PSUtils -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$nesting = 0; -$page = 1; -$infont = 0; - -@fonts = (); -@body = (); -$header = 1; - -while (<>) { - if (/^XP/) { - $infont++; - push(@fonts, $_); - $infont-- if /PXL.*RP/ || /DN?F.*RP/; - } elsif ($infont) { - push(@fonts, $_); - $infont-- if /PXL.*RP/ || /DN?F.*RP/; - } elsif ((/^%%EndSetup/ || /^%%Page:/) && $header) { - print @body; - @body = ("%%EndSetup\n"); - $header = 0; - } elsif (/^%%EndProlog/ && !$nesting) { - push(@body, - "\$DviLaser begin/GlobalMode{}bdef/LocalMode{}bdef/XP{}def/RP{}def", - "/DoInitialScaling{72.0 Resolution div dup scale}bdef end\n", $_); - } elsif (/^%%BeginPageSetup/ && !$nesting) { - push(@body, "%%Page: $page $page\n", $_, - "Resolution 72 div dup scale Magnification 1000 div dup scale\n", - "/DocumentInitState where {\n", - "/DocumentInitState [ matrix currentmatrix currentlinewidth", - " currentlinecap currentlinejoin currentdash currentgray", - " currentmiterlimit] cvx put}if\n"); - $page++; - } elsif (/^%%BeginDocument:/ || /^%%BeginBinary:/ || /^%%BeginFile:/) { - push(@body, $_); - $nesting++; - } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) { - push(@body, $_); - $nesting--; - } elsif (!/^%%PageBoundingBox:/ && !/^%%Page:/) { - push(@body, $_); - } -} - -print @fonts; -print @body; - -exit 0; - diff --git a/Master/texmf-dist/scripts/psutils/fixfmps.pl b/Master/texmf-dist/scripts/psutils/fixfmps.pl deleted file mode 100755 index 039ac8e5a3e..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixfmps.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env perl -# fixfmps: get conforming PostScript out of FrameMaker version 2 file -# move all FMDEFINEFONTs to start of pages -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -%fonts=(); - -while (<>) { - if (/^([0-9]+) [0-9]+ .* FMDEFINEFONT$/) { - $fonts{$1} = $_; - } elsif (/^[0-9.]+ [0-9.]+ [0-9]+ FMBEGINPAGE$/) { - print $_, join('',values(%fonts)); - } elsif (m%(.*/PageSize \[paperwidth paperheight\]put )setpagedevice(.*)%) { - print "$1pop$2\n"; - } else { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixpsditps.pl b/Master/texmf-dist/scripts/psutils/fixpsditps.pl deleted file mode 100755 index 2a1728a8204..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixpsditps.pl +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env perl -# fixpsditps: fix psdit output for use in psutils -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$nesting = 0; - -while (<>) { - if (/^\/p{pop showpage pagesave restore \/pagesave save def}def$/) { - print "/p{pop showpage pagesave restore}def\n"; - } elsif (/^%%BeginDocument/ || /^%%BeginBinary/ || /^%%BeginFile/ ) { - print $_; - $nesting++; - } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) { - print $_; - $nesting--; - } elsif (/^%%Page:/ && $nesting == 0) { - print $_; - print "xi\n"; - } elsif (! /^xi$/) { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixpspps.pl b/Master/texmf-dist/scripts/psutils/fixpspps.pl deleted file mode 100755 index 77bba66d6b7..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixpspps.pl +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env perl -# mangle PostScript produced by PSPrint to make it almost conforming -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$header = 1; $ignore = 0; -$verbose = 0; -@body = (); -%fonts = (); $font = ""; -$inchar = 0; @char = (); - -while (<>) { - if (/^\@end$/) { - $ignore = 1; - } elsif (/^[0-9]+ \@bop0$/) { - $ignore = 0; - $header = 1; - } elsif ($header) { - if (/^\/([a-z.0-9]+) \@newfont$/) { - if (! defined($fonts{$1})) { - $fonts{$1} = 1; - print; - } elsif ($verbose) { - print STDERR "$font already defined\n"; - } - } elsif (/^([a-z.0-9]+) sf$/) { - $font = $1; - print; - } elsif (/^\[) { - if (/^([0-9]+ [0-9]+ [0-9]+ PB) (%!.*)/) { - print "$1\n%%BeginDocument: Scribe-EPSF $epsfn 0\n$2\n"; - $inepsf++; - } elsif (/^ PE/ && $inepsf) { - print "%%EndDocument\n", $_; - } else { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixtpps.pl b/Master/texmf-dist/scripts/psutils/fixtpps.pl deleted file mode 100755 index 4239bb9dfc5..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixtpps.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env perl -# fixtpps: fix tpscript document to work with PSUtils -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$nesting = 0; -$header = 1; - -while (<>) { - if (/^%%Page:/ && $nesting == 0) { - print $_; - print "save home\n"; - $header = 0; - } elsif (/^%%BeginDocument/ || /^%%BeginBinary/ || /^%%BeginFile/) { - print $_; - $nesting++; - } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) { - print $_; - $nesting--; - } elsif (/save home/) { - s/save home//; - print $_; - } elsif (!$header || (! /^save$/ && ! /^home$/)) { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixwfwps.pl b/Master/texmf-dist/scripts/psutils/fixwfwps.pl deleted file mode 100755 index 92d88443fe1..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixwfwps.pl +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env perl -# fixwfwps: fix Word for windows PostScript for printing. -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$nesting = 0; -while (<>) { - tr/\000-\010\012-\014\016-\037//d; - foreach (grep($_ ne "", split("\015"))) { - s!/SVDoc\s+save\s+def!!g; - s!SVDoc\s+restore!!g; - if (/^(%!PS-Adobe-\d*\.\d*) EPSF-/ && !$nesting) { - print "$1\n"; - $wfwepsf = 1; - } elsif (/^SS\s*$/ && $wfwepsf) { - print "%%Page: $wfwepsf $wfwepsf\n"; - $wfwepsf++; - print "$_\n"; - } elsif (/^%MSEPS Preamble/) { - print "%%BeginDocument: (Included EPSF)\n"; - print "$_\n"; - $nesting++; - } elsif (/^%MSEPS Trailer/) { - $nesting--; - print "$_\n"; - print "%%EndDocument\n"; - } elsif (! /^%%BoundingBox/) { - print "$_\n"; - } - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixwpps.pl b/Master/texmf-dist/scripts/psutils/fixwpps.pl deleted file mode 100755 index 83a5fdfaf0b..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixwpps.pl +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env perl -# fixwpps: get semi-conforming PostScript out of WordPerfect 5.0 file -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$page = 1; -$nesting = 0; - -while (<>) { - s/([^\/]_t)([0-9]+)/\1 \2/g; # fix wp 5.0 bug - if (m!/_[be][dp]! || m!_bp \d+ \d+ roll!) { - print $_; - } elsif (/^(.*)(_bp.*)$/) { - print "$1\n" if $1 ne ""; - print "%%Page: $page $page\n"; - print "$2\n"; - $page++; - $nesting++; - } elsif (/_ep$/) { - print $_; - $nesting--; - } elsif (/^(.*)(_ed.*)/) { - print "$1\n" if $1 ne ""; - print "%%Trailer:\n"; - print "$2\n"; - } else { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/fixwwps.pl b/Master/texmf-dist/scripts/psutils/fixwwps.pl deleted file mode 100755 index bfd58c086da..00000000000 --- a/Master/texmf-dist/scripts/psutils/fixwwps.pl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env perl -# fixwwps: get semi-conforming PostScript out of Windows Write file -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$page = 1; - -while (<>) { - if (/^(%!.*) EPSF-\d.\d/) { - print $1, "\n"; - } elsif (/^SS/) { - print "%%Page: $page $page\n"; - print $_; - $page++; - } else { - print $_; - } -} - diff --git a/Master/texmf-dist/scripts/psutils/getafm.sh b/Master/texmf-dist/scripts/psutils/getafm.sh deleted file mode 100755 index 1c6cd21cf77..00000000000 --- a/Master/texmf-dist/scripts/psutils/getafm.sh +++ /dev/null @@ -1,358 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ]; then - echo "usage: $0 font-name | gsnd - >font-name.afm" >&2 - exit 1 -fi - -cat << EOF -%! -% produce .afm for $1 -% (c) 1993 by Robert Joop -% inspired by two other versions of this theme which are -% getafm 1.00 (c) AJCD -% and getafm.ps by an unknown author, -% modified by J. Daniel Smith - -% Metrics dictionary code added by AJCD, 7/6/93 - -/getafmdict 100 dict dup begin - - /buf 256 string def - /buf2 16 string def - - /prany % dict dictname printname -> dict - { - 2 index 2 index cvn known - { - print % printname - ( ) print - 1 index exch cvn get = - } - { - (Comment /FontInfo contains no /) print - 2 copy eq - { - = % printname - pop % dictname - } - { - exch - print % dictname - (, therefore no ) print - = % printname - } - ifelse - } - ifelse - } - bind def - - /printfontname - { - (FontName)dup prany - } - bind def - - /printfontinfo - { - dup /FontInfo known - { - dup /FontInfo get - (FullName)dup prany - (FamilyName)dup prany - (Weight)dup prany - (ItalicAngle)dup prany - (isFixedPitch)(IsFixedPitch) prany - (UnderlinePosition)dup prany - (UnderlineThickness)dup prany - (Version)(version) prany - (Notice)dup prany - pop - } - { - (Comment Font lacks a /FontInfo!)= - } - ifelse - } - bind def - - /prbbox % llx lly urx ury -> - - { - 4 1 roll 3 1 roll exch % swap top 4 elements - 4 { ( ) print buf cvs print } repeat - } - bind def - - /getbbox % fontdict chardict character -> fontdict chardict llx lly urx ury - { - gsave - 2 index setfont 0 0 moveto - false charpath flattenpath pathbbox - grestore - } - bind def - - /printmiscinfo - { - dup /FontBBox known - { - (FontBBox) print - dup /FontBBox get aload pop prbbox ()= - } - { - (Comment missing required /FontBBox)= - quit - } - ifelse - 2 copy exch get - dup /H known - 1 index /x known and - 1 index /d known and - 1 index /p known and - dup /looksRoman exch def - { - (CapHeight ) print - (H) getbbox - ceiling cvi = pop pop pop - (XHeight ) print - (x) getbbox - ceiling cvi = pop pop pop - (Ascender ) print - (d) getbbox - ceiling cvi = pop pop pop - (Descender ) print - (p) getbbox - pop pop floor cvi = pop - } - { - (Comment font doesn't contain H, x, d and p; therefore no CapHeight, XHeight, Ascender and Descender)= - } - ifelse - pop - dup /Encoding get - [ - [ (ISOLatin1Encoding) /ISOLatin1Encoding ] - [ (AdobeStandardEncoding) /StandardEncoding ] - ] - { - aload pop dup where - { - exch get 2 index eq - { - (EncodingScheme ) print - buf cvs = - } - { - pop - } - ifelse - } - { - pop pop - } - ifelse - } - forall - pop - } - bind def - - /printcharmetric - { - % chardictname fontdict charnamedict encoding charindex charname - - 4 index dup length dict dup begin exch - { - 1 index /FID ne - 2 index /UniqueID ne - and - { - 1 index /Encoding eq { 256 array copy } if - def - } - { pop pop } - ifelse - } - forall - end - dup /Encoding get 32 3 index put - /f2 exch definefont - setfont - - (C ) print - 1 index buf cvs print - - ( ; WX ) print -% Metrics entries are: -% 1 number: which is the character width -% an array of 2 numbers: which are the left sidebearing and width -% an array of 4 numbers: x & y left sidebearing, width and height - dup 5 index % /charname fontdict - dup /Metrics known { - /Metrics get exch 2 copy known { - get dup type /arraytype eq { - dup length 2 eq - {1 get} {2 get} ifelse - } if - round cvi buf cvs print - } { - pop pop ( ) stringwidth pop round cvi buf cvs print - } ifelse - } { - pop pop ( ) stringwidth pop round cvi buf cvs print - } ifelse - - ( ; N ) print - dup buf cvs print - - ( ; B) print - gsave - newpath 0 0 moveto - ( ) true charpath flattenpath pathbbox - grestore - 2 { ceiling cvi 4 1 roll } repeat - 2 { floor cvi 4 1 roll } repeat - prbbox - - looksRoman - { - [ - [ /f [ /i /f /l ] ] - [ /ff [ /i /l ] ] - ] - { - aload pop 1 index 3 index eq - { - { - 1 index buf cvs - length - 1 index buf2 cvs dup length - 2 index add - buf - 4 2 roll putinterval - buf 0 - 3 -1 roll getinterval - dup cvn - 7 index - exch known - { - exch - ( ; L ) print - buf2 cvs print - ( ) print - print - } - { - pop pop - } - ifelse - } - forall - pop - } - { - pop pop - } - ifelse - } - forall - } - if - pop - - ( ;)= - } - bind def - - /printcharmetrics - { - (StartCharMetrics ) print - 2 copy exch get length 1 sub buf cvs = - - 256 dict dup begin - 1 index /Encoding get - { null def } - forall - end - % chardictname fontdict charnamedict - 1 index /Encoding get - 0 1 255 - { - % encoding index - 2 copy get - dup /.notdef eq { pop } { printcharmetric } ifelse - pop % index - } for - - -1 - 3 index 5 index get - { - pop - dup /.notdef eq - { pop } - { - % chardictname fontdict charnamedict encoding charindex charname - dup 4 index exch known - { pop } - { printcharmetric } - ifelse - } - ifelse - } - forall - % charnamedict encoding index - pop pop pop - - (EndCharMetrics)= - } - bind def - - /printfontmetrics - { - (StartFontMetrics 3.0)= - (Comment Produced by getafm 3.0 (which is by rj@rainbow.in-berlin.de))= - - printfontname - printfontinfo - printmiscinfo - printcharmetrics - - (EndFontMetrics)= - } - bind def - -end def - -/getafm -{ - getafmdict begin - save exch - findfont 1000 scalefont - - null - [ /CharDefs /CharData /CharProcs /CharStrings ] - { - 2 index 1 index known { exch } if - pop - } - forall - dup null eq - { - (can't find dictionary with character data!)= - quit - } - if - exch % dictname fontdict - - printfontmetrics - - pop pop - restore - end -} -bind def - -/$1 getafm - -EOF diff --git a/Master/texmf-dist/scripts/psutils/includeres.pl b/Master/texmf-dist/scripts/psutils/includeres.pl index c9d0eee61cb..87f8377b34d 100755 --- a/Master/texmf-dist/scripts/psutils/includeres.pl +++ b/Master/texmf-dist/scripts/psutils/includeres.pl @@ -1,45 +1,117 @@ #!/usr/bin/env perl -# includeres: include resources in PostScript file +# extractres: extract resources from PostScript file +# includeres: add resources to a PostScript file # -# Copyright (C) Angus J. C. Duggan 1991-1995 +# (c) Reuben Thomas 2012 +# (c) Angus J. C. Duggan 1991-1997 # See file LICENSE for details. -$0 =~ s=.*/==; -$prog = $0; +use strict; +use warnings; -%extn = ("font", ".pfa", "file", ".ps", "procset", ".ps", # resource extns - "pattern", ".pat", "form", ".frm", "encoding", ".enc"); -%type = ("%%BeginFile:", "file", "%%BeginProcSet:", "procset", - "%%BeginFont:", "font"); # resource types +use File::Basename; +use Getopt::Long; + +my $prog = basename($0); + +# Resource extensions +my %extn = ("font" => ".pfa", "file" => ".ps", "procset" => ".ps", + "pattern" => ".pat", "form" => ".frm", "encoding" => ".enc"); +# Resource types +my %type = ("%%BeginFile:" => "file", "%%BeginProcSet:" => "procset", + "%%BeginFont:" => "font"); sub filename { # make filename for resource in @_ - local($name); - foreach (@_) { # sanitise name - s/[!()\$\#*&\\\|\`\'\"\~\{\}\[\]\<\>\?]//g; - $name .= $_; - } - $name =~ s@.*/@@; # drop directories - die "Filename not found for resource ", join(" ", @_), "\n" - if $name =~ /^$/; - $name; + my $name; + foreach (@_) { # sanitise name + s/[!()\$\#*&\\\|\`\'\"\~\{\}\[\]\<\>\?]//g; + $name .= $_; + } + $name =~ s@.*/@@; # drop directories + die "$prog: filename not found for resource ", join(" ", @_), "\n" + if $name =~ /^$/; + return $name; +} + +sub extract { + my %resources = (); # list of resources included + my %merge = (); # list of resources extracted this time + + my $merge; + unless (GetOptions('merge' => \$merge)) { + print STDERR "Usage: $prog [-merge] [FILE]\n"; + exit 1; + } + + my $prolog = ""; + my $body = ""; + my $resource = ""; + my $output = \$prolog; + my $saveout; + while (<>) { + if (/^%%BeginResource:/ || /^%%BeginFont:/ || /^%%BeginProcSet:/) { + my ($comment, @res) = split(/\s+/); # look at resource type + my $type = defined($type{$comment}) ? $type{$comment} : shift(@res); + my $name = filename(@res, $extn{$type}); # make file name + $saveout = $output; + if (!defined($resources{$name})) { + $prolog .= "%%IncludeResource: $type " . join(" ", @res) . "\n"; + if (!-e $name) { + open RES, ">$name" || die "$prog: can't write file `$name'\n"; + $resources{$name} = ""; + $merge{$name} = $merge; + $output = \$resources{$name}; + } else { # resource already exists + close(RES); + undef $output; + } + } elsif ($merge{$name}) { + open RES, ">>$name" || die "$prog: can't append to file `$name'\n"; + $resources{$name} = ""; + $output = \$resources{$name}; + } else { # resource already included + undef $output; + } + } elsif (/^%%EndResource/ || /^%%EndFont/ || /^%%EndProcSet/) { + if (defined $output) { + $$output .= $_; + print RES $$output; + } + $output = $saveout; + next; + } elsif ((/^%%EndProlog/ || /^%%BeginSetup/ || /^%%Page:/)) { + $output = \$body; + } + $$output .= $_ if defined $output; + } + + print $prolog . $body; } -while (<>) { - if (/^%%IncludeResource:/ || /^%%IncludeFont:/ || /^%%IncludeProcSet:/) { - local($comment, @res) = split(/\s+/); - local($type) = defined($type{$comment}) ? $type{$comment} : shift(@res); - local($name) = &filename(@res); +sub include { + while (<>) { + if (/^%%IncludeResource:/ || /^%%IncludeFont:/ || /^%%IncludeProcSet:/) { + my ($comment, @res) = split(/\s+/); + my $type = defined($type{$comment}) ? $type{$comment} : shift(@res); + my $name = filename(@res); if (open(RES, $name) || open(RES, "$name$extn{$type}")) { - while () { - print $_; - } - close(RES); + print do { local $/; }; + close(RES); } else { - print "%%IncludeResource: ", join(" ", $type, @res), "\n"; - print STDERR "Resource $name not found\n"; + print "%%IncludeResource: ", join(" ", $type, @res), "\n"; + print STDERR "$prog: resource `$name' not found\n"; } - } else { + } else { print $_; - } + } + } } +# Perform function according to name +if ($prog eq "extractres") { + extract(); +} elsif ($prog eq "includeres") { + include(); +} else { + die "$prog: I need to be called `extractres' or `includeres'\n"; +} diff --git a/Master/texmf-dist/scripts/psutils/psmerge.pl b/Master/texmf-dist/scripts/psutils/psmerge.pl deleted file mode 100755 index ff1b8039b4d..00000000000 --- a/Master/texmf-dist/scripts/psutils/psmerge.pl +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env perl -# psmerge: merge PostScript files produced by same application and setup -# usage: psmerge [-oout.ps] [-thorough] file1.ps file2.ps ... -# -# Copyright (C) Angus J. C. Duggan 1991-1995 -# See file LICENSE for details. - -$0 =~ s=.*/==; -$prog = $0; - -while ($ARGV[0] =~ /^-/) { - $_ = shift; - if (/^-o(.+)/) { - if (!close(STDOUT) || !open(STDOUT, ">$1")) { - print STDERR "$prog: can't open $1 for output\n"; - exit 1; - } - } elsif (/^-t(horough)?$/) { - $thorough = 1; - } else { - print STDERR "Usage: $prog [-oout] [-thorough] file...\n"; - exit 1; - } -} - -$page = 0; -$first = 1; -$nesting = 0; - -@header = (); -$header = 1; - -@trailer = (); -$trailer = 0; - -@pages = (); -@body = (); - -@resources = (); -$inresource = 0; - -while (<>) { - if (/^%%BeginFont:/ || /^%%BeginResource:/ || /^%%BeginProcSet:/) { - $inresource = 1; - push(@resources, $_); - } elsif ($inresource) { - push(@resources, $_); - $inresource = 0 if /^%%EndFont/ || /^%%EndResource/ || /^%%EndProcSet/; - } elsif (/^%%Page:/ && $nesting == 0) { - $header = $trailer = 0; - push(@pages, join("", @body)) if @body; - $page++; - @body = ("%%Page: ($page) $page\n"); - } elsif (/^%%Trailer/ && $nesting == 0) { - push(@trailer, $_); - push(@pages, join("", @body)) if @body; - @body = (); - $trailer = 1; - $header = 0; - } elsif ($header) { - push(@trailer, $_); - push(@pages, join("", @body)) if @body; - @body = (); - $trailer = 1; - $header = 0; - } elsif ($trailer) { - if (/^%!/ || /%%EOF/) { - $trailer = $first = 0; - } elsif ($first) { - push(@trailer, $_); - } - } elsif (/^%%BeginDocument/ || /^%%BeginBinary/ || /^%%BeginFile/) { - push(@body, $_); - $nesting++; - } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) { - push(@body, $_); - $nesting--; - } else { - print $_ if $print; - } -} - -print @trailer; - -exit 0; - diff --git a/Master/texmf-dist/scripts/psutils/showchar.sh b/Master/texmf-dist/scripts/psutils/showchar.sh deleted file mode 100755 index e685e99ae8c..00000000000 --- a/Master/texmf-dist/scripts/psutils/showchar.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh -# showchar: show character with information -# usage: -# showchar Font-Name Char-Name | lpr -Pprinter - -if [ $# != 2 ]; then - echo "Usage: `basename $0` Font-Name Char-Name" >&2 - exit 1 -fi - -cat < When you use these +LaTeX engines, you must use B instead. + A good introductionary description of B appears in the indexing chapter of the LaTeX Companion (2nd ed.) @@ -49,9 +52,7 @@ markup, the command xindy(1) is probably more of interest for you. B is an approach to merge support for the I framework, own xindy modules (e.g., for special LaTeX commands in the -index), and a reasonable level of MakeIndex compatibility. There are -other older approaches, eventually they will get a description on the -xindy Web Site, http://www.xindy.org/. +index), and a reasonable level of MakeIndex compatibility. =head1 OPTIONS @@ -110,9 +111,18 @@ encoding, in that order. =item C<--codepage> I / B <-C> I -The raw input is in input encoding I. This information is used to -select the correct xindy sort module and also the I target -encoding for C input markup. +B's raw input is always assumed to be encoded in LaTeX +Internal Character Representation (LICR). I.e., non-ASCII characters +are encoded as command sequences. This option tells xindy the encoding +it shall use internally for sorting. + +Effectively, you need this option to specify the encoding of letter +group headings. + +Encoding C is only supported for Latin alphabets. But if you use +non-Latin alphabets, you probably use XeLaTeX or LuaLaTeX and then you +must not use B anyhow. Then direct usage of B is +appropriate. When C input markup is used, C is always used as the sort codepage and no inputenc module is loaded. Then this option is @@ -292,6 +302,22 @@ should please contact the author. =item * +If you have an index rage and a location attribute, e.g., +C<\index{key\(attr}> starts the range, one needs (1) to specify that +attribute in the range closing entry as well (i.e., as +C<\index{key\)attr}>) and (2) one needs to declare the index attribute +in an B style file. + +MakeIndex will output the markup C<\attr{page1--page2}> for such a +construct. This is not possible to achieve in B, output will be +C<\attrMarkup{page1}--\attrMarkup{page2}>. (This is actually +considered a bug, but not a high priority one.) + +The difference between MakeIndex page number tags and B +location attributes was already explained in the previous item. + +=item * + The MakeIndex compatibility definitions support only the default raw index syntax and markup definition. It is not possible to configure raw index parsing or use a MakeIndex style file to describe output @@ -340,7 +366,7 @@ GNU General Public License for more details. use strict; use English qw(-no_match_vars); -our $VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /: (\d+)\.(\d+)/ ; +our $VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /: (\d+)\.(\d+)/ ; # Used modules. @@ -410,7 +436,8 @@ sub usage ( ;$ ) { my $exit_code = shift; $exit_code += 0; # turn undef into 0 - print STDERR <<_EOT_ + my $out = ( $exit_code ? *STDERR : *STDOUT ); + print $out <<_EOT_ usage: $cmd [-V?h] [-qv] [-iglr] [-d magic] [-o outfile.ind] [-t log] \\ [-L lang] [-C codepage] [-M module] [-I input] [idx0 idx1 ...] @@ -598,6 +625,13 @@ sub output_xindy_release () { #====================================================================== # # $Log: texindy,v $ +# Revision 1.13 2011/01/18 22:18:29 jschrod +# Document the range raw markup incompatibility with MakeIndex. +# (Bug ticket 998541) +# +# Revision 1.12 2010/08/12 00:16:01 jschrod +# Output help message on stdout if there's no error. +# # Revision 1.11 2010/05/10 23:39:24 jschrod # Incorporate TeX-Live patches from Vladimir Volovich and Peter # Breitenlohner: Support for TL installation scheme, support for Mac OS diff --git a/Master/texmf-dist/scripts/xindy/xindy.pl b/Master/texmf-dist/scripts/xindy/xindy.pl index a1fecf65a29..80eaafe6d59 100755 --- a/Master/texmf-dist/scripts/xindy/xindy.pl +++ b/Master/texmf-dist/scripts/xindy/xindy.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# $Id: xindy.pl,v 1.16 2010/05/10 23:39:24 jschrod Exp $ +# $Id: xindy.pl,v 1.18 2011/01/18 22:18:29 jschrod Exp $ #------------------------------------------------------------ # (history at end) @@ -99,9 +99,12 @@ The index is sorted according to the rules of language I. These rules are encoded in a xindy module created by I. If no input encoding is specified via C<--codepage>, a xindy module -for that language is searched with a latin, a cp, an iso, or ascii +for that language is searched with a latin, a cp, an iso, ascii, or utf8 encoding, in that order. +Language modules are either placed in the F or in the +F sub-directory of the modules base directory. + =item C<--codepage> I / B<-C> I The raw input is in input encoding I. This information is used to @@ -266,6 +269,22 @@ should please contact the author. =item * +If you have an index rage and a location attribute, e.g., +C<\index{key\(attr}> starts the range, one needs (1) to specify that +attribute in the range closing entry as well (i.e., as +C<\index{key\)attr}>) and (2) one needs to declare the index attribute +in an B style file. + +MakeIndex will output the markup C<\attr{page1--page2}> for such a +construct. This is not possible to achieve in B, output will be +C<\attrMarkup{page1}--\attrMarkup{page2}>. (This is actually +considered a bug, but not a high priority one.) + +The difference between MakeIndex page number tags and B +location attributes was already explained in the previous item. + +=item * + The MakeIndex compatibility definitions support only the default raw index syntax and markup definition. It is not possible to configure raw index parsing or use a MakeIndex style file to describe output @@ -322,7 +341,7 @@ GNU General Public License for more details. use strict; use English qw(-no_match_vars); -our $VERSION = sprintf "%d.%02d", q$Revision: 1.16 $ =~ /: (\d+)\.(\d+)/ ; +our $VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /: (\d+)\.(\d+)/ ; # Used modules. @@ -370,25 +389,31 @@ $TMPDIR = "."; # FIXME: In standalone installations, modules are still placed in lib # directory. This is not conformant to FHS. -if ( $is_TL ) { # TeX Live +if ( $is_TL ) { # TeX Live and MikTeX $modules_dir = Cwd::realpath("$cmd_dir/../../xindy/modules"); die "$cmd: Cannot locate xindy modules directory" unless -d $modules_dir; if ( $is_w32 ) { - $cmd_dir = "$cmd_dir/../../../bin/win32"; + if ( -d "$cmd_dir/../../../bin/win32" ) { # TeX Live + $cmd_dir = "$cmd_dir/../../../bin/win32"; + } elsif ( -d "$cmd_dir/../../miktex/bin" ) { # MikTeX + $cmd_dir = "$cmd_dir/../../miktex/bin"; + } else { + die "$cmd: Cannot locate bin directory"; + } } else { die "$cmd: not a symlink as required for TeX Live" unless -l $0; # Follow symlinks and determine $cmd_dir such that # $cmd_dir/xindy -> $r0 = XINDY_SCRIPTDIR/xindy.pl - # - # FIXME: What's this code good for? Cwd::realpath() already - # resolves all symbolic links; this just recomputes that - # information manually! It's from Peter, check with him. + # I.e., it determines the directory with the last symbolic link; the + # one that points to a real file. That's the directory with the binary + # files (Lisp executable and memory file). $real_cmd = $0; while (-l $real_cmd) { $cmd_dir = dirname($real_cmd); $real_cmd = readlink($real_cmd); + # \ directory separator may happen on Cygwin. $real_cmd = "$cmd_dir/$real_cmd" unless $real_cmd =~ m,^[\\/],; # relative link } } @@ -438,7 +463,8 @@ sub usage ( ;$ ) { my $exit_code = shift; $exit_code += 0; # turn undef into 0 - print STDERR <<_EOT_ + my $out = ( $exit_code ? *STDERR : *STDOUT ); + print $out <<_EOT_ usage: $cmd [-V?h] [-qv] [-d magic] [-o outfile.ind] [-t log] \\ [-L lang] [-C codepage] [-M module] [-I input] \\ @@ -702,8 +728,6 @@ sub xindy_expression () { # FIXME: I didn't see all languages. What's on with gypsy and # hausa? if ( $language ) { - my $ld = "$modules_dir/lang"; - my $variant; # If there is no language directory, this might be a variant. # Language names and variants are separated by hyphens. The # variant name "din" is an abbreviation for "din5007". The @@ -711,20 +735,29 @@ sub xindy_expression () { # name. # # FIXME: Or is "iso" the variant "translit"?! - if ( ! -d "$ld/$language" ) { - $language =~ /^([^-]*)-(.*)/ ; # language name ends with 1st hyphen - if ( $2 && -d "$ld/$1" ) { # $2 is not set if the regex didn't match - $language = $1; - $variant = "$2-" unless ( $2 eq 'iso' ); - $variant eq 'din-' and $variant = 'din5007-'; + my @lang_base_dirs = ("$modules_dir/contrib/lang", "$modules_dir/lang"); + my ($lang_dir, $variant); + foreach my $ld ( @lang_base_dirs ) { + if ( -d "$ld/$language" ) { + $lang_dir = "$ld/$language"; + last; + } else { + $language =~ /^([^-]*)-(.*)/ ; # language name ends with 1st hyphen + if ( $2 && -d "$ld/$1" ) { # $2 is not set if the regex didn't match + $language = $1; + $lang_dir = "$ld/$language"; + $variant = "$2-" unless ( $2 eq 'iso' ); + $variant eq 'din-' and $variant = 'din5007-'; + last; + } } } # Let's guess the codepage. We take any that starts with - # "latin", "cp", "iso8859", or "ascii". - @codepages = qw(latin cp iso8859 ascii) unless @codepages; + # "latin", "cp", "iso8859", "ascii", or "utf8". + @codepages = qw(latin cp iso8859 ascii utf8) unless @codepages; my @styles; foreach my $cp ( @codepages ) { - @styles = glob("$ld/$language/$variant$cp*-lang.xdy"); + @styles = glob("$lang_dir/$variant$cp*-lang.xdy"); last if @styles; } unless ( @styles ) { @@ -867,6 +900,13 @@ sub quotify ( $ ) { #====================================================================== # # $Log: xindy.pl,v $ +# Revision 1.18 2011/01/18 22:18:29 jschrod +# Document the range raw markup incompatibility with MakeIndex. +# (Bug ticket 998541) +# +# Revision 1.17 2010/08/12 00:16:01 jschrod +# Output help message on stdout if there's no error. +# # Revision 1.16 2010/05/10 23:39:24 jschrod # Incorporate TeX-Live patches from Vladimir Volovich and Peter # Breitenlohner: Support for TL installation scheme, support for Mac OS -- cgit v1.2.3