diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/catchfile.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/catchfile.dtx | 171 |
1 files changed, 110 insertions, 61 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/catchfile.dtx b/Master/texmf-dist/source/latex/oberdiek/catchfile.dtx index 5e50a738477..7c5efdb0b08 100644 --- a/Master/texmf-dist/source/latex/oberdiek/catchfile.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/catchfile.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2007, 2010 by +% Copyright (C) 2007, 2010, 2011 by % Heiko Oberdiek <heiko.oberdiek at googlemail.com> % % This work may be distributed and/or modified under the @@ -79,7 +79,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: catchfile 2010/04/28 v1.5 Catches the contents of a file (HO)} +\Msg{* Package: catchfile 2011/03/01 v1.6 Catches the contents of a file (HO)} \Msg{************************************************************************} \keepsilent @@ -90,7 +90,7 @@ This is a generated file. -Copyright (C) 2007, 2010 by +Copyright (C) 2007, 2010, 2011 by Heiko Oberdiek <heiko.oberdiek at googlemail.com> This work may be distributed and/or modified under the @@ -158,7 +158,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{catchfile.drv}% - [2010/04/28 v1.5 Catches the contents of a file (HO)]% + [2011/03/01 v1.6 Catches the contents of a file (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc}[2008/08/11] \begin{document} @@ -167,7 +167,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{833} +% \CheckSum{907} % % \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 @@ -188,7 +188,7 @@ and the derived files % \GetFileInfo{catchfile.drv} % % \title{The \xpackage{catchfile} package} -% \date{2010/04/28 v1.5} +% \date{2011/03/01 v1.6} % \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}} % % \maketitle @@ -228,14 +228,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@catchfile.sty\endcsname \ifx\x\relax % plain-TeX, first loading \else @@ -243,7 +247,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.}% @@ -255,24 +258,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}% @@ -291,42 +297,53 @@ and the derived files \fi \expandafter\x\csname ver@catchfile.sty\endcsname \ProvidesPackage{catchfile}% - [2010/04/28 v1.5 Catches the contents of a file (HO)] + [2011/03/01 v1.6 Catches the contents of a file (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 CatchFile@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\CatchFile@AtEnd{% \CatchFile@AtEnd - \catcode#1 \the\catcode#1\relax + \catcode#1=\the\catcode#1\relax }% - \catcode#1 #2\relax + \catcode#1=#2\relax } \TMP@EnsureCode{39}{12}% ' \TMP@EnsureCode{44}{12}% , \TMP@EnsureCode{45}{12}% - \TMP@EnsureCode{46}{12}% . \TMP@EnsureCode{47}{12}% / -\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{91}{12}% [ +\TMP@EnsureCode{93}{12}% ] \TMP@EnsureCode{96}{12}% ` +\edef\CatchFile@AtEnd{\CatchFile@AtEnd\noexpand\endinput} % \end{macrocode} % % \subsection{Preparations} @@ -355,9 +372,8 @@ and the derived files package loading is aborted% }\@ehd \endgroup - \CatchFile@AtEnd - \expandafter\endinput - \fi + \expandafter\CatchFile@AtEnd + \fi% \endgroup % \end{macrocode} % @@ -394,8 +410,7 @@ and the derived files package loading is aborted% }\@ehd \csname endgroup\endcsname - \CatchFile@AtEnd - \endinput + \CatchFile@AtEnd% \endgroup % \end{macrocode} % \end{macro} @@ -525,12 +540,19 @@ and the derived files }% }% }% - #3% + #3\relax \expandafter\expandafter\expandafter\CatchFile@Do \CatchFile@Input\CatchFile@File\relax \fi } % \end{macrocode} +% \cs{relax} after |#3| was added to make it more robust in +% case the user uses something like +%\begin{verbatim} +%\CatchFileDef{\content}{\jobname.tt}{\endlinechar=-1} +%\end{verbatim} +% that expands the following \cs{expandafter} after |#3| prematurely +% (contribution of Martin Scharrer). % \end{macro} % \begin{macro}{\CatchFile@EOF} % If the file is read the catcode mappings are fixed. @@ -551,7 +573,7 @@ and the derived files % \end{macro} % % \begin{macrocode} -\CatchFile@AtEnd +\CatchFile@AtEnd% %</package> % \end{macrocode} % @@ -615,6 +637,22 @@ and the derived files \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 catchfile.sty\relax}% \fi @@ -625,15 +663,20 @@ and the derived files \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 @@ -653,7 +696,7 @@ and the derived files \listfiles \tracingnesting=2 % \documentclass{minimal} -\usepackage{catchfile}[2010/04/28] +\usepackage{catchfile}[2011/03/01] \makeatletter \def\mysetup{% \let\do\@makeother @@ -1047,6 +1090,12 @@ and the derived files % definition of \dots' (HO) including improvement that uses % \cs{unexpanded} if available (Florent Chervet). % \end{Version} +% \begin{Version}{2011/03/01 v1.6} +% \item +% \cs{relax} added after the setup argument of +% \cs{CatchFileDef} to prevent premature file reading +% (Martin Scharrer). +% \end{Version} % \end{History} % % \PrintIndex |