diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/magicnum.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/magicnum.dtx | 261 |
1 files changed, 193 insertions, 68 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/magicnum.dtx b/Master/texmf-dist/source/latex/oberdiek/magicnum.dtx index e96bfb37134..2c878ae6ff6 100644 --- a/Master/texmf-dist/source/latex/oberdiek/magicnum.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/magicnum.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2007, 2009, 2010 by +% Copyright (C) 2007, 2009, 2010, 2011 by % Heiko Oberdiek <heiko.oberdiek at googlemail.com> % % This work may be distributed and/or modified under the @@ -24,7 +24,7 @@ % and the derived files % magicnum.sty, magicnum.pdf, magicnum.ins, magicnum.drv, magicnum.txt, % magicnum-test1.tex, magicnum-test2.tex, magicnum-test3.tex, -% magicnum.lua, oberdiek.magicnum.lua. +% magicnum-test4.tex, magicnum.lua, oberdiek.magicnum.lua. % % Distribution: % CTAN:macros/latex/contrib/oberdiek/magicnum.dtx @@ -65,6 +65,7 @@ % TDS:doc/latex/oberdiek/test/magicnum-test1.tex % TDS:doc/latex/oberdiek/test/magicnum-test2.tex % TDS:doc/latex/oberdiek/test/magicnum-test3.tex +% TDS:doc/latex/oberdiek/test/magicnum-test4.tex % TDS:source/latex/oberdiek/magicnum.dtx % %<*ignore> @@ -82,7 +83,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: magicnum 2010/03/09 v1.2 Magic numbers (HO)} +\Msg{* Package: magicnum 2011/04/10 v1.4 Magic numbers (HO)} \Msg{************************************************************************} \keepsilent @@ -93,7 +94,7 @@ This is a generated file. -Copyright (C) 2007, 2009, 2010 by +Copyright (C) 2007, 2009, 2010, 2011 by Heiko Oberdiek <heiko.oberdiek at googlemail.com> This work may be distributed and/or modified under the @@ -117,7 +118,7 @@ This work consists of the main source file magicnum.dtx and the derived files magicnum.sty, magicnum.pdf, magicnum.ins, magicnum.drv, magicnum.txt, magicnum-test1.tex, magicnum-test2.tex, magicnum-test3.tex, - magicnum.lua, oberdiek.magicnum.lua. + magicnum-test4.tex, magicnum.lua, oberdiek.magicnum.lua. \endpreamble \let\MetaPrefix\DoubleperCent @@ -131,6 +132,7 @@ and the derived files \file{magicnum-test1.tex}{\from{magicnum.dtx}{test1}}% \file{magicnum-test2.tex}{\from{magicnum.dtx}{testplain,testdata}}% \file{magicnum-test3.tex}{\from{magicnum.dtx}{testlatex,testdata}}% + \file{magicnum-test4.tex}{\from{magicnum.dtx}{test4}}% \nopreamble \nopostamble \usedir{doc/latex/oberdiek}% @@ -176,7 +178,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{magicnum.drv}% - [2010/03/09 v1.2 Magic numbers (HO)]% + [2011/04/10 v1.4 Magic numbers (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc}[2008/08/11] \usepackage{array} @@ -186,7 +188,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{592} +% \CheckSum{755} % % \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 @@ -207,7 +209,7 @@ and the derived files % \GetFileInfo{magicnum.drv} % % \title{The \xpackage{magicnum} package} -% \date{2010/03/09 v1.2} +% \date{2011/04/10 v1.4} % \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}} % % \maketitle @@ -432,14 +434,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@magicnum.sty\endcsname \ifx\x\relax % plain-TeX, first loading \else @@ -447,7 +453,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.}% @@ -459,24 +464,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}% @@ -495,36 +503,46 @@ and the derived files \fi \expandafter\x\csname ver@magicnum.sty\endcsname \ProvidesPackage{magicnum}% - [2010/03/09 v1.2 Magic numbers (HO)] + [2011/04/10 v1.4 Magic numbers (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 magicnum@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\magicnum@AtEnd{% \magicnum@AtEnd - \catcode#1 \the\catcode#1\relax + \catcode#1=\the\catcode#1\relax }% - \catcode#1 #2\relax + \catcode#1=#2\relax } \TMP@EnsureCode{34}{12}% " +\TMP@EnsureCode{39}{12}% ' \TMP@EnsureCode{40}{12}% ( \TMP@EnsureCode{41}{12}% ) \TMP@EnsureCode{42}{12}% * @@ -532,8 +550,12 @@ and the derived files \TMP@EnsureCode{45}{12}% - \TMP@EnsureCode{46}{12}% . \TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{12}% : \TMP@EnsureCode{60}{12}% < \TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{91}{12}% [ +\TMP@EnsureCode{93}{12}% ] +\edef\magicnum@AtEnd{\magicnum@AtEnd\noexpand\endinput} % \end{macrocode} % % \subsection{Check for previous definition} @@ -544,7 +566,7 @@ and the derived files \expandafter\ifx\csname magicnum\endcsname\relax \else \input infwarerr.sty\relax - \@PackageErrorNoLine{magicnum}{% + \@PackageError{magicnum}{% \string\magicnum\space is already defined% }\@ehc \fi @@ -595,9 +617,11 @@ and the derived files % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname RequirePackage\endcsname\relax - \input luatex.sty\relax + \input ifluatex.sty\relax + \input infwarerr.sty\relax \else - \RequirePackage{luatex}[2010/03/09]% + \RequirePackage{ifluatex}[2010/03/01]% + \RequirePackage{infwarerr}[2010/04/08]% \fi % \end{macrocode} % @@ -610,23 +634,64 @@ and the derived files \fi % \end{macrocode} % \end{macro} +% \begin{macrocode} + \magicnum@directlua{% + require("oberdiek.magicnum")% + }% + \begingroup + \def\x{2011/04/10 v1.4}% + \def\StripPrefix#1>{}% + \edef\x{\expandafter\StripPrefix\meaning\x}% + \edef\y{% + \magicnum@directlua{% + if oberdiek.magicnum.getversion then % + oberdiek.magicnum.getversion()% + end% + }% + }% + \ifx\x\y + \else + \@PackageError{magicnum}{% + Wrong version of lua module.\MessageBreak + Package version: \x\MessageBreak + Lua module: \y + }\@ehc + \fi + \endgroup +% \end{macrocode} +% \begin{macro}{\luaescapestring} +% \begin{macrocode} + \begingroup + \expandafter\ifx\csname luaescapestring\endcsname\relax + \directlua{% + if tex.enableprimitives then % + tex.enableprimitives('magicnum@', {'luaescapestring'})% + end% + }% + \global\let\luaescapestring\magicnum@luaescapestring + \fi + \expandafter\ifx\csname luaescapestring\endcsname\relax + \escapechar=92 % + \@PackageError{magicnum}{% + Missing \string\luaescapestring + }\@ehc + \fi + \endgroup +% \end{macrocode} +% \end{macro} % \begin{macro}{\magicnum} % \begin{macrocode} \def\magicnum#1{% \magicnum@directlua{% - require("oberdiek.magicnum")% - oberdiek.magicnum.get(% - "\luatexluaescapestring{#1}",\number\CatcodeTableString - )% + oberdiek.magicnum.get("\luaescapestring{#1}")% }% }% % \end{macrocode} % \end{macro} % % \begin{macrocode} - \magicnum@AtEnd - \expandafter\endinput -\fi + \expandafter\magicnum@AtEnd +\fi% %</package> % \end{macrocode} % @@ -842,7 +907,7 @@ luatex.pdfliteral.mode \magicnum@add{luatex.pdfliteral.mode}{direct}{2} % \end{macrocode} % \begin{macrocode} -\magicnum@AtEnd +\magicnum@AtEnd% %</package> % \end{macrocode} % @@ -855,6 +920,11 @@ luatex.pdfliteral.mode module("oberdiek.magicnum", package.seeall) % \end{macrocode} % \begin{macrocode} +function getversion() + tex.write("2011/04/10 v1.4") +end +% \end{macrocode} +% \begin{macrocode} local data = { ["tex.catcode"] = { [0] = "escape", @@ -1025,7 +1095,7 @@ local data = { } % \end{macrocode} % \begin{macrocode} -function get(name, catcodetable) +function get(name) local startpos, endpos, category, entry = string.find(name, "^(%a[%a%d%.]*)%.(-?[%a%d]+)$") if not entry then @@ -1049,7 +1119,7 @@ function get(name, catcodetable) end value = "" .. value end - tex.print(catcodetable, value) + tex.write(value) end % \end{macrocode} % @@ -1117,6 +1187,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 magicnum.sty\relax}% \fi @@ -1127,15 +1213,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 @@ -1170,7 +1261,7 @@ end %<*testlatex> \NeedsTeXFormat{LaTeX2e} \documentclass{minimal} -\usepackage{magicnum}[2010/03/09] +\usepackage{magicnum}[2011/04/10] \usepackage{qstest} \IncludeTests{*} \LogTests{log}{*}{*} @@ -1212,6 +1303,27 @@ end %</testlatex> % \end{macrocode} % +% \subsection{Small test for \hologo{iniTeX}} +% +% \begin{macrocode} +%<*test4> +\catcode`\{=1 +\catcode`\}=2 +\catcode`\#=6 +\input magicnum.sty\relax +\edef\x{\magicnum{tex.catcode.15}} +\edef\y{invalid} +\def\Strip#1>{} +\edef\y{\expandafter\Strip\meaning\y} +\ifx\x\y + \immediate\write16{Ok}% +\else + \errmessage{\x<>\y}% +\fi +\csname @@end\endcsname\end +%</test4> +% \end{macrocode} +% % \section{Installation} % % \subsection{Download} @@ -1279,6 +1391,7 @@ end % test/magicnum-test1.tex & doc/latex/oberdiek/test/magicnum-test1.tex\\ % test/magicnum-test2.tex & doc/latex/oberdiek/test/magicnum-test2.tex\\ % test/magicnum-test3.tex & doc/latex/oberdiek/test/magicnum-test3.tex\\ +% test/magicnum-test4.tex & doc/latex/oberdiek/test/magicnum-test4.tex\\ % magicnum.dtx & source/latex/oberdiek/magicnum.dtx\\ % \end{tabular}^^A % }^^A @@ -1412,6 +1525,18 @@ end % \item % Adaptation to package \xpackage{luatex} 0.4. % \end{Version} +% \begin{Version}{2011/03/24 v1.3} +% \item +% Catcode fixes. +% \end{Version} +% \begin{Version}{2011/04/10 v1.4} +% \item +% Compatibility for \hologo{iniTeX}. +% \item +% Dependency from package \xpackage{luatex} removed. +% \item +% Version check for lua module. +% \end{Version} % \end{History} % % \PrintIndex |