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.dtx219
1 files changed, 203 insertions, 16 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx b/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
index 85b7968861c..4d1c09c4b5d 100644
--- a/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
+++ b/Master/texmf-dist/source/latex/oberdiek/pdftexcmds.dtx
@@ -69,7 +69,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: pdftexcmds 2009/04/10 v0.4 LuaTeX support for pdfTeX utility functions (HO)}
+\Msg{* Package: pdftexcmds 2009/09/22 v0.5 LuaTeX support for pdfTeX utility functions (HO)}
\Msg{************************************************************************}
\keepsilent
@@ -147,7 +147,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{pdftexcmds.drv}%
- [2009/04/10 v0.4 LuaTeX support for pdfTeX utility functions (HO)]%
+ [2009/09/22 v0.5 LuaTeX support for pdfTeX utility functions (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\usepackage{paralist}
@@ -157,7 +157,7 @@ and the derived files
%</driver>
% \fi
%
-% \CheckSum{571}
+% \CheckSum{752}
%
% \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
@@ -178,7 +178,7 @@ and the derived files
% \GetFileInfo{pdftexcmds.drv}
%
% \title{The \xpackage{pdftexcmds} package}
-% \date{2009/04/10 v0.4}
+% \date{2009/09/22 v0.5}
% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}}
%
% \maketitle
@@ -191,6 +191,8 @@ and the derived files
%
% \tableofcontents
%
+% \def\csi#1{\texttt{\textbackslash\textit{#1}}}
+%
% \section{Documentation}
%
% Some primitives of \pdfTeX\ are not defined by \LuaTeX.
@@ -225,8 +227,9 @@ and the derived files
% macro expansion. Example:
% \begin{quote}
% |\expandafter\foo\pdffilemoddate{file}|\\
-% vs.
-% |\expandafter\expandafter\expandafter\foo\pdf@filemoddate{file}|.
+% vs.\\
+% |\expandafter\expandafter\expandafter|\\
+% |\foo\pdf@filemoddate{file}|
% \end{quote}
% \end{itemize}
%
@@ -247,10 +250,16 @@ and the derived files
% The macro |\pdf@|\meta{cmd} is expandable if the
% corresponding \pdfTeX\ primitive has this property.
% Exact two expansion steps are necessary (first is the macro
-% expansion).
+% expansion) except for \cs{pdf@primitive} and \cs{pdf@ifprimitive}.
+% The latter ones are not macros, but have the direct meaning of the
+% primitive.
% \item[Without \LuaTeX:]
% The macros |\pdf@|\meta{cmd} are mapped to the commands
% of \pdfTeX\ if they are available. Otherwise they are undefined.
+% \item[Availability:]
+% The macros that the packages provides are undefined, if
+% the necessary primitives are not found and cannot be
+% implemented by Lua.
% \end{description}
%
% \subsection{Macros}
@@ -317,6 +326,18 @@ and the derived files
% Does it make sense to provide an user interface to
% this status exit code?
%
+% \begin{declcs}{pdf@primitive} \csi{cmd}
+% \end{declcs}
+% Same as \cs{pdfprimitive} in \pdfTeX\ or \LuaTeX. In \XeTeX\ the
+% primitive is called \cs{primitive}. Despite the current definition
+% of the command \csi{cmd}, it's meaning as primitive is used.
+%
+% \begin{declcs}{pdf@ifprimitive} \csi{cmd}
+% \end{declcs}
+% Same as \cs{ifpdfprimitive} in \pdfTeX\ or \LuaTeX. \XeTeX\ calls
+% it \cs{ifprimitive}. It is a switch that checks if the command
+% \csi{cmd} has it's primitive meaning.
+%
% \subsubsection{Experimental}
%
% \begin{declcs}{pdf@unescapehexnative} \M{string}\\
@@ -414,7 +435,7 @@ and the derived files
\fi
\expandafter\x\csname ver@pdftexcmds.sty\endcsname
\ProvidesPackage{pdftexcmds}%
- [2009/04/10 v0.4 LuaTeX support for pdfTeX utility functions (HO)]
+ [2009/09/22 v0.5 LuaTeX support for pdfTeX utility functions (HO)]
% \end{macrocode}
%
% \subsection{Catcodes}
@@ -463,6 +484,11 @@ and the derived files
\TMP@EnsureCode{95}{12}% _ (other)
\TMP@EnsureCode{96}{12}% `
\TMP@EnsureCode{126}{12}% ~ (other)
+\edef\pdftexcmds@AtEnd{%
+ \pdftexcmds@AtEnd
+ \escapechar=\number\escapechar\relax
+}
+\escapechar=92 %
% \end{macrocode}
%
% \subsection{Load package \xpackage{infwarerr}}
@@ -483,7 +509,7 @@ and the derived files
% \begin{macrocode}
\ifluatex
\else
- \@PackageInfo{pdftexcmds}{LuaTeX not detected}%
+ \@PackageInfoNoLine{pdftexcmds}{LuaTeX not detected}%
\def\pdftexcmds@nopdftex{%
\@PackageInfoNoLine{pdftexcmds}{pdfTeX >= 1.30 not detected}%
\let\pdftexcmds@nopdftex\relax
@@ -535,22 +561,175 @@ and the derived files
\def\pdf@system#{%
\immediate\write18%
}%
- \pdftexcmds@AtEnd
- \expandafter\endinput
\fi
% \end{macrocode}
%
+% \subsection{\cs{pdf@primitive}, \cs{pdf@ifprimitive}}
+%
+% Since version 1.40.0 \pdfTeX\ has \cs{pdfprimitive} and
+% \cs{ifpdfprimitive}. And \cs{pdfprimitive} was fixed in
+% version 1.40.4.
+%
+% \XeTeX\ provides them under the name \cs{primitive} and
+% \cs{ifprimitive}. \LuaTeX\ knows both name variants,
+% but they have possibly to be enabled first (|tex.enableprimitives|).
+%
+% Depending on the format TeX Live uses a prefix |luatex|.
+%
+% Caution: \cs{let} must be used for the definition of
+% the macros, especially because of \cs{ifpdfprimitive}.
+%
+% \subsubsection{Using \LuaTeX's \texttt{tex.enableprimitives}}
+%
+% \begin{macrocode}
+\ifluatex
+% \end{macrocode}
% \begin{macro}{\pdftexcmds@directlua}
% \begin{macrocode}
-\ifnum\luatexversion<36 %
- \def\pdftexcmds@directlua{\directlua0 }%
-\else
- \let\pdftexcmds@directlua\directlua
+ \ifnum\luatexversion<36 %
+ \def\pdftexcmds@directlua{\directlua0 }%
+ \else
+ \let\pdftexcmds@directlua\directlua
+ \fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+ \begingroup
+ \newlinechar=10 %
+ \endlinechar=\newlinechar
+ \pdftexcmds@directlua{%
+ if tex.enableprimitives then
+ tex.enableprimitives('pdf@', {'primitive', 'ifprimitive'})
+ end
+ }%
+ \endgroup %
+% \end{macrocode}
+%
+% \begin{macrocode}
\fi
% \end{macrocode}
+%
+% \subsubsection{Trying various names to find the primitives}
+%
+% \begin{macro}{\pdftexcmds@strip@prefix}
+% \begin{macrocode}
+\def\pdftexcmds@strip@prefix#1>{}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\def\pdftexcmds@temp#1#2#3{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname pdf@#1\endcsname\relax
+ \begingroup
+ \def\x{#3}%
+ \edef\x{\expandafter\pdftexcmds@strip@prefix\meaning\x}%
+ \escapechar=-1 %
+ \edef\y{\expandafter\meaning\csname#2\endcsname}%
+ \expandafter\endgroup
+ \ifx\x\y
+ \expandafter\let\csname pdf@#1\expandafter\endcsname
+ \csname #2\endcsname
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macro}{\pdf@primitive}
+% \begin{macrocode}
+\pdftexcmds@temp{primitive}{pdfprimitive}{pdfprimitive}% pdfTeX, LuaTeX
+\pdftexcmds@temp{primitive}{primitive}{primitive}% XeTeX
+\pdftexcmds@temp{primitive}{luatexprimitive}{pdfprimitive}% LuaTeX
+\pdftexcmds@temp{primitive}{luatexpdfprimitive}{pdfprimitive}% LuaTeX
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\pdf@ifprimitive}
+% \begin{macrocode}
+\pdftexcmds@temp{ifprimitive}{ifpdfprimitive}{ifpdfprimitive}% pdfTeX, LuaTeX
+\pdftexcmds@temp{ifprimitive}{ifprimitive}{ifprimitive}% XeTeX
+\pdftexcmds@temp{ifprimitive}{luatexifprimitive}{ifpdfprimitive}% LuaTeX
+\pdftexcmds@temp{ifprimitive}{luatexifpdfprimitive}{ifpdfprimitive}% LuaTeX
+% \end{macrocode}
% \end{macro}
%
-% \subsection{Load module}
+% Disable broken \cs{pdfprimitive}.
+% \begin{macrocode}
+\begingroup
+ \expandafter\ifx\csname pdf@primitive\endcsname\relax
+ \else
+ \expandafter\ifx\csname pdftexversion\endcsname\relax
+ \else
+ \ifnum\pdftexversion=140 %
+ \expandafter\ifx\csname pdftexrevision\endcsname\relax
+ \else
+ \ifnum\pdftexrevision<4 %
+ \endgroup
+ \let\pdf@primitive\@undefined
+ \@PackageInfoNoLine{pdftexcmds}{%
+ \string\pdf@primitive disabled, because\MessageBreak
+ \string\pdfprimitive\space is broken until pdfTeX 1.40.4%
+ }%
+ \begingroup
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+\endgroup
+% \end{macrocode}
+%
+% \subsubsection{Result}
+%
+% \begin{macrocode}
+\begingroup
+ \@PackageInfoNoLine{pdftexcmds}{%
+ \string\pdf@primitive\space is %
+ \expandafter\ifx\csname pdf@primitive\endcsname\relax not \fi
+ available%
+ }%
+ \@PackageInfoNoLine{pdftexcmds}{%
+ \string\pdf@ifprimitive\space is %
+ \expandafter\ifx\csname pdf@ifprimitive\endcsname\relax not \fi
+ available%
+ }%
+\endgroup
+% \end{macrocode}
+%
+% \subsection{Xe\TeX}
+%
+% Look for primitives \cs{shellescape}, \cs{strcmp}.
+% \begin{macrocode}
+\def\pdftexcmds@temp#1{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname pdf@#1\endcsname\relax
+ \begingroup
+ \escapechar=-1 %
+ \edef\x{\expandafter\meaning\csname#1\endcsname}%
+ \def\y{#1}%
+ \def\z##1->{}%
+ \edef\y{\expandafter\z\meaning\y}%
+ \expandafter\endgroup
+ \ifx\x\y
+ \expandafter\def\csname pdf@#1\expandafter\endcsname
+ \expandafter{%
+ \csname#1\endcsname
+ }%
+ \fi
+ \fi
+}%
+\pdftexcmds@temp{shellescape}%
+\pdftexcmds@temp{strcmp}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ifluatex
+\else
+ \pdftexcmds@AtEnd
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \subsection{Load Lua module}
%
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
@@ -1377,6 +1556,14 @@ end
% Adaptation for syntax change of \cs{directlua} in
% \LuaTeX\ 0.36.
% \end{Version}
+% \begin{Version}{2009/09/22 v0.5}
+% \item
+% \cs{pdf@primitive}, \cs{pdf@ifprimitive} added.
+% \item
+% \XeTeX's variants are detected for
+% \cs{pdf@shellescape}, \cs{pdf@strcmp}, \cs{pdf@primitive},
+% \cs{pdf@ifprimitive}.
+% \end{Version}
% \end{History}
%
% \PrintIndex