summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx')
-rw-r--r--Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx710
1 files changed, 640 insertions, 70 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx b/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
index 52752d99621..7f51559757b 100644
--- a/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
+++ b/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2007, 2009, 2010 by
+% Copyright (C) 2007, 2009-2011 by
% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%
% This work may be distributed and/or modified under the
@@ -24,6 +24,7 @@
% and the derived files
% pdftexcmds.sty, pdftexcmds.pdf, pdftexcmds.ins, pdftexcmds.drv,
% pdftexcmds-test1.tex, pdftexcmds-test2.tex,
+% pdftexcmds-test-shell.tex, pdftexcmds-test-escape.tex,
% oberdiek.pdftexcmds.lua, pdftexcmds.lua.
%
% Distribution:
@@ -63,6 +64,8 @@
% TDS:doc/latex/oberdiek/pdftexcmds.pdf
% TDS:doc/latex/oberdiek/test/pdftexcmds-test1.tex
% TDS:doc/latex/oberdiek/test/pdftexcmds-test2.tex
+% TDS:doc/latex/oberdiek/test/pdftexcmds-test-shell.tex
+% TDS:doc/latex/oberdiek/test/pdftexcmds-test-escape.tex
% TDS:source/latex/oberdiek/pdftexcmds.dtx
%
%<*ignore>
@@ -80,7 +83,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: pdftexcmds 2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX (HO)}
+\Msg{* Package: pdftexcmds 2011/04/10 v0.14 Utilities of pdfTeX for LuaTeX (HO)}
\Msg{************************************************************************}
\keepsilent
@@ -91,7 +94,7 @@
This is a generated file.
-Copyright (C) 2007, 2009, 2010 by
+Copyright (C) 2007, 2009-2011 by
Heiko Oberdiek <heiko.oberdiek at googlemail.com>
This work may be distributed and/or modified under the
@@ -115,6 +118,7 @@ This work consists of the main source file pdftexcmds.dtx
and the derived files
pdftexcmds.sty, pdftexcmds.pdf, pdftexcmds.ins, pdftexcmds.drv,
pdftexcmds-test1.tex, pdftexcmds-test2.tex,
+ pdftexcmds-test-shell.tex, pdftexcmds-test-escape.tex,
oberdiek.pdftexcmds.lua, pdftexcmds.lua.
\endpreamble
@@ -128,6 +132,8 @@ and the derived files
\usedir{doc/latex/oberdiek/test}%
\file{pdftexcmds-test1.tex}{\from{pdftexcmds.dtx}{test1}}%
\file{pdftexcmds-test2.tex}{\from{pdftexcmds.dtx}{test2}}%
+ \file{pdftexcmds-test-shell.tex}{\from{pdftexcmds.dtx}{test-shell}}%
+ \file{pdftexcmds-test-escape.tex}{\from{pdftexcmds.dtx}{test-escape}}%
}
\def\MetaPrefix{-- }
\def\defaultpostamble{%
@@ -169,7 +175,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{pdftexcmds.drv}%
- [2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX (HO)]%
+ [2011/04/10 v0.14 Utilities of pdfTeX for LuaTeX (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\usepackage{paralist}
@@ -179,7 +185,7 @@ and the derived files
%</driver>
% \fi
%
-% \CheckSum{940}
+% \CheckSum{1618}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -200,7 +206,7 @@ and the derived files
% \GetFileInfo{pdftexcmds.drv}
%
% \title{The \xpackage{pdftexcmds} package}
-% \date{2010/04/01 v0.9}
+% \date{2011/04/10 v0.14}
% \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
@@ -329,14 +335,50 @@ and the derived files
% \end{declcs}
% Same as |\pdfmdfivesum file{|\meta{filename}|}|.
%
+% \begin{declcs}{pdf@draftmode}
+% \end{declcs}
+% If the \TeX\ compiler knows \cs{pdfdraftmode} (\hologo{pdfTeX},
+% \hologo{LuaTeX}), then \cs{pdf@draftmode} returns, whether
+% this mode is enabled. The result is an implicite number:
+% one means the draft mode is available and enabled.
+% If the value is zero, then the mode is not active or
+% \cs{pdfdraftmode} is not available.
+% An explicite number is yielded by \cs{number}\cs{pdf@draftmode}.
+% The macro cannot
+% be used to change the mode, see \cs{pdf@setdraftmode}.
+%
+% \begin{declcs}{pdf@ifdraftmode} \M{true} \M{false}
+% \end{declcs}
+% If \cs{pdfdraftmode} is available and enabled, \meta{true} is
+% called, otherwise \meta{false} is executed.
+%
+% \begin{declcs}{pdf@setdraftmode} \M{value}
+% \end{declcs}
+% Macro \cs{pdf@setdraftmode} expects the number zero or one as
+% \meta{value}. Zero deactivates the mode and one enables the draft mode.
+% The macro does not have an effect, if the feature \cs{pdfdraftmode} is not
+% available.
+%
% \begin{declcs}{pdf@shellescape}
% \end{declcs}
-% Same as |\pdfshellescape|. It expands to |1| if external
+% Same as |\pdfshellescape|. It is or expands to |1| if external
% commands can be executed and |0| otherwise. In \hologo{pdfTeX} external
% commands must be enabled first by command line option or
% configuration option. In \hologo{LuaTeX} option |--safer| disables
% the execution of external commands.
%
+% Hints for usage:
+% \begin{itemize}
+% \item \cs{pdf@shellescape} might be a numerical constant,
+% expands to the primitive, or expands to a plain number.
+% Therefore use it in contexts where these differences does not matter.
+% \item Use in comparisons, e.g.:
+% \begin{quote}
+% |\ifnum\pdf@shellescape=0 ...|
+% \end{quote}
+% \item Print the number: |\number\pdf@shellescape|
+% \end{itemize}
+%
% \begin{declcs}{pdf@system} \M{cmdline}
% \end{declcs}
% It is a wrapper for |\immediate\write18| in \hologo{pdfTeX} or
@@ -418,14 +460,18 @@ and the derived files
% \subsection{Reload check and package identification}
% Reload check, especially if the package is not used with \LaTeX.
% \begin{macrocode}
-\begingroup
- \catcode44 12 % ,
- \catcode45 12 % -
- \catcode46 12 % .
- \catcode58 12 % :
- \catcode64 11 % @
- \catcode123 1 % {
- \catcode125 2 % }
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode35=6 % #
+ \catcode39=12 % '
+ \catcode44=12 % ,
+ \catcode45=12 % -
+ \catcode46=12 % .
+ \catcode58=12 % :
+ \catcode64=11 % @
+ \catcode123=1 % {
+ \catcode125=2 % }
\expandafter\let\expandafter\x\csname ver@pdftexcmds.sty\endcsname
\ifx\x\relax % plain-TeX, first loading
\else
@@ -433,7 +479,6 @@ and the derived files
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\else
- \catcode35 6 % #
\expandafter\ifx\csname PackageInfo\endcsname\relax
\def\x#1#2{%
\immediate\write-1{Package #1 Info: #2.}%
@@ -445,24 +490,27 @@ and the derived files
\aftergroup\endinput
\fi
\fi
-\endgroup
+\endgroup%
% \end{macrocode}
% Package identification:
% \begin{macrocode}
-\begingroup
- \catcode35 6 % #
- \catcode40 12 % (
- \catcode41 12 % )
- \catcode44 12 % ,
- \catcode45 12 % -
- \catcode46 12 % .
- \catcode47 12 % /
- \catcode58 12 % :
- \catcode64 11 % @
- \catcode91 12 % [
- \catcode93 12 % ]
- \catcode123 1 % {
- \catcode125 2 % }
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode35=6 % #
+ \catcode39=12 % '
+ \catcode40=12 % (
+ \catcode41=12 % )
+ \catcode44=12 % ,
+ \catcode45=12 % -
+ \catcode46=12 % .
+ \catcode47=12 % /
+ \catcode58=12 % :
+ \catcode64=11 % @
+ \catcode91=12 % [
+ \catcode93=12 % ]
+ \catcode123=1 % {
+ \catcode125=2 % }
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\x#1#2#3[#4]{\endgroup
\immediate\write-1{Package: #3 #4}%
@@ -481,38 +529,51 @@ and the derived files
\fi
\expandafter\x\csname ver@pdftexcmds.sty\endcsname
\ProvidesPackage{pdftexcmds}%
- [2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX (HO)]
+ [2011/04/10 v0.14 Utilities of pdfTeX for LuaTeX (HO)]%
% \end{macrocode}
%
% \subsection{Catcodes}
%
% \begin{macrocode}
-\begingroup
- \catcode123 1 % {
- \catcode125 2 % }
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode123=1 % {
+ \catcode125=2 % }
+ \catcode64=11 % @
\def\x{\endgroup
\expandafter\edef\csname pdftexcmds@AtEnd\endcsname{%
- \catcode35 \the\catcode35\relax
- \catcode64 \the\catcode64\relax
- \catcode123 \the\catcode123\relax
- \catcode125 \the\catcode125\relax
+ \endlinechar=\the\endlinechar\relax
+ \catcode13=\the\catcode13\relax
+ \catcode32=\the\catcode32\relax
+ \catcode35=\the\catcode35\relax
+ \catcode61=\the\catcode61\relax
+ \catcode64=\the\catcode64\relax
+ \catcode123=\the\catcode123\relax
+ \catcode125=\the\catcode125\relax
}%
}%
-\x
-\catcode35 6 % #
-\catcode64 11 % @
-\catcode123 1 % {
-\catcode125 2 % }
+\x\catcode61\catcode48\catcode32=10\relax%
+\catcode13=5 % ^^M
+\endlinechar=13 %
+\catcode35=6 % #
+\catcode64=11 % @
+\catcode123=1 % {
+\catcode125=2 % }
\def\TMP@EnsureCode#1#2{%
\edef\pdftexcmds@AtEnd{%
\pdftexcmds@AtEnd
- \catcode#1 \the\catcode#1\relax
+ \catcode#1=\the\catcode#1\relax
}%
- \catcode#1 #2\relax
+ \catcode#1=#2\relax
}
+\TMP@EnsureCode{0}{12}%
+\TMP@EnsureCode{1}{12}%
+\TMP@EnsureCode{2}{12}%
\TMP@EnsureCode{10}{12}% ^^J
\TMP@EnsureCode{33}{12}% !
\TMP@EnsureCode{34}{12}% "
+\TMP@EnsureCode{38}{4}% &
\TMP@EnsureCode{39}{12}% '
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
@@ -524,8 +585,9 @@ and the derived files
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{58}{12}% :
\TMP@EnsureCode{60}{12}% <
-\TMP@EnsureCode{61}{12}% =
\TMP@EnsureCode{62}{12}% >
+\TMP@EnsureCode{91}{12}% [
+\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{94}{7}% ^ (superscript)
\TMP@EnsureCode{95}{12}% _ (other)
\TMP@EnsureCode{96}{12}% `
@@ -533,22 +595,31 @@ and the derived files
\edef\pdftexcmds@AtEnd{%
\pdftexcmds@AtEnd
\escapechar=\number\escapechar\relax
+ \noexpand\endinput
}
\escapechar=92 %
% \end{macrocode}
%
-% \subsection{Load package \xpackage{infwarerr}}
+% \subsection{Load packages}
%
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
- \input infwarerr.sty\relax
- \input ifluatex.sty\relax
- \input ltxcmds.sty\relax
+ \def\TMP@RequirePackage#1[#2]{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname ver@#1.sty\endcsname\relax
+ \input #1.sty\relax
+ \fi
+ }%
+ \TMP@RequirePackage{infwarerr}[2007/09/09]%
+ \TMP@RequirePackage{ifluatex}[2010/03/01]%
+ \TMP@RequirePackage{ltxcmds}[2010/12/02]%
+ \TMP@RequirePackage{ifpdf}[2010/09/13]%
\else
\RequirePackage{infwarerr}[2007/09/09]%
\RequirePackage{ifluatex}[2010/03/01]%
- \RequirePackage{ltxcmds}[2009/12/12]%
+ \RequirePackage{ltxcmds}[2010/12/02]%
+ \RequirePackage{ifpdf}[2010/09/13]%
\fi
% \end{macrocode}
%
@@ -658,7 +729,10 @@ and the derived files
\endlinechar=\newlinechar
\pdftexcmds@directlua{%
if tex.enableprimitives then
- tex.enableprimitives('pdf@', {'primitive', 'ifprimitive'})
+ tex.enableprimitives(
+ 'pdf@',
+ {'primitive', 'ifprimitive', 'pdfdraftmode'}
+ )
tex.enableprimitives('', {'luaescapestring'})
end
}%
@@ -834,23 +908,156 @@ and the derived files
\ifluatex
\else
\pdf@isprimitive
- \pdftexcmds@AtEnd
- \expandafter\endinput
\fi
% \end{macrocode}
%
+% \subsection{\cs{pdf@draftmode}}
+%
+%
+% \begin{macrocode}
+\let\pdftexcmds@temp\ltx@zero %
+\ltx@IfUndefined{pdfdraftmode}{%
+ \@PackageInfoNoLine{pdftexcmds}{\ltx@backslashchar pdfdraftmode not found}%
+}{%
+ \ifpdf
+ \let\pdftexcmds@temp\ltx@one
+ \@PackageInfoNoLine{pdftexcmds}{\ltx@backslashchar pdfdraftmode found}%
+ \else
+ \@PackageInfoNoLine{pdftexcmds}{%
+ \ltx@backslashchar pdfdraftmode is ignored in DVI mode%
+ }%
+ \fi
+}
+\ifcase\pdftexcmds@temp
+% \end{macrocode}
+% \begin{macro}{\pdf@draftmode}
+% \begin{macrocode}
+ \let\pdf@draftmode\ltx@zero
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdf@ifdraftmode}
+% \begin{macrocode}
+ \let\pdf@ifdraftmode\ltx@secondoftwo
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdftexcmds@setdraftmode}
+% \begin{macrocode}
+ \def\pdftexcmds@setdraftmode#1{}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\else
+% \end{macrocode}
+% \begin{macro}{\pdftexcmds@draftmode}
+% \begin{macrocode}
+ \let\pdftexcmds@draftmode\pdfdraftmode
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdf@ifdraftmode}
+% \begin{macrocode}
+ \def\pdf@ifdraftmode{%
+ \ifnum\pdftexcmds@draftmode=\ltx@one
+ \expandafter\ltx@firstoftwo
+ \else
+ \expandafter\ltx@secondoftwo
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdf@draftmode}
+% \begin{macrocode}
+ \def\pdf@draftmode{%
+ \ifnum\pdftexcmds@draftmode=\ltx@one
+ \expandafter\ltx@one
+ \else
+ \expandafter\ltx@zero
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdftexcmds@setdraftmode}
+% \begin{macrocode}
+ \def\pdftexcmds@setdraftmode#1{%
+ \pdftexcmds@draftmode=#1\relax
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\fi
+% \end{macrocode}
+% \begin{macro}{\pdf@setdraftmode}
+% \begin{macrocode}
+\def\pdf@setdraftmode#1{%
+ \begingroup
+ \count\ltx@cclv=#1\relax
+ \edef\x{\endgroup
+ \noexpand\pdftexcmds@@setdraftmode{\the\count\ltx@cclv}%
+ }%
+ \x
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdftexcmds@@setdraftmode}
+% \begin{macrocode}
+\def\pdftexcmds@@setdraftmode#1{%
+ \ifcase#1 %
+ \pdftexcmds@setdraftmode{#1}%
+ \or
+ \pdftexcmds@setdraftmode{#1}%
+ \else
+ \@PackageWarning{pdftexcmds}{%
+ \string\pdf@setdraftmode: Ignoring\MessageBreak
+ invalid value `#1'%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Load Lua module}
%
% \begin{macrocode}
+\ifluatex
+\else
+ \expandafter\pdftexcmds@AtEnd
+\fi%
+% \end{macrocode}
+%
+% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
- \input luatex-loader.sty\relax
+ \def\TMP@RequirePackage#1[#2]{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname ver@#1.sty\endcsname\relax
+ \input #1.sty\relax
+ \fi
+ }%
+ \TMP@RequirePackage{luatex-loader}[2009/04/10]%
\else
\RequirePackage{luatex-loader}[2009/04/10]%
\fi
\pdftexcmds@directlua{%
require("oberdiek.pdftexcmds")%
}
+\begingroup
+ \def\x{2011/04/10 v0.14}%
+ \ltx@onelevel@sanitize\x
+ \edef\y{%
+ \pdftexcmds@directlua{%
+ if oberdiek.pdftexcmds.getversion then %
+ oberdiek.pdftexcmds.getversion()%
+ end%
+ }%
+ }%
+ \ifx\x\y
+ \else
+ \@PackageError{pdftexcmds}{%
+ Wrong version of lua module.\MessageBreak
+ Package version: \x\MessageBreak
+ Lua module: \y
+ }\@ehc
+ \fi
+\endgroup
% \end{macrocode}
%
% \subsection{Lua functions}
@@ -866,6 +1073,65 @@ and the derived files
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\pdftexcmds@Patch}
+% \begin{macrocode}
+\def\pdftexcmds@Patch{0}
+
+\ifnum\luatexversion>40 %
+ \ifnum\luatexversion<66 %
+ \def\pdftexcmds@Patch{1}%
+ \fi
+\fi
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\ifcase\pdftexcmds@Patch
+ \catcode`\&=14 %
+\else
+ \catcode`\&=9 %
+% \end{macrocode}
+% \begin{macro}{\pdftexcmds@PatchDecode}
+% \begin{macrocode}
+ \def\pdftexcmds@PatchDecode#1\@nil{%
+ \pdftexcmds@DecodeA#1^^A^^A\@nil{}%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdftexcmds@DecodeA}
+% \begin{macrocode}
+ \def\pdftexcmds@DecodeA#1^^A^^A#2\@nil#3{%
+ \ifx\relax#2\relax
+ \ltx@ReturnAfterElseFi{%
+ \pdftexcmds@DecodeB#3#1^^A^^B\@nil{}%
+ }%
+ \else
+ \ltx@ReturnAfterFi{%
+ \pdftexcmds@DecodeA#2\@nil{#3#1^^@}%
+ }%
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdftexcmds@DecodeB}
+% \begin{macrocode}
+ \def\pdftexcmds@DecodeB#1^^A^^B#2\@nil#3{%
+ \ifx\relax#2\relax%
+ \ltx@ReturnAfterElseFi{%
+ \ltx@zero
+ #3#1%
+ }%
+ \else
+ \ltx@ReturnAfterFi{%
+ \pdftexcmds@DecodeB#2\@nil{#3#1^^A}%
+ }%
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\fi
+% \end{macrocode}
+%
% \begin{macrocode}
\ifnum\luatexversion<36 %
\else
@@ -907,22 +1173,26 @@ and the derived files
% \begin{macro}{\pdf@unescapehex}
% \begin{macrocode}
\def\pdf@unescapehex#1{%
+& \romannumeral\expandafter\pdftexcmds@PatchDecode
\the\expandafter\pdftexcmds@toks
\directlua0{%
oberdiek.pdftexcmds.toks="pdftexcmds@toks"%
- oberdiek.pdftexcmds.unescapehex("\luaescapestring{#1}", "byte")%
+ oberdiek.pdftexcmds.unescapehex("\luaescapestring{#1}", "byte", \pdftexcmds@Patch)%
}%
+& \@nil
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pdf@unescapehexnative}
% \begin{macrocode}
\def\pdf@unescapehexnative#1{%
+& \romannumeral\expandafter\pdftexcmds@PatchDecode
\the\expandafter\pdftexcmds@toks
\directlua0{%
oberdiek.pdftexcmds.toks="pdftexcmds@toks"%
- oberdiek.pdftexcmds.unescapehex("\luaescapestring{#1}")%
+ oberdiek.pdftexcmds.unescapehex("\luaescapestring{#1}", \pdftexcmds@Patch)%
}%
+& \@nil
}%
% \end{macrocode}
% \end{macro}
@@ -1064,18 +1334,20 @@ and the derived files
}%
=1 %
\def\pdf@pipe#1{%
+& \romannumeral\expandafter\pdftexcmds@PatchDecode
\the\expandafter\pdftexcmds@toks
\pdftexcmds@directlua{%
oberdiek.pdftexcmds.toks="pdftexcmds@toks"%
- oberdiek.pdftexcmds.pipe("\luaescapestring{#1}")%
+ oberdiek.pdftexcmds.pipe("\luaescapestring{#1}", \pdftexcmds@Patch)%
}%
+& \@nil
}%
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
-\pdftexcmds@AtEnd
+\pdftexcmds@AtEnd%
%</package>
% \end{macrocode}
%
@@ -1088,6 +1360,9 @@ and the derived files
% \begin{macrocode}
module("oberdiek.pdftexcmds", package.seeall)
local systemexitstatus
+function getversion()
+ tex.write("2011/04/10 v0.14")
+end
function strcmp(A, B)
if A == B then
tex.write("0")
@@ -1136,7 +1411,7 @@ end
% See procedure |unescapehex| in file \xfile{utils.c} of \hologo{pdfTeX}.
% Caution: |tex.write| ignores leading spaces.
% \begin{macrocode}
-function unescapehex(str, mode)
+function unescapehex(str, mode, patch)
local a = 0
local first = true
local result = {}
@@ -1164,6 +1439,23 @@ function unescapehex(str, mode)
if not first then
table.insert(result, a)
end
+ if patch == 1 then
+ local temp = {}
+ for i, a in ipairs(result) do
+ if a == 0 then
+ table.insert(temp, 1)
+ table.insert(temp, 1)
+ else
+ if a == 1 then
+ table.insert(temp, 1)
+ table.insert(temp, 2)
+ else
+ table.insert(temp, a)
+ end
+ end
+ end
+ result = temp
+ end
if mode == "byte" then
local utf8 = {}
for i, a in ipairs(result) do
@@ -1326,7 +1618,16 @@ function filemdfivesum(filename)
end
function shellescape()
if os.execute then
- tex.write("1")
+ local result = os.execute()
+ if result == 0 then
+ tex.write("0")
+ else
+ if result == nil then
+ tex.write("0")
+ else
+ tex.write("1")
+ end
+ end
else
tex.write("0")
end
@@ -1354,7 +1655,7 @@ function lastsystemexit()
tex.write(math.floor(result / 256))
end
end
-function pipe(cmdline)
+function pipe(cmdline, patch)
local result
systemexitstatus = nil
texio.write_nl("log", "pipe(" .. cmdline ..") ")
@@ -1369,6 +1670,23 @@ function pipe(cmdline)
texio.write("log", "disabled.")
end
if result then
+ if patch == 1 then
+ local temp = {}
+ for i, a in ipairs(result) do
+ if a == 0 then
+ table.insert(temp, 1)
+ table.insert(temp, 1)
+ else
+ if a == 1 then
+ table.insert(temp, 1)
+ table.insert(temp, 2)
+ else
+ table.insert(temp, a)
+ end
+ end
+ end
+ result = temp
+ end
tex.settoks(toks, result)
else
tex.settoks(toks, "")
@@ -1439,6 +1757,22 @@ end
\advance\count@ 1 %
\repeat
}
+\def\RangeCatcodeCheck#1#2#3{%
+ \count@=#1\relax
+ \loop
+ \ifnum#3=\catcode\count@
+ \else
+ \errmessage{%
+ Character \the\count@\space
+ with wrong catcode \the\catcode\count@\space
+ instead of \number#3%
+ }%
+ \fi
+ \ifnum\count@<#2\relax
+ \advance\count@ 1 %
+ \repeat
+}
+\def\space{ }
\expandafter\ifx\csname LoadCommand\endcsname\relax
\def\LoadCommand{\input pdftexcmds.sty\relax}%
\fi
@@ -1449,15 +1783,20 @@ end
\RangeCatcodeInvalid{123}{255}%
\catcode`\@=12 %
\catcode`\\=0 %
- \catcode`\{=1 %
- \catcode`\}=2 %
- \catcode`\#=6 %
- \catcode`\[=12 %
- \catcode`\]=12 %
\catcode`\%=14 %
- \catcode`\ =10 %
- \catcode13=5 %
\LoadCommand
+ \RangeCatcodeCheck{0}{36}{15}%
+ \RangeCatcodeCheck{37}{37}{14}%
+ \RangeCatcodeCheck{38}{47}{15}%
+ \RangeCatcodeCheck{48}{57}{12}%
+ \RangeCatcodeCheck{58}{63}{15}%
+ \RangeCatcodeCheck{64}{64}{12}%
+ \RangeCatcodeCheck{65}{90}{11}%
+ \RangeCatcodeCheck{91}{91}{15}%
+ \RangeCatcodeCheck{92}{92}{0}%
+ \RangeCatcodeCheck{93}{96}{15}%
+ \RangeCatcodeCheck{97}{122}{11}%
+ \RangeCatcodeCheck{123}{255}{15}%
\RestoreCatcodes
}
\Test
@@ -1520,6 +1859,210 @@ end
%</test2>
% \end{macrocode}
%
+% \subsection{Test for \cs{pdf@shellescape}}
+%
+% \begin{macrocode}
+%<*test-shell>
+\catcode`\{=1 %
+\catcode`\}=2 %
+\catcode`\#=6 %
+\catcode`\@=11 %
+\input pdftexcmds.sty\relax
+\def\msg#{\immediate\write16}
+\ifx\pdf@shellescape\@undefined
+ \msg{SHELL=U}%
+\else
+ \msg{SHELL=\number\pdf@shellescape}%
+\fi
+\ifx\expected\@undefined
+\else
+ \ifx\expected\relax
+ \msg{EXPECTED=U}%
+ \ifx\pdf@shellescape\@undefined
+ \msg{OK}%
+ \else
+ \errmessage{Failed}%
+ \fi
+ \else
+ \msg{EXPECTED=\number\expected}%
+ \ifnum\pdf@shellescape=\expected\relax
+ \msg{OK}%
+ \else
+ \errmessage{Failed}%
+ \fi
+ \fi
+\fi
+\csname @@end\endcsname\end
+%</test-shell>
+% \end{macrocode}
+%
+% \subsection{Test for escape functions}
+%
+% \begin{macrocode}
+%<*test-escape>
+\catcode`\{=1 %
+\catcode`\}=2 %
+\catcode`\#=6 %
+\catcode`\^=7 %
+\catcode`\@=11 %
+\errorcontextlines=1000 %
+\input pdftexcmds.sty\relax
+\def\msg#1{%
+ \begingroup
+ \escapechar=92 %
+ \immediate\write16{#1}%
+ \endgroup
+}
+% \end{macrocode}
+% \begin{macrocode}
+\begingroup
+ \catcode`\@=11 %
+ \countdef\count@=255 %
+ \def\space{ }%
+ \long\def\@whilenum#1\do #2{%
+ \ifnum #1\relax
+ #2\relax
+ \@iwhilenum{#1\relax#2\relax}%
+ \fi
+ }%
+ \long\def\@iwhilenum#1{%
+ \ifnum #1%
+ \expandafter\@iwhilenum
+ \else
+ \expandafter\ltx@gobble
+ \fi
+ {#1}%
+ }%
+ \gdef\AllBytes{}%
+ \count@=0 %
+ \catcode0=12 %
+ \@whilenum\count@<256 \do{%
+ \lccode0=\count@
+ \ifnum\count@=32 %
+ \xdef\AllBytes{\AllBytes\space}%
+ \else
+ \lowercase{%
+ \xdef\AllBytes{\AllBytes^^@}%
+ }%
+ \fi
+ \advance\count@ by 1 %
+ }%
+\endgroup
+% \end{macrocode}
+% \begin{macrocode}
+\def\AllBytesHex{%
+ 000102030405060708090A0B0C0D0E0F%
+ 101112131415161718191A1B1C1D1E1F%
+ 202122232425262728292A2B2C2D2E2F%
+ 303132333435363738393A3B3C3D3E3F%
+ 404142434445464748494A4B4C4D4E4F%
+ 505152535455565758595A5B5C5D5E5F%
+ 606162636465666768696A6B6C6D6E6F%
+ 707172737475767778797A7B7C7D7E7F%
+ 808182838485868788898A8B8C8D8E8F%
+ 909192939495969798999A9B9C9D9E9F%
+ A0A1A2A3A4A5A6A7A8A9AAABACADAEAF%
+ B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF%
+ C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF%
+ D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF%
+ E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF%
+ F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF%
+}
+\ltx@onelevel@sanitize\AllBytesHex
+\expandafter\lowercase\expandafter{%
+ \expandafter\def\expandafter\AllBytesHexLC
+ \expandafter{\AllBytesHex}%
+}
+\begingroup
+ \catcode`\#=12 %
+ \xdef\AllBytesName{%
+ #01#02#03#04#05#06#07#08#09#0A#0B#0C#0D#0E#0F%
+ #10#11#12#13#14#15#16#17#18#19#1A#1B#1C#1D#1E#1F%
+ #20!"#23$#25&'#28#29*+,-.#2F%
+ 0123456789:;#3C=#3E?%
+ @ABCDEFGHIJKLMNO%
+ PQRSTUVWXYZ#5B\ltx@backslashchar#5D^_%
+ `abcdefghijklmno%
+ pqrstuvwxyz#7B|#7D\string~#7F%
+ #80#81#82#83#84#85#86#87#88#89#8A#8B#8C#8D#8E#8F%
+ #90#91#92#93#94#95#96#97#98#99#9A#9B#9C#9D#9E#9F%
+ #A0#A1#A2#A3#A4#A5#A6#A7#A8#A9#AA#AB#AC#AD#AE#AF%
+ #B0#B1#B2#B3#B4#B5#B6#B7#B8#B9#BA#BB#BC#BD#BE#BF%
+ #C0#C1#C2#C3#C4#C5#C6#C7#C8#C9#CA#CB#CC#CD#CE#CF%
+ #D0#D1#D2#D3#D4#D5#D6#D7#D8#D9#DA#DB#DC#DD#DE#DF%
+ #E0#E1#E2#E3#E4#E5#E6#E7#E8#E9#EA#EB#EC#ED#EE#EF%
+ #F0#F1#F2#F3#F4#F5#F6#F7#F8#F9#FA#FB#FC#FD#FE#FF%
+ }%
+\endgroup
+\ltx@onelevel@sanitize\AllBytesName
+\edef\AllBytesFromName{\expandafter\ltx@gobble\AllBytes}
+\begingroup
+ \def\|{|}%
+ \edef\%{\ltx@percentchar}%
+ \catcode`\|=0 %
+ \catcode`\#=12 %
+ \catcode`\~=12 %
+ \catcode`\\=12 %
+ |xdef|AllBytesString{%
+ \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017%
+ \020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037%
+ \040!"#$|%&'\(\)*+,-./%
+ 0123456789:;<=>?%
+ @ABCDEFGHIJKLMNO%
+ PQRSTUVWXYZ[\\]^_%
+ `abcdefghijklmno%
+ pqrstuvwxyz{||}~\177%
+ \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217%
+ \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237%
+ \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257%
+ \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277%
+ \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317%
+ \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337%
+ \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357%
+ \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377%
+ }%
+|endgroup
+\ltx@onelevel@sanitize\AllBytesString
+% \end{macrocode}
+% \begin{macrocode}
+\def\Test#1#2#3{%
+ \begingroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\TestResult
+ \expandafter\expandafter\expandafter{%
+ #1{#2}%
+ }%
+ \ifx\TestResult#3%
+ \else
+ \newlinechar=10 %
+ \msg{Expect:^^J#3}%
+ \msg{Result:^^J\TestResult}%
+ \errmessage{\string#2 -\string#1-> \string#3}%
+ \fi
+ \endgroup
+}
+\def\test#1#2#3{%
+ \edef\TestFrom{#2}%
+ \edef\TestExpect{#3}%
+ \ltx@onelevel@sanitize\TestExpect
+ \Test#1\TestFrom\TestExpect
+}
+\test\pdf@unescapehex{74657374}{test}
+\begingroup
+ \catcode0=12 %
+ \catcode1=12 %
+ \test\pdf@unescapehex{740074017400740174}{t^^@t^^At^^@t^^At}%
+\endgroup
+\Test\pdf@escapehex\AllBytes\AllBytesHex
+\Test\pdf@unescapehex\AllBytesHex\AllBytes
+\Test\pdf@escapename\AllBytes\AllBytesName
+\Test\pdf@escapestring\AllBytes\AllBytesString
+% \end{macrocode}
+% \begin{macrocode}
+\csname @@end\endcsname\end
+%</test-escape>
+% \end{macrocode}
+%
% \section{Installation}
%
% \subsection{Download}
@@ -1585,6 +2128,8 @@ end
% pdftexcmds.pdf & doc/latex/oberdiek/pdftexcmds.pdf\\
% test/pdftexcmds-test1.tex & doc/latex/oberdiek/test/pdftexcmds-test1.tex\\
% test/pdftexcmds-test2.tex & doc/latex/oberdiek/test/pdftexcmds-test2.tex\\
+% test/pdftexcmds-test-shell.tex & doc/latex/oberdiek/test/pdftexcmds-test-shell.tex\\
+% test/pdftexcmds-test-escape.tex & doc/latex/oberdiek/test/pdftexcmds-test-escape.tex\\
% pdftexcmds.dtx & source/latex/oberdiek/pdftexcmds.dtx\\
% \end{tabular}^^A
% }^^A
@@ -1748,6 +2293,31 @@ end
% Use \cs{ifeof18} for defining \cs{pdf@shellescape} between
% \hologo{pdfTeX} 1.21a (inclusive) and 1.30.0 (exclusive).
% \end{Version}
+% \begin{Version}{2010/11/04 v0.10}
+% \item
+% \cs{pdf@draftmode}, \cs{pdf@ifdraftmode} and
+% \cs{pdf@setdraftmode} added.
+% \end{Version}
+% \begin{Version}{2010/11/11 v0.11}
+% \item
+% Missing \cs{RequirePackage} for package \xpackage{ifpdf} added.
+% \end{Version}
+% \begin{Version}{2011/01/30 v0.12}
+% \item
+% Already loaded package files are not input in \hologo{plainTeX}.
+% \end{Version}
+% \begin{Version}{2011/03/04 v0.13}
+% \item
+% Improved Lua function \texttt{shellescape} that also
+% uses the result of \texttt{os.execute()} (thanks to Philipp Stephani).
+% \end{Version}
+% \begin{Version}{2011/04/10 v0.14}
+% \item
+% Version check of loaded module added.
+% \item
+% Patch for bug in \hologo{LuaTeX} between 0.40.6 and 0.65 that
+% is fixed in revision 4096.
+% \end{Version}
% \end{History}
%
% \PrintIndex