diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx | 823 |
1 files changed, 698 insertions, 125 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx b/Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx index 56419efe093..f68dd90b1aa 100644 --- a/Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/pdfescape.dtx @@ -71,7 +71,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: pdfescape 2007/04/11 v1.3 Provides hex, PDF name and string conversions (HO)} +\Msg{* Package: pdfescape 2007/04/21 v1.4 Provides hex, PDF name and string conversions (HO)} \Msg{************************************************************************} \keepsilent @@ -137,7 +137,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{pdfescape.drv}% - [2007/04/11 v1.3 Provides hex, PDF name and string conversions (HO)]% + [2007/04/21 v1.4 Provides hex, PDF name and string conversions (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -146,7 +146,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{1074} +% \CheckSum{1812} % % \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 @@ -167,7 +167,7 @@ and the derived files % \GetFileInfo{pdfescape.drv} % % \title{The \xpackage{pdfescape} package} -% \date{2007/04/11 v1.3} +% \date{2007/04/21 v1.4} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -193,7 +193,8 @@ and the derived files % Note that the argument \meta{string} is expanded before % the conversion. % -% For example, if \pdfTeX\ >= 1.30 is present, then \cs{EdefEscapeHex} +% For example, if \pdfTeX\ \textgreater= 1.30 is present, +% then \cs{EdefEscapeHex} % becomes to: % \begin{quote} %\begin{verbatim} @@ -210,6 +211,24 @@ and the derived files % The input strings may contain shorthand characters of package % \xpackage{babel}. % +% \subsection{Additional unescape macros} +% +% \begin{declcs}{EdefUnescapeName} \M{cmd} \M{string}\\ +% \end{declcs} +% Sequences of a hash sign with two hexadecimal digits are +% converted to the corresponding character (PDF-1.2). +% A hash sign that is not followed by two hexadecimal digits +% is left unchanged. The catcodes in the result string follow +% TeX's conventions. The space has catcode 10 (space) and +% the other characters have catcode 12 (other). +% +% \begin{declcs}{EdefUnescapeString} \M{cmd} \M{string}\\ +% \end{declcs} +% Macro \meta{cmd} stores the unescaped string in \meta{string}. +% All the rules for literal strings are implemented, see +% PDF specification. +% The catcodes in the result string follow TeX's conventions. +% % \StopEventually{ % } % @@ -219,10 +238,44 @@ and the derived files %<*package> % \end{macrocode} % +% \subsection{Catcodes} +% +% \begin{macrocode} +\expandafter\edef\csname PE@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\PE@EnsureCode#1#2#3{% + \edef\PE@AtEnd{% + \PE@AtEnd + #1#2 \the#1#2\relax + }% + #1#2 #3\relax +} +\PE@EnsureCode\catcode{0}{12}% ^^@ +\PE@EnsureCode\catcode{34}{12}% " +\PE@EnsureCode\catcode{42}{12}% * +\PE@EnsureCode\catcode{45}{12}% - +\PE@EnsureCode\catcode{46}{12}% . +\PE@EnsureCode\catcode{60}{12}% < +\PE@EnsureCode\catcode{61}{12}% = +\PE@EnsureCode\catcode{62}{12}% > +\PE@EnsureCode\catcode{94}{7}% ^ +\PE@EnsureCode\catcode{96}{12}% ` +\PE@EnsureCode\uccode{34}{0}% " +\PE@EnsureCode\uccode{48}{0}% 0 +\PE@EnsureCode\uccode{61}{0}% = +% \end{macrocode} +% % \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 % @ \expandafter\let\expandafter\x\csname ver@pdfescape.sty\endcsname \ifcase 0% \ifx\x\relax % plain @@ -249,6 +302,11 @@ and the derived files % Package identification: % \begin{macrocode} \begingroup + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode58 12 % : + \catcode64 11 % @ \expandafter\ifx\csname ProvidesPackage\endcsname\relax \def\x#1#2#3[#4]{\endgroup \immediate\write-1{Package: #3 #4}% @@ -264,41 +322,403 @@ and the derived files \fi \expandafter\x\csname ver@pdfescape.sty\endcsname \ProvidesPackage{pdfescape}% - [2007/04/11 v1.3 Provides hex, PDF name and string conversions (HO)] + [2007/04/21 v1.4 Provides hex, PDF name and string conversions (HO)] % \end{macrocode} % -% \subsection{Preparations} +% \subsection{Sanitizing} % -% \subsubsection{Catcodes} +% \begin{macro}{\PE@sanitize} +% Macro \cs{PE@sanitize} takes |#2|, entirely converts +% it to token with catcode 12 (other) and stores the +% result in macro |#1|. +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname detokenize\endcsname\relax + \long\def\PE@sanitize#1#2{% + \begingroup + \csname @safe@activestrue\endcsname + \edef#1{#2}% + \PE@onelevel@sanitize#1% + \expandafter\endgroup + \expandafter\def\expandafter#1\expandafter{#1}% + }% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname @onelevel@sanitize\endcsname\relax + \def\PE@onelevel@sanitize#1{% + \edef#1{\expandafter\PE@strip@prefix\meaning#1}% + }% + \def\PE@strip@prefix#1>{}% + \else + \let\PE@onelevel@sanitize\@onelevel@sanitize + \fi +\else + \long\def\PE@sanitize#1#2{% + \begingroup + \csname @safe@activestrue\endcsname + \edef#1{#2}% + \PE@onelevel@sanitize#1% + \expandafter\endgroup + \expandafter\def\expandafter#1\expandafter{#1}% + }% + \def\PE@onelevel@sanitize#1{% + \edef#1{\detokenize\expandafter{#1}}% + }% +\fi +% \end{macrocode} +% \end{macro} % +% \subsubsection{Space characters} +% +% \begin{macro}{\PE@space@other} % \begin{macrocode} -\expandafter\edef\csname PE@AtEnd\endcsname{% - \catcode64 \the\catcode64\relax +\begingroup + \catcode`\ =12\relax% +\def\x{\endgroup\def\PE@space@other{ }}\x\relax +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@space@space} +% \begin{macrocode} +\def\PE@space@space{ } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Space normalization} +% +% \begin{macro}{\PE@SanitizeSpaceOther} +% \begin{macrocode} +\def\PE@SanitizeSpaceOther#1{% + \edef#1{\expandafter\PE@SpaceToOther#1 \relax}% } -\catcode64 11 % @ -\def\PE@EnsureCode#1#2#3{% - \edef\PE@AtEnd{% - \PE@AtEnd - #1#2 \the#1#2\relax +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PE@SpaceToOther} +% \begin{macrocode} +\def\PE@SpaceToOther#1 #2\relax{% + #1% + \ifx\\#2\\% + \else + \PE@space@other + \@ReturnAfterFi{% + \PE@SpaceToOther#2\relax + }% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@ReturnAfterFi} +% \begin{macrocode} +\long\def\@ReturnAfterFi#1\fi{\fi#1} +% \end{macrocode} +% \end{macro} +% +% \subsection{\cs{EdefUnescapeName}} +% +% \begin{macro}{\EdefUnescapeName} +% \begin{macrocode} +\def\EdefUnescapeName#1#2{% + \PE@sanitize#1{#2}% + \PE@SanitizeSpaceOther#1% + \PE@UnescapeName#1% + \PE@onelevel@sanitize#1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PE@UnescapeName} +% \begin{macrocode} +\begingroup + \catcode`\$=6 % hash + \catcode`\#=12 % other + \gdef\PE@UnescapeName$1{% + \begingroup + \PE@InitUccodeHexDigit + \def\PE@result{}% + \expandafter\PE@DeName$1#\relax\relax + \expandafter\endgroup + \expandafter\def\expandafter$1\expandafter{\PE@result}% }% - #1#2 #3\relax + \gdef\PE@DeName$1#$2$3{% + \ifx\relax$2% + \edef\PE@result{\PE@result$1}% + \let\PE@next\relax + \else + \ifx\relax$3% + % wrong escape sequence in input + \edef\PE@result{\PE@result$1#}% + \let\PE@next\relax + \else + \uppercase{% + \def\PE@testA{$2}% + \def\PE@testB{$3}% + }% + \ifcase\ifcase\expandafter\PE@TestUcHexDigit\PE@testA + \ifcase\expandafter\PE@TestUcHexDigit\PE@testB + \z@ + \else + \@ne + \fi + \else + \@ne + \fi + \uccode\z@="\PE@testA\PE@testB\relax + \uppercase{% + \def\PE@temp{^^@}% + }% + \uccode\z@=\z@ + \edef\PE@result{\PE@result$1\PE@temp}% + \let\PE@next\PE@DeName + \else + % wrong escape sequence in input + \edef\PE@result{\PE@result$1#}% + \def\PE@next{\PE@DeName$2$3}% + \fi + \fi + \fi + \PE@next + }% +\endgroup +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PE@InitUccodeHexDigit} +% \begin{macrocode} +\def\PE@InitUccodeHexDigit{% + \uccode`a=`A\relax + \uccode`b=`B\relax + \uccode`c=`C\relax + \uccode`d=`D\relax + \uccode`e=`E\relax + \uccode`f=`F\relax + \uccode`A=\z@ + \uccode`B=\z@ + \uccode`C=\z@ + \uccode`D=\z@ + \uccode`E=\z@ + \uccode`F=\z@ + \uccode`0=\z@ + \uccode`1=\z@ + \uccode`2=\z@ + \uccode`3=\z@ + \uccode`4=\z@ + \uccode`5=\z@ + \uccode`6=\z@ + \uccode`7=\z@ + \uccode`8=\z@ + \uccode`9=\z@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PE@TestUcHexDigit} +% \begin{macrocode} +\def\PE@TestUcHexDigit#1{% + \ifnum`#1<48 % 0 + \@ne + \else + \ifnum`#1>70 % F + \@ne + \else + \ifnum`#1>57 % 9 + \ifnum`#1<65 % A + \@ne + \else + \z@ + \fi + \else + \z@ + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\cs{EdefUnescapeString}} +% +% \begin{macro}{\EdefUnescapeString} +% \begin{macrocode} +\def\EdefUnescapeString#1#2{% + \PE@sanitize#1{#2}% + \PE@SanitizeSpaceOther#1% + \PE@NormalizeLineEnd#1% + \PE@UnescapeString#1% + \PE@onelevel@sanitize#1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\begingroup + \uccode`\8=10 % lf + \uccode`\9=13 % cr +\def\x#1#2{\endgroup +% \end{macrocode} +% \begin{macro}{\PE@NormalizeLineEnd} +% \begin{macrocode} + \def\PE@NormalizeLineEnd##1{% + \def\PE@result{}% + \expandafter\PE@@NormalizeLineEnd##1#2\relax + \let##1\PE@result + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@@NormalizeLineEnd} +% \begin{macrocode} + \def\PE@@NormalizeLineEnd##1#2##2{% + \ifx\relax##2% + \edef\PE@result{\PE@result##1}% + \let\PE@next\relax + \else + \edef\PE@result{\PE@result##1#1}% + \ifx#1##2% lf + \let\PE@next\PE@@NormalizeLineEnd + \else + \def\PE@next{\PE@@NormalizeLineEnd##2}% + \fi + \fi + \PE@next + }% +}% +\uppercase{% + \x 89% } -\PE@EnsureCode\catcode{0}{12}% ^^@ -\PE@EnsureCode\catcode{34}{12}% " -\PE@EnsureCode\catcode{42}{12}% * -\PE@EnsureCode\catcode{45}{12}% - -\PE@EnsureCode\catcode{46}{12}% . -\PE@EnsureCode\catcode{60}{12}% < -\PE@EnsureCode\catcode{61}{12}% = -\PE@EnsureCode\catcode{62}{12}% > -\PE@EnsureCode\catcode{94}{7}% ^ -\PE@EnsureCode\catcode{96}{12}% ` -\PE@EnsureCode\uccode{34}{0}% " -\PE@EnsureCode\uccode{48}{0}% 0 -\PE@EnsureCode\uccode{61}{0}% = % \end{macrocode} +% \end{macro} % -% \subsection{User macros} +% \begin{macrocode} +\begingroup + \catcode`\|=0 % + \catcode`\\=12 % +% \end{macrocode} +% \begin{macro}{\PE@UnescapeString} +% \begin{macrocode} + |gdef|PE@UnescapeString#1{% + |begingroup + |def|PE@result{}% + |expandafter|PE@DeString#1\|relax + |expandafter|endgroup + |expandafter|def|expandafter#1|expandafter{|PE@result}% + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@DeString} +% \begin{macrocode} + |gdef|PE@DeString#1\#2{% + |ifx|relax#2% + |edef|PE@result{|PE@result#1}% + |let|PE@next|relax + |else + |if n#2% + |uccode|z@=10 % + |else|if r#2% + |uccode|z@=13 % + |else|if t#2% + |uccode|z@=9 % + |else|if b#2% + |uccode|z@=8 % + |else|if f#2% + |uccode|z@=12 % + |else + |uccode|z@=|z@ + |fi|fi|fi|fi|fi + |ifnum|uccode|z@>|z@ + |uppercase{% + |edef|PE@temp{^^@}% + }% + |edef|PE@result{|PE@result#1|PE@temp}% + |let|PE@next|PE@DeString + |else + |if\#2% backslash + |edef|PE@result{|PE@result#1}% + |let|PE@next|PE@CheckEndBackslash + |else + |ifnum`#2=10 % linefeed + |edef|PE@result{|PE@result#1}% + |let|PE@next|PE@DeString + |else + |ifcase|PE@TestOctDigit#2% + |edef|PE@result{|PE@result#1}% + |def|PE@next{|PE@OctI#2}% + |else + |edef|PE@result{|PE@result#1#2}% + |let|PE@next|PE@DeString + |fi + |fi + |fi + |fi + |fi + |PE@next + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@CheckEndBackslash} +% \begin{macrocode} + |gdef|PE@CheckEndBackslash#1{% + |ifx|relax#1% + |else + |edef|PE@result{|PE@result\}% + |expandafter|PE@DeString|expandafter#1% + |fi + }% +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +|endgroup +% \end{macrocode} +% \begin{macro}{\PE@TestOctDigit} +% \begin{macrocode} +\def\PE@TestOctDigit#1{% + \ifnum`#1<48 % 0 + \@ne + \else + \ifnum`#1>55 % 7 + \@ne + \else + \z@ + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@OctI} +% \begin{macrocode} +\def\PE@OctI#1#2{% + \ifcase\PE@TestOctDigit#2% + \def\PE@next{\PE@OctII{#1#2}}% + \else + \def\PE@next{\PE@OctAll#1#2}% + \fi + \PE@next +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@OctII} +% \begin{macrocode} +\def\PE@OctII#1#2{% + \ifcase\PE@TestOctDigit#2% + \def\PE@next{\PE@OctAll{#1#2}}% + \else + \def\PE@next{\PE@OctAll{#1}#2}% + \fi + \PE@next +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\PE@OctAll} +% \begin{macrocode} +\def\PE@OctAll#1{% + \uccode\z@='#1\relax + \uppercase{% + \edef\PE@result{\PE@result^^@}% + }% + \PE@DeString +} +% \end{macrocode} +% \end{macro} +% +% \subsection{User macros (\pdfTeX\space analogues)} % % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup @@ -309,7 +729,7 @@ and the derived files % \begin{macrocode} \long\def\EdefEscapeHex#1#2{% \PE@sanitize#1{#2}% - \edef#1{\expandafter\PE@SpaceToOther#1 \relax}% + \PE@SanitizeSpaceOther#1% \PE@EscapeHex#1% }% % \end{macrocode} @@ -326,7 +746,7 @@ and the derived files % \begin{macrocode} \long\def\EdefEscapeName#1#2{% \PE@sanitize#1{#2}% - \edef#1{\expandafter\PE@SpaceToOther#1 \relax}% + \PE@SanitizeSpaceOther#1% \PE@EscapeName#1% }% % \end{macrocode} @@ -335,7 +755,7 @@ and the derived files % \begin{macrocode} \long\def\EdefEscapeString#1#2{% \PE@sanitize#1{#2}% - \edef#1{\expandafter\PE@SpaceToOther#1 \relax}% + \PE@SanitizeSpaceOther#1% \PE@EscapeString#1% }% % \end{macrocode} @@ -349,13 +769,13 @@ and the derived files % Help macro that adds support for \xpackage{babel}'s shorthand % characters. % \begin{macrocode} -\long\def\PE@edefbabel#1#2#3{% - \begingroup - \csname @save@activestrue\endcsname - \edef#1{#2{#3}}% - \expandafter\endgroup - \expandafter\def\expandafter#1\expandafter{#1}% -} + \long\def\PE@edefbabel#1#2#3{% + \begingroup + \csname @save@activestrue\endcsname + \edef#1{#2{#3}}% + \expandafter\endgroup + \expandafter\def\expandafter#1\expandafter{#1}% + }% % \end{macrocode} % \end{macro} % @@ -405,25 +825,12 @@ and the derived files \edef\PE@hash{\string#} % \end{macrocode} % \end{macro} -% \begin{macro}{\PE@space@other} -% \begin{macrocode} -\begingroup - \catcode`\ =12\relax% -\def\x{\endgroup\def\PE@space@other{ }}\x\relax -% \end{macrocode} -% \end{macro} -% \begin{macro}{\PE@space@space} -% \begin{macrocode} -\def\PE@space@space{ } -% \end{macrocode} -% \end{macro} % \begin{macro}{\PE@backslash} % \begin{macrocode} \begingroup - \long\def\@gobble#1{}% - \escapechar=92 % + \escapechar=-1 % \edef\x{\endgroup - \def\noexpand\PE@backslash{\expandafter\@gobble\string\\}% + \def\noexpand\PE@backslash{\string\\}% } \x % \end{macrocode} @@ -440,66 +847,6 @@ and the derived files \fi % \end{macrocode} % -% \subsection{Sanitizing} -% -% \begin{macro}{\PE@sanitize} -% Macro \cs{PE@sanitize} takes |#2|, entirely converts -% it to token with catcode 12 (other) and stores the -% result in macro |#1|. -% \begin{macrocode} -\begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname detokenize\endcsname\relax - \long\def\PE@sanitize#1#2{% - \begingroup - \csname @safe@activestrue\endcsname - \edef#1{#2}% - \PE@onelevel@sanitize#1% - \expandafter\endgroup - \expandafter\def\expandafter#1\expandafter{#1}% - }% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname @onelevel@sanitize\endcsname\relax - \def\PE@onelevel@sanitize#1{% - \edef#1{\expandafter\PE@strip@prefix\meaning#1}% - }% - \def\PE@strip@prefix#1>{}% - \else - \let\PE@onelevel@sanitize\@onelevel@sanitize - \fi -\else - \long\def\PE@sanitize#1#2{% - \begingroup - \csname @safe@activestrue\endcsname - \edef#1{#2}% - \edef#1{\detokenize\expandafter{#1}}% - \expandafter\endgroup - \expandafter\def\expandafter#1\expandafter{#1}% - }% -\fi -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\PE@SpaceToOther} -% \begin{macrocode} -\def\PE@SpaceToOther#1 #2\relax{% - #1% - \ifx\\#2\\% - \else - \PE@space@other - \@ReturnAfterFi{% - \PE@SpaceToOther#2\relax - }% - \fi -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@ReturnAfterFi} -% \begin{macrocode} -\long\def\@ReturnAfterFi#1\fi{\fi#1} -% \end{macrocode} -% \end{macro} -% % \subsection{Conversions} % % \subsubsection{Conversion to hex string} @@ -610,6 +957,7 @@ and the derived files % \begin{macrocode} \def\PE@UnescapeHex#1{% \begingroup + \PE@InitUccodeHexDigit \def\PE@result{}% \expandafter\PE@DeHex#1\relax\relax \expandafter\endgroup @@ -622,19 +970,48 @@ and the derived files \def\PE@DeHex#1#2{% \ifx#2\relax \ifx#1\relax + \let\PE@next\relax \else - \PE@DeHex#10\relax\relax + \uppercase{% + \def\PE@testA{#1}% + }% + \ifcase\expandafter\PE@TestUcHexDigit\PE@testA + \def\PE@next{% + \PE@DeHex#10\relax\relax + }% + \else + \let\PE@next\relax + \fi \fi \else - \uppercase{\lccode0="#1#2}\relax - \ifnum\lccode0=32 % - \edef\PE@result{\PE@result\PE@space@space}% + \uppercase{% + \def\PE@testA{#1}% + \def\PE@testB{#2}% + }% + \ifcase\expandafter\PE@TestUcHexDigit\PE@testA + \ifcase\expandafter\PE@TestUcHexDigit\PE@testB + \uccode\z@="\PE@testA\PE@testB\relax + \ifnum\uccode\z@=32 % + \let\PE@temp\PE@space@space + \else + \uppercase{% + \def\PE@temp{^^@}% + }% + \fi + \edef\PE@result{\PE@result\PE@temp}% + \let\PE@next\PE@DeHex + \else + % invalid input sequence + \def\PE@next{% + \PE@DeHex#1% + }% + \fi \else - \lowercase{\def\PE@temp{^^@}}% - \edef\PE@result{\PE@result\PE@temp}% + % invalid input sequence + \def\PE@next{\PE@DeHex#2}% \fi - \expandafter\PE@DeHex \fi + \PE@next } % \end{macrocode} % \end{macro} @@ -789,7 +1166,7 @@ and the derived files % \begin{macrocode} %<*test1> \ProvidesFile{pdfescape-test1.tex}% - [2007/04/11 v1.3 Test with \string\pdfescape... commands]% + [2007/04/21 v1.4 Test with \string\pdfescape... commands]% %</test1> % \end{macrocode} % @@ -798,7 +1175,7 @@ and the derived files % \begin{macrocode} %<*test2> \ProvidesFile{pdfescape-test2.tex}% - [2007/04/11 v1.3 Test without \string\pdfescape..., with e-TeX]% + [2007/04/21 v1.4 Test without \string\pdfescape..., with e-TeX]% %</test2> % \end{macrocode} % @@ -807,7 +1184,7 @@ and the derived files % \begin{macrocode} %<*test3> \ProvidesFile{pdfescape-test3.tex}% - [2007/04/11 v1.3 Test without \string\pdfescape... and e-TeX]% + [2007/04/21 v1.4 Test without \string\pdfescape... and e-TeX]% %</test3> % \end{macrocode} % @@ -859,6 +1236,14 @@ and the derived files \LogTests{lgout}{*}{*} \newcommand*{\ExpectVar}[2]{% + \ifx#1#2% + \else + \begingroup + \@onelevel@sanitize#1% + \@onelevel@sanitize#2% + \typeout{[#1] <> [#2]}% + \endgroup + \fi \Expect*{\ifx#1#2true\else false\fi}{true}% } @@ -1005,6 +1390,42 @@ and the derived files \ExpectVar\x\z \end{qstest} +\begin{qstest}{unhex-hash}{unescapehex, hash} + \catcode`\#=12 % + \EdefUnescapeHex\x{#20}% + \ExpectVar\x\space +\end{qstest} + +\begin{qstest}{unhex-invalid}{unescapehex, invalid} + \def\test#1#2{% + \EdefUnescapeHex\x{#1}% + \edef\y{#2}% + \@onelevel@sanitize\y + \ExpectVar\x\y + }% +%<*test1> + \edef\x{\pdfunescapehex{4X}}% + \edef\y{\string @}% + \ifx\x\y + \else + \def~{\space}% + \typeout{************************************}% + \typeout{* Your pdfTeX contains bug 777.~~~~*}% + \typeout{* This test is redefined as dummy, *}% + \typeout{* because it triggers the bug.~~~~~*}% + \typeout{************************************}% + \def\test#1#2{}% + \fi +%</test1> + \test{X}{}% + \test{XY}{}% + \test{XYZ}{}% + \test{A}{^^a0}% + \test{AX}{^^a0}% + \test{XA}{^^a0}% + \test{XXAXX}{^^a0}% +\end{qstest} + \begin{qstest}{all-name}{\AllBytes, escapename} \EdefEscapeName\x{\AllBytes}% \Expect*{\x}*{\AllBytesName}% @@ -1017,6 +1438,154 @@ and the derived files \ExpectVar\x\AllBytesString \end{qstest} +\begin{qstest}{uchexdigit}{unescape, uppercase hex digit} + \catcode`\@=11 % + \catcode0=12 % + \def\test#1#2{% + \uccode0=#1\relax + \uppercase{% + \def\x{^^@}% + }% + \Expect*{% + \ifcase\expandafter\PE@TestUcHexDigit\x + true% + \else + false% + \fi + }{#2}% + }% + \def\range#1#2#3{% + \count0=#1\relax + \loop + \ifnum\count0<#2\relax + \test{\count0}{#3}% + \advance\count0 by 1 % + \repeat + }% + \range{0}{47}{false}% + \range{48}{57}{true}% + \range{58}{64}{false}% + \range{65}{70}{true}% + \range{71}{255}{false}% +\end{qstest} + +\begin{qstest}{unescapename}{unescapename} + \def\test#1#2{% + \EdefUnescapeName\x{#1}% + \edef\y{#2}% + \@onelevel@sanitize\y + \ExpectVar\x\y + }% + \catcode`\#=12 % + \catcode0=12 % + \test{}{}% + \test{x}{x}% + \test{xy}{xy}% + \test{#}{#}% + \test{##}{##}% + \test{###}{###}% + \test{####}{####}% + \test{#x}{#x}% + \test{#xy}{#xy}% + \test{#1}{#1}% + \test{#40}{@}% + \test{#400}{@0}% + \test{#4x0}{#4x0}% + \test{#ab}{^^ab}% + \test{#00}{^^@}% + \test{x#40y#40z}{x@y@z}% + \test{#40#40#40#40}{@@@@}% + \test{a#x}{a#x}% + \test{a#xy}{a#xy}% + \test{a#1}{a#1}% + \test{a#40}{a@}% + \test{a#400}{a@0}% + \test{#20}{ }% + \test{a#20}{a }% + \test{a#20b}{a b}% + \test{a#20#20#20b}{a \space\space b}% +\end{qstest} + +\begin{qstest}{unescapestring}{unescapestring} + \def\test#1#2{% + \EdefUnescapeString\x{#1}% + \edef\y{#2}% + \@onelevel@sanitize\y + \ExpectVar\x\y + }% + \catcode0=12 % + \def\DefChar#1#2{% + \begingroup + \uccode0=#2\relax + \uppercase{\endgroup + \def#1{^^@}% + }% + }% + \DefChar\nul{0}% + \DefChar\one{1}% + \DefChar\bel{8}% + \DefChar\tab{9}% + \DefChar\lf{10}% + \DefChar\ff{12}% + \DefChar\cr{13}% + \DefChar\\{92}% + \test{}{}% + \test{a}{a}% + \test{\\}{}% + \test{\\\\}{\\}% + \test{\\\\y}{\\y}% + \test{\\000}{\nul}% + \test{\\b}{\bel}% + \test{\\t}{\tab}% + \test{\\n}{\lf}% + \test{\\f}{\ff}% + \test{\\r}{\cr}% + \test{\\(}{(}% + \test{\\)}{)}% + \test{\\040}{ }% + \test{\\100}{@}% + \test{\\40}{ }% + \test{\\1}{\one}% + \test{\\01}{\one}% + \test{\\001}{\one}% + \test{\\18}{\one8}% + \test{\\018}{\one8}% + \test{\\0018}{\one8}% + \test{x\\}{x}% + \test{x\\\\}{x\\}% + \test{x\\\\y}{x\\y}% + \test{x\\000}{x\nul}% + \test{x\\b}{x\bel}% + \test{x\\t}{x\tab}% + \test{x\\n}{x\lf}% + \test{x\\f}{x\ff}% + \test{x\\r}{x\cr}% + \test{x\\(}{x(}% + \test{x\\)}{x)}% + \test{x\\040}{x }% + \test{x\\100}{x@}% + \test{x\\40}{x }% + \test{x\\1}{x\one}% + \test{x\\01}{x\one}% + \test{x\\001}{x\one}% + \test{x\\18}{x\one8}% + \test{x\\018}{x\one8}% + \test{x\\0018}{x\one8}% + \test{\\b\\t\\n\\f\\r\\(\\)\\\\\\000\\040}{% + \bel\tab\lf\ff\cr()\\\nul\space + }% + \test{\\\lf}{}% + \test{x\\\lf}{x}% + \test{\cr}{\lf}% + \test{\cr\lf}{\lf}% + \test{\lf}{\lf}% + \test{\lf\cr}{\lf\lf}% + \test{x\cr}{x\lf}% + \test{x\cr\lf}{x\lf}% + \test{x\lf}{x\lf}% + \test{x\lf\cr}{x\lf\lf}% + \test{x\\\cr\lf y\cr}{xy\lf}% +\end{qstest} \stop % \end{macrocode} % @@ -1184,6 +1753,10 @@ and the derived files % \item % Line ends sanitized. % \end{Version} +% \begin{Version}{2007/04/21 v1.4} +% \item +% \cs{EdefUnescapeName} and \cs{EdefUnescapeString} added. +% \end{Version} % \end{History} % % \PrintIndex |