diff options
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/tests/TeXLive/TLUtils.pm | 159 | ||||
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/uptex/convbkmk.rb | 115 | ||||
-rw-r--r-- | Build/source/texk/texlive/tl_scripts/fmtutil.cnf | 8 | ||||
-rw-r--r-- | Build/source/utils/biber/TeXLive/TLUtils.pm | 159 |
4 files changed, 315 insertions, 126 deletions
diff --git a/Build/source/texk/tests/TeXLive/TLUtils.pm b/Build/source/texk/tests/TeXLive/TLUtils.pm index fdcd482f5ba..fdc594d2c2c 100644 --- a/Build/source/texk/tests/TeXLive/TLUtils.pm +++ b/Build/source/texk/tests/TeXLive/TLUtils.pm @@ -5,7 +5,7 @@ package TeXLive::TLUtils; -my $svnrev = '$Revision: 30127 $'; +my $svnrev = '$Revision: 30367 $'; my $_modulerevision; if ($svnrev =~ m/: ([0-9]+) /) { $_modulerevision = $1; @@ -49,6 +49,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::dirname($path); TeXLive::TLUtils::basename($path); TeXLive::TLUtils::dirname_and_basename($path); + TeXLive::TLUtils::tl_abs_path($path); TeXLive::TLUtils::dir_writable($path); TeXLive::TLUtils::dir_creatable($path); TeXLive::TLUtils::mkdirhier($path); @@ -136,6 +137,7 @@ BEGIN { &dirname &basename &dirname_and_basename + &tl_abs_path &dir_writable &dir_creatable &mkdirhier @@ -542,26 +544,62 @@ sub run_cmd { =over 4 -=item C<dirname($path)> +=item C<dirname_and_basename($path)> -Return C<$path> with its trailing C</component> removed. +Return both C<dirname> and C<basename>. Example: + + ($dirpart,$filepart) = dirname_and_basename ($path); =cut -sub dirname { +sub dirname_and_basename { my $path=shift; + my ($share, $base) = ("", ""); if (win32) { $path=~s!\\!/!g; } + # do not try to make sense of paths ending with /.. + return (undef, undef) if $path =~ m!/\.\.$!; if ($path=~m!/!) { # dirname("foo/bar/baz") -> "foo/bar" - $path=~m!(.*)/.*!; # works because of greedy matching - return $1; + # eliminate `/.' path components + while ($path =~ s!/\./!/!) {}; + # UNC path? => first split in $share = //xxx/yy and $path = /zzzz + if (win32() and $path =~ m!^(//[^/]+/[^/]+)(.*)$!) { + ($share, $path) = ($1, $2); + if ($path =~ m!^/?$!) { + $path = $share; + $base = ""; + } elsif ($path =~ m!(/.*)/(.*)!) { + $path = $share.$1; + $base = $2; + } else { + $base = $path; + $path = $share; + } + return ($path, $base); + } + # not a UNC path + $path=~m!(.*)/(.*)!; # works because of greedy matching + return ((($1 eq '') ? '/' : $1), $2); } else { # dirname("ignore") -> "." - return "."; + return (".", $path); } } +=item C<dirname($path)> + +Return C<$path> with its trailing C</component> removed. + +=cut + +sub dirname { + my $path = shift; + my ($dirname, $basename) = dirname_and_basename($path); + return $dirname; +} + + =item C<basename($path)> Return C<$path> with any leading directory components removed. @@ -569,34 +607,51 @@ Return C<$path> with any leading directory components removed. =cut sub basename { - my $path=shift; - if (win32) { - $path=~s!\\!/!g; - } - if ($path=~m!/!) { # basename("foo/bar") -> "bar" - $path=~m!.*/(.*)!; - return $1; - } else { # basename("ignore") -> "ignore" - return $path; - } + my $path = shift; + my ($dirname, $basename) = dirname_and_basename($path); + return $basename; } -=item C<dirname_and_basename($path)> - -Return both C<dirname> and C<basename>. Example: +=item C<tl_abs_path($path)> - ($dirpart,$filepart) = dirname_and_basename ($path); +# Other than Cwd::abs_path, tl_abs_path also works +# if only the grandparent exists. =cut -sub dirname_and_basename { - my $path=shift; +sub tl_abs_path { + my $path = shift; if (win32) { $path=~s!\\!/!g; } - $path=~/(.*)\/(.*)/; - return ("$1", "$2"); + my $ret; + eval {$ret = Cwd::abs_path($path);}; # eval needed for w32 + return $ret if defined $ret; + # $ret undefined: probably the parent does not exist. + # But we also want an answer if only the grandparent exists. + my ($parent, $base) = dirname_and_basename($path); + return undef unless defined $parent; + eval {$ret = Cwd::abs_path($parent);}; + if (defined $ret) { + if ($ret =~ m!/$! or $base =~ m!^/!) { + $ret = "$ret$base"; + } else { + $ret = "$ret/$base"; + } + return $ret; + } else { + my ($pparent, $pbase) = dirname_and_basename($parent); + return undef unless defined $pparent; + eval {$ret = Cwd::abs_path($pparent);}; + return undef unless defined $ret; + if ($ret =~ m!/$!) { + $ret = "$ret$pbase/$base"; + } else { + $ret = "$ret/$pbase/$base"; + } + return $ret; + } } @@ -614,14 +669,16 @@ sub dir_slash { # test whether subdirectories can be created in the argument sub dir_creatable { - $path=shift; + my $path=shift; #print STDERR "testing $path\n"; $path =~ s!\\!/!g if win32; + return 0 unless -d $path; $path =~ s!/$!!; - return 0 unless -d dir_slash($path); #print STDERR "testing $path\n"; my $i = 0; - while (-e $path . "/" . $i) { $i++; } + my $too_large = 100000; + while ((-e $path . "/" . $i) and $i<$too_large) { $i++; } + return 0 if $i>=$too_large; my $d = $path."/".$i; #print STDERR "creating $d\n"; return 0 unless mkdir $d; @@ -652,12 +709,14 @@ a fileserver. # real Program Files. Ugh. sub dir_writable { - $path=shift; - return 0 unless -d dir_slash($path); + my $path=shift; + return 0 unless -d $path; $path =~ s!\\!/!g if win32; $path =~ s!/$!!; my $i = 0; - while (-e $path . "/" . $i) { $i++; } + my $too_large = 100000; + while ((-e $path . "/" . $i) and $i<$too_large) { $i++; } + return 0 if $i>=$too_large; my $f = $path."/".$i; return 0 unless open TEST, ">".$f; my $written = 0; @@ -3076,22 +3135,24 @@ Test whether installation with TEXDIR set to $texdir would succeed due to writing permissions. Writable or not, we will not allow installation to the root -directory (Unix) or the root of the system drive (Windows). +directory (Unix) or the root of a drive (Windows). =cut sub texdir_check { my $texdir = shift; + return 0 unless defined $texdir; + # convert to absolute/canonical, for safer parsing + # tl_abs_path should work as long as grandparent exists + $texdir = tl_abs_path($texdir); + return 0 unless defined $texdir; + # also reject the root of a drive/volume, + # assuming that only the canonical form of the root ends with / + return 0 if $texdir =~ m!/$!; my $texdirparent; my $texdirpparent; - $texdir =~ s!/$!!; # remove final slash - #print STDERR "Checking $texdir".'[/]'."\n"; - # disallow unix root - return 0 if $texdir eq ""; - # disallow w32 systemdrive root - return 0 if (win32() and $texdir eq $ENV{SystemDrive}); - - return dir_writable($texdir) if (-d dir_slash($texdir)); + + return dir_writable($texdir) if (-d $texdir); ($texdirparent = $texdir) =~ s!/[^/]*$!!; #print STDERR "Checking $texdirparent".'[/]'."\n"; return dir_creatable($texdirparent) if -d dir_slash($texdirparent); @@ -3401,16 +3462,16 @@ would be considered part of the filename. sub conv_to_w32_path { my $p = shift; - $p =~ s!/!\\!g; # we need absolute paths, too - if ($p !~ m!^.:!) { - my $cwd = `cd`; - die "sorry, could not find current working directory via cd?!" if ! $cwd; - chomp($cwd); - $p = "$cwd\\$p"; - } - $p = quotify_path_with_spaces($p); - return($p); + my $pabs = tl_abs_path($p); + if (not defined $pabs) { + $pabs = $p; + tlwarn ("sorry, could not determine absolute path of $p!\n". + "using original path instead"); + } + $pabs =~ s!/!\\!g; + $pabs = quotify_path_with_spaces($pabs); + return($pabs); } =pod diff --git a/Build/source/texk/texlive/linked_scripts/uptex/convbkmk.rb b/Build/source/texk/texlive/linked_scripts/uptex/convbkmk.rb index f78583d546b..2c566fe6301 100755 --- a/Build/source/texk/texlive/linked_scripts/uptex/convbkmk.rb +++ b/Build/source/texk/texlive/linked_scripts/uptex/convbkmk.rb @@ -3,13 +3,67 @@ =begin -convbkmk Ver.0.07 += convbkmk Ver.0.08 -= License + 2013.05.11 + Takuji Tanaka + KXD02663 (at) nifty.ne.jp +((<URL:http://homepage3.nifty.com/ttk/comp/tex/uptex_en.html>)) + + +== Abstract + +((*convbkmk*)) is a tiny utility for making correct bookmarks in pdf files +typesetted by platex/uplatex with the hyperref package. +platex/uplatex + hyperref outputs data of bookmarks +in their internal encodings (EUC-JP, Shift_JIS or UTF-8). +On the other hand, the PostScript/PDF format requests that +the data is written in a certain syntax with UTF-16 or PDFDocEncoding. +Thus, data conversion is required to create correct bookmarks. +((*convbkmk*)) provides a function of +the encoding conversion and formatting the bookmark data. + +== Requirement + +ruby 1.8.3 or later + +== Examples + +platex (internal kanji code: euc) + hyperref + dvips : + $ platex doc00.tex + $ platex doc00.tex + $ dvips doc00.dvi + $ convbkmk.rb -e doc00.ps + $ ps2pdf doc00-convbkmk.ps + +platex (internal kanji code: sjis) + hyperref + dvipdfmx : + $ platex doc01.tex + $ platex doc01.tex + $ convbkmk.rb -s -o doc01.out + $ platex doc01.tex + $ dvipdfmx doc01.dvi + +uplatex + hyperref + dvips : + $ uplatex doc02.tex + $ uplatex doc02.tex + $ dvips doc02.dvi + $ convbkmk.rb doc02.ps + $ ps2pdf doc02-convbkmk.ps + +uplatex + hyperref + dvipdfmx : + $ uplatex doc03.tex + $ uplatex doc03.tex + $ convbkmk.rb -o doc03.out + $ uplatex doc03.tex + $ dvipdfmx doc03.dvi + +More examples are included in the uptex source archive. + +== License convbkmk -Copyright (c) 2009-2012 Takuji Tanaka +Copyright (c) 2009-2013 Takuji Tanaka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -29,29 +83,35 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -= History - -2009.08.02 0.00 Initial version. -2011.05.02 0.01 Bug fix: BOM was not correct. -2012.05.08 0.02 Bug fix: for a case of dvips with -z option and Ruby1.8. - Add conversion of /Creator and /Producer . -2012.05.12 0.03 Suppress halfwidth -> fullwidth katakana conversion - and MIME decoding in Ruby1.8. -2012.06.01 0.04 Support escape sequences: \n, \r, \t, \b, \f, \\, - \ddd (octal, PDFDocEncoding) and \0xUUUU (Unicode UTF-16BE). - Support sequences of end of line: - '\' or other followed by "\n", "\r\n" or "\r" . - Set file IO to binary mode. -2012.07.26 0.05 Add -o option to support conversion of OUT files - generated by dvipdfmx. -2012.08.07 0.06 Bug fix: Ver.0.05 does not work with Ruby1.9 -2012.09.17 0.07 Bug fix: An infinite loop occurs in Ver.0.05, 0.06 - with -g option in some cases. - Add reference for PDFDocEncoding. +== History + +: 2009.08.02 0.00 + * Initial version. +: 2011.05.02 0.01 + * Bug fix: BOM was not correct. +: 2012.05.08 0.02 + * Bug fix: for a case of dvips with -z option and Ruby1.8. + * Add conversion of /Creator and /Producer . +: 2012.05.12 0.03 + * Suppress halfwidth -> fullwidth katakana conversion and MIME decoding in Ruby1.8. +: 2012.06.01 0.04 + * Support escape sequences: \n, \r, \t, \b, \f, \\, \ddd (octal, PDFDocEncoding) and \0xUUUU (Unicode UTF-16BE). + * Support sequences of end of line: '\' or other followed by "\n", "\r\n" or "\r" . + * Set file IO to binary mode. +: 2012.07.26 0.05 + * Add -o option to support conversion of OUT files generated by dvipdfmx. +: 2012.08.07 0.06 + * Bug fix: Ver.0.05 does not work with Ruby1.9. +: 2012.09.17 0.07 + * Bug fix: An infinite loop occurs in Ver.0.05, 0.06 with -g option in some cases. + * Add reference for PDFDocEncoding. +: 2013.05.11 0.08 + * Add -O option: overwrite output files onto input files instead of creating foo-convbkmk.ps . + * Make comments rd/rdtool friendly. =end -Version = "0.07" +Version = "0.08" require "optparse" @@ -196,6 +256,11 @@ OptionParser.new do |opt| Opts[:mode] = 'out' require "fileutils" } + opt.on('-O', '--overwrite', + 'overwrite output files') {|v| + Opts[:mode] = 'overwrite' + require "fileutils" + } opt.banner += " file0.ps [file1.ps ...]\n" \ + opt.banner.sub('Usage:',' ') + " < in_file.ps > out_file.ps\n" \ + opt.banner.sub('Usage:',' ') + ' -o file0.out [file1.out ...]' @@ -429,7 +494,9 @@ else file_treatment(ifile, ofile, enc) } } - FileUtils.mv(fout, fin) if Opts[:mode] == 'out' + if (Opts[:mode] == 'out' || Opts[:mode] == 'overwrite') + FileUtils.mv(fout, fin) + end } end diff --git a/Build/source/texk/texlive/tl_scripts/fmtutil.cnf b/Build/source/texk/texlive/tl_scripts/fmtutil.cnf index e6dab71afee..16ee26b61cc 100644 --- a/Build/source/texk/texlive/tl_scripts/fmtutil.cnf +++ b/Build/source/texk/texlive/tl_scripts/fmtutil.cnf @@ -1,4 +1,4 @@ -# Generated by /home/texlive/karl/Master/bin/i386-linux/tlmgr on Mon Apr 8 21:17:02 2013 +# Generated by /home/texlive/karl/Master/bin/i386-linux/tlmgr on Fri May 3 03:37:00 2013 # Originally written by Thomas Esser, 1998. Public domain. # # As of TeX Live 2008, the final fmtutil.cnf is generated by @@ -13,7 +13,7 @@ # The last "argument" must be the name of the file on which to run # the ini-engine (such as initex). If the ini-engine is e-TeX, and the # e-TeX extensions should be enabled, the filename must be prefixed with -# a * character. +# a * character; this is essentially equivalent to the -etex option. # # fmtutil always passes the -ini option to the engine. # If no pattern-file is desired, use -. @@ -23,7 +23,7 @@ # 1) tex and amstex just load hyphen.tex. No customization. # You can have your own customized (via babel's hyphen.cfg) # formats on top of plain by using "bplain.tex" instead of -# plain.tex (see e.g. bplain.ini file for bplain format). +# plain.tex (e.g., bplain.ini file for bplain format). # # 2) etex-based formats load language.def, not language.dat. # @@ -86,7 +86,7 @@ pdfmex pdftex mexconf.tex -translate-file=cp227.tcx *pdfmex.ini utf8mex pdftex mexconf.tex -enc *utf8mex.ini # # from mltex: -mllatex pdftex language.dat -translate-file=cp227.tcx -mltex mllatex.ini +mllatex pdftex language.dat -translate-file=cp227.tcx -mltex *mllatex.ini mltex pdftex - -translate-file=cp227.tcx -mltex mltex.ini # # from mptopdf: diff --git a/Build/source/utils/biber/TeXLive/TLUtils.pm b/Build/source/utils/biber/TeXLive/TLUtils.pm index fdcd482f5ba..fdc594d2c2c 100644 --- a/Build/source/utils/biber/TeXLive/TLUtils.pm +++ b/Build/source/utils/biber/TeXLive/TLUtils.pm @@ -5,7 +5,7 @@ package TeXLive::TLUtils; -my $svnrev = '$Revision: 30127 $'; +my $svnrev = '$Revision: 30367 $'; my $_modulerevision; if ($svnrev =~ m/: ([0-9]+) /) { $_modulerevision = $1; @@ -49,6 +49,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::dirname($path); TeXLive::TLUtils::basename($path); TeXLive::TLUtils::dirname_and_basename($path); + TeXLive::TLUtils::tl_abs_path($path); TeXLive::TLUtils::dir_writable($path); TeXLive::TLUtils::dir_creatable($path); TeXLive::TLUtils::mkdirhier($path); @@ -136,6 +137,7 @@ BEGIN { &dirname &basename &dirname_and_basename + &tl_abs_path &dir_writable &dir_creatable &mkdirhier @@ -542,26 +544,62 @@ sub run_cmd { =over 4 -=item C<dirname($path)> +=item C<dirname_and_basename($path)> -Return C<$path> with its trailing C</component> removed. +Return both C<dirname> and C<basename>. Example: + + ($dirpart,$filepart) = dirname_and_basename ($path); =cut -sub dirname { +sub dirname_and_basename { my $path=shift; + my ($share, $base) = ("", ""); if (win32) { $path=~s!\\!/!g; } + # do not try to make sense of paths ending with /.. + return (undef, undef) if $path =~ m!/\.\.$!; if ($path=~m!/!) { # dirname("foo/bar/baz") -> "foo/bar" - $path=~m!(.*)/.*!; # works because of greedy matching - return $1; + # eliminate `/.' path components + while ($path =~ s!/\./!/!) {}; + # UNC path? => first split in $share = //xxx/yy and $path = /zzzz + if (win32() and $path =~ m!^(//[^/]+/[^/]+)(.*)$!) { + ($share, $path) = ($1, $2); + if ($path =~ m!^/?$!) { + $path = $share; + $base = ""; + } elsif ($path =~ m!(/.*)/(.*)!) { + $path = $share.$1; + $base = $2; + } else { + $base = $path; + $path = $share; + } + return ($path, $base); + } + # not a UNC path + $path=~m!(.*)/(.*)!; # works because of greedy matching + return ((($1 eq '') ? '/' : $1), $2); } else { # dirname("ignore") -> "." - return "."; + return (".", $path); } } +=item C<dirname($path)> + +Return C<$path> with its trailing C</component> removed. + +=cut + +sub dirname { + my $path = shift; + my ($dirname, $basename) = dirname_and_basename($path); + return $dirname; +} + + =item C<basename($path)> Return C<$path> with any leading directory components removed. @@ -569,34 +607,51 @@ Return C<$path> with any leading directory components removed. =cut sub basename { - my $path=shift; - if (win32) { - $path=~s!\\!/!g; - } - if ($path=~m!/!) { # basename("foo/bar") -> "bar" - $path=~m!.*/(.*)!; - return $1; - } else { # basename("ignore") -> "ignore" - return $path; - } + my $path = shift; + my ($dirname, $basename) = dirname_and_basename($path); + return $basename; } -=item C<dirname_and_basename($path)> - -Return both C<dirname> and C<basename>. Example: +=item C<tl_abs_path($path)> - ($dirpart,$filepart) = dirname_and_basename ($path); +# Other than Cwd::abs_path, tl_abs_path also works +# if only the grandparent exists. =cut -sub dirname_and_basename { - my $path=shift; +sub tl_abs_path { + my $path = shift; if (win32) { $path=~s!\\!/!g; } - $path=~/(.*)\/(.*)/; - return ("$1", "$2"); + my $ret; + eval {$ret = Cwd::abs_path($path);}; # eval needed for w32 + return $ret if defined $ret; + # $ret undefined: probably the parent does not exist. + # But we also want an answer if only the grandparent exists. + my ($parent, $base) = dirname_and_basename($path); + return undef unless defined $parent; + eval {$ret = Cwd::abs_path($parent);}; + if (defined $ret) { + if ($ret =~ m!/$! or $base =~ m!^/!) { + $ret = "$ret$base"; + } else { + $ret = "$ret/$base"; + } + return $ret; + } else { + my ($pparent, $pbase) = dirname_and_basename($parent); + return undef unless defined $pparent; + eval {$ret = Cwd::abs_path($pparent);}; + return undef unless defined $ret; + if ($ret =~ m!/$!) { + $ret = "$ret$pbase/$base"; + } else { + $ret = "$ret/$pbase/$base"; + } + return $ret; + } } @@ -614,14 +669,16 @@ sub dir_slash { # test whether subdirectories can be created in the argument sub dir_creatable { - $path=shift; + my $path=shift; #print STDERR "testing $path\n"; $path =~ s!\\!/!g if win32; + return 0 unless -d $path; $path =~ s!/$!!; - return 0 unless -d dir_slash($path); #print STDERR "testing $path\n"; my $i = 0; - while (-e $path . "/" . $i) { $i++; } + my $too_large = 100000; + while ((-e $path . "/" . $i) and $i<$too_large) { $i++; } + return 0 if $i>=$too_large; my $d = $path."/".$i; #print STDERR "creating $d\n"; return 0 unless mkdir $d; @@ -652,12 +709,14 @@ a fileserver. # real Program Files. Ugh. sub dir_writable { - $path=shift; - return 0 unless -d dir_slash($path); + my $path=shift; + return 0 unless -d $path; $path =~ s!\\!/!g if win32; $path =~ s!/$!!; my $i = 0; - while (-e $path . "/" . $i) { $i++; } + my $too_large = 100000; + while ((-e $path . "/" . $i) and $i<$too_large) { $i++; } + return 0 if $i>=$too_large; my $f = $path."/".$i; return 0 unless open TEST, ">".$f; my $written = 0; @@ -3076,22 +3135,24 @@ Test whether installation with TEXDIR set to $texdir would succeed due to writing permissions. Writable or not, we will not allow installation to the root -directory (Unix) or the root of the system drive (Windows). +directory (Unix) or the root of a drive (Windows). =cut sub texdir_check { my $texdir = shift; + return 0 unless defined $texdir; + # convert to absolute/canonical, for safer parsing + # tl_abs_path should work as long as grandparent exists + $texdir = tl_abs_path($texdir); + return 0 unless defined $texdir; + # also reject the root of a drive/volume, + # assuming that only the canonical form of the root ends with / + return 0 if $texdir =~ m!/$!; my $texdirparent; my $texdirpparent; - $texdir =~ s!/$!!; # remove final slash - #print STDERR "Checking $texdir".'[/]'."\n"; - # disallow unix root - return 0 if $texdir eq ""; - # disallow w32 systemdrive root - return 0 if (win32() and $texdir eq $ENV{SystemDrive}); - - return dir_writable($texdir) if (-d dir_slash($texdir)); + + return dir_writable($texdir) if (-d $texdir); ($texdirparent = $texdir) =~ s!/[^/]*$!!; #print STDERR "Checking $texdirparent".'[/]'."\n"; return dir_creatable($texdirparent) if -d dir_slash($texdirparent); @@ -3401,16 +3462,16 @@ would be considered part of the filename. sub conv_to_w32_path { my $p = shift; - $p =~ s!/!\\!g; # we need absolute paths, too - if ($p !~ m!^.:!) { - my $cwd = `cd`; - die "sorry, could not find current working directory via cd?!" if ! $cwd; - chomp($cwd); - $p = "$cwd\\$p"; - } - $p = quotify_path_with_spaces($p); - return($p); + my $pabs = tl_abs_path($p); + if (not defined $pabs) { + $pabs = $p; + tlwarn ("sorry, could not determine absolute path of $p!\n". + "using original path instead"); + } + $pabs =~ s!/!\\!g; + $pabs = quotify_path_with_spaces($pabs); + return($pabs); } =pod |