diff options
author | Karl Berry <karl@freefriends.org> | 2007-10-05 23:13:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-10-05 23:13:42 +0000 |
commit | 4c911ff5ebf103e651707635abf2064ddf149c96 (patch) | |
tree | d3550a7008c8851c3df0746c7e9800df307a0699 | |
parent | f020fc73ad0b6e33f65d5f0b84646131e0340f2f (diff) |
oberdiek update/new: bigintcalc bitset grfext
git-svn-id: svn://tug.org/texlive/trunk@5118 c570f23f-e606-0410-a88d-b1316a301751
113 files changed, 21622 insertions, 1589 deletions
diff --git a/Master/texmf-dist/doc/latex/oberdiek/accsupp.pdf b/Master/texmf-dist/doc/latex/oberdiek/accsupp.pdf Binary files differindex d8f232c2205..721c61b3c8f 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/accsupp.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/accsupp.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/aliascnt.pdf b/Master/texmf-dist/doc/latex/oberdiek/aliascnt.pdf Binary files differindex 5cb281e2c94..64d2075f792 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/aliascnt.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/aliascnt.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/alphalph.pdf b/Master/texmf-dist/doc/latex/oberdiek/alphalph.pdf Binary files differindex 80b0d68e2a3..5ecde69c044 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/alphalph.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/alphalph.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/atbegshi.pdf b/Master/texmf-dist/doc/latex/oberdiek/atbegshi.pdf Binary files differindex e514d3da4ad..4b0ca47d8db 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/atbegshi.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/atbegshi.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/atenddvi.pdf b/Master/texmf-dist/doc/latex/oberdiek/atenddvi.pdf Binary files differindex c03fe6d863a..8bb1df67130 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/atenddvi.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/atenddvi.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/attachfile2.pdf b/Master/texmf-dist/doc/latex/oberdiek/attachfile2.pdf Binary files differindex 5b1c5a51921..436d28e819e 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/attachfile2.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/attachfile2.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/auxhook.pdf b/Master/texmf-dist/doc/latex/oberdiek/auxhook.pdf Binary files differindex df9b3d31017..c22e69a0bde 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/auxhook.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/auxhook.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test1.tex new file mode 100644 index 00000000000..acedbc7d1bf --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test1.tex @@ -0,0 +1,74 @@ +%% +%% This is file `bigintcalc-test1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bigintcalc.dtx (with options: `test1') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bigintcalc.dtx +%% and the derived files +%% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, +%% bigintcalc-test1.tex, bigintcalc-test2.tex, +%% bigintcalc-test3.tex. +%% +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input bigintcalc.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +\endinput +%% +%% End of file `bigintcalc-test1.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test2.tex b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test2.tex new file mode 100644 index 00000000000..3d34ec0e48f --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test2.tex @@ -0,0 +1,812 @@ +%% +%% This is file `bigintcalc-test2.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bigintcalc.dtx (with options: `test2,etex') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bigintcalc.dtx +%% and the derived files +%% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, +%% bigintcalc-test1.tex, bigintcalc-test2.tex, +%% bigintcalc-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\makeatletter +\chardef\BIC@TestMode=1 % +\makeatother +\usepackage{bigintcalc}[2007/09/27] +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\newcommand*{\TestSpaceAtEnd}[1]{% + \edef\resultA{#1}% + \edef\resultB{#1 }% + \Expect*{\resultA\space}*{\resultB}% +} +\newcommand*{\TestResult}[2]{% + \edef\result{#1}% + \Expect*{\result}{#2}% +} +\newcommand*{\TestResultTwoExpansions}[2]{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1}{#2}% +} +\newcount\TestCount +\newcommand*{\TestArg}[1]{\numexpr#1\relax} +\newcommand*{\TestTeXDivide}[2]{% + \TestCount=\TestArg{#1}\relax + \divide\TestCount by \TestArg{#2}\relax + \Expect*{\bigintcalcDiv{#1}{#2}}*{\the\TestCount}% +} +\newcommand*{\Test}[2]{% + \TestResult{#1}{#2}% + \TestResultTwoExpansions{#1}{#2}% + \TestSpaceAtEnd{#1}% +} +\newcommand*{\TestExch}[2]{\Test{#2}{#1}} +\newcommand*{\TestInv}[2]{% + \Test{\bigintcalcInv{#1}}{#2}% +} +\newcommand*{\TestAbs}[2]{% + \Test{\bigintcalcAbs{#1}}{#2}% +} +\newcommand*{\TestSgn}[2]{% + \Test{\bigintcalcSgn{#1}}{#2}% +} +\newcommand*{\TestMin}[3]{% + \Test{\bigintcalcMin{#1}{#2}}{#3}% +} +\newcommand*{\TestMax}[3]{% + \Test{\bigintcalcMax{#1}{#2}}{#3}% +} +\newcommand*{\TestCmp}[3]{% + \Test{\bigintcalcCmp{#1}{#2}}{#3}% +} +\newcommand*{\TestOdd}[2]{% + \Test{\bigintcalcOdd{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcOdd + \bigintcalcAbs{#1}!% + }{#2}% + }% + \x +} +\newcommand*{\TestInc}[2]{% + \Test{\bigintcalcInc{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcInc\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestDec}[2]{% + \Test{\bigintcalcDec{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDec\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestAdd}[3]{% + \Test{\bigintcalcAdd{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#2}!\bigintcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestSub}[3]{% + \Test{\bigintcalcSub{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcSub + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestShl}[2]{% + \Test{\bigintcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShl\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestShr}[2]{% + \Test{\bigintcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShr\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestMul}[3]{% + \Test{\bigintcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMul + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x +} +\newcommand*{\TestSqr}[2]{% + \Test{\bigintcalcSqr{#1}}{#2}% +} +\newcommand*{\TestFac}[2]{% + \expandafter\TestExch\expandafter{% + \the\numexpr#2% + }{\bigintcalcFac{#1}}% +} +\newcommand*{\TestFacBig}[2]{% + \Test{\bigintcalcFac{#1}}{#2}% +} +\newcommand*{\TestPow}[3]{% + \Test{\bigintcalcPow{#1}{#2}}{#3}% +} +\newcommand*{\TestDiv}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \TestTeXDivide{#1}{#2}% +} +\newcommand*{\TestDivBig}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDiv\bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% +} +\newcommand*{\TestMod}[3]{% + \Test{\bigintcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\bigintcalcSgn{#1} 0% + \or + \ifcase\bigintcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\bigintcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMod + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x + \fi +} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +\makeatletter + +\begin{qstest}{inv}{inv}% + \TestInv{0}{0}% + \TestInv{1}{-1}% + \TestInv{-1}{1}% + \TestInv{10}{-10}% + \TestInv{-10}{10}% + \TestInv{2147483647}{-2147483647}% + \TestInv{-2147483647}{2147483647}% + \TestInv{12345678901234567890}{-12345678901234567890}% + \TestInv{-12345678901234567890}{12345678901234567890}% + \TestInv{ 0 }{0}% + \TestInv{ 1 }{-1}% + \TestInv{--1}{-1}% + \TestInv{\number\z@}{0}% + \TestInv{\ifx\relax\relax1\fi}{-1}% + \TestInv{\ifx\relax\relax-\fi\ifx234\else1\fi}{1}% +\end{qstest} + +\begin{qstest}{abs}{abs}% + \TestAbs{0}{0}% + \TestAbs{1}{1}% + \TestAbs{-1}{1}% + \TestAbs{10}{10}% + \TestAbs{-10}{10}% + \TestAbs{2147483647}{2147483647}% + \TestAbs{-2147483647}{2147483647}% + \TestAbs{12345678901234567890}{12345678901234567890}% + \TestAbs{-12345678901234567890}{12345678901234567890}% + \TestAbs{ 0 }{0}% + \TestAbs{ 1 }{1}% + \TestAbs{--1}{1}% + \TestAbs{-+-+1}{1}% + \TestAbs{00000000000}{0}% + \TestAbs{00000001000}{1000}% + \TestAbs{\ifx\relax\relax 0\else 1\fi}{0}% +\end{qstest} + +\begin{qstest}{sign}{sign}% + \TestSgn{0}{0}% + \TestSgn{1}{1}% + \TestSgn{-1}{-1}% + \TestSgn{10}{1}% + \TestSgn{-10}{-1}% + \TestSgn{2147483647}{1}% + \TestSgn{-2147483647}{-1}% + \TestSgn{12345678901234567890}{1}% + \TestSgn{-12345678901234567890}{-1}% + \TestSgn{ 0 }{0}% + \TestSgn{ 2 }{1}% + \TestSgn{ -2 }{-1}% + \TestSgn{--2}{1}% + \TestSgn{\number\z@}{0}% + \TestSgn{\number\@ne}{1}% + \TestSgn{\number\m@ne}{-1}% + \TestSgn{% + -+-+\number\z@\number\z@ + \iftrue1\fi\iftrue2\fi\iftrue3\fi + }{1}% +\end{qstest} + +\begin{qstest}{min}{min}% + \TestMin{0}{1}{0}% + \TestMin{1}{0}{0}% + \TestMin{-10}{-20}{-20}% + \TestMin{ 1 }{ 2 }{1}% + \TestMin{ 2 }{ 1 }{1}% + \TestMin{1}{1}{1}% + \TestMin{\number\z@}{\number\@ne}{0}% + \TestMin{\number\@ne}{\number\m@ne}{-1}% +\end{qstest} + +\begin{qstest}{max}{max}% + \TestMax{0}{1}{1}% + \TestMax{1}{0}{1}% + \TestMax{-10}{-20}{-10}% + \TestMax{ 1 }{ 2 }{2}% + \TestMax{ 2 }{ 1 }{2}% + \TestMax{1}{1}{1}% + \TestMax{\number\z@}{\number\@ne}{1}% + \TestMax{\number\@ne}{\number\m@ne}{1}% +\end{qstest} + +\begin{qstest}{cmp}{cmp}% + \TestCmp{0}{0}{0}% + \TestCmp{-21}{17}{-1}% + \TestCmp{3}{4}{-1}% + \TestCmp{-10}{-10}{0}% + \TestCmp{-10}{-11}{1}% + \TestCmp{100}{5}{1}% + \TestCmp{9}{10}{-1}% + \TestCmp{10}{9}{1}% + \TestCmp{ 3 }{ 3 }{0}% + \TestCmp{-9}{-10}{1}% + \TestCmp{-10}{-9}{-1}% + \TestCmp{-3}{-3}{0}% + \TestCmp{0}{-2}{1}% + \TestCmp{0}{2}{-1}% + \TestCmp{2}{0}{1}% + \TestCmp{-2}{0}{-1}% + \TestCmp{12}{11}{1}% + \TestCmp{11}{12}{-1}% + \TestCmp{2147483647}{-2147483647}{1}% + \TestCmp{-2147483647}{2147483647}{-1}% + \TestCmp{2147483647}{2147483647}{0}% + \TestCmp{\number\z@}{\number\@ne}{-1}% + \TestCmp{\number\@ne}{\number\m@ne}{1}% + \TestCmp{ 4 }{ 5 }{-1}% + \TestCmp{ -3 }{ -7 }{1}% +\end{qstest} + +\begin{qstest}{odd}{odd} +\tracingmacros=1 + \TestOdd{0}{0}% + \TestOdd{1}{1}% + \TestOdd{2}{0}% + \TestOdd{3}{1}% + \TestOdd{14}{0}% + \TestOdd{15}{1}% + \TestOdd{12345678901234567896}{0}% + \TestOdd{12345678901234567897}{1}% +\end{qstest} + +\begin{qstest}{inc}{inc}% + \TestInc{0}{1}% + \TestInc{1}{2}% + \TestInc{-1}{0}% + \TestInc{10}{11}% + \TestInc{-10}{-9}% + \TestInc{ 3 }{4}% + \TestInc{999}{1000}% + \TestInc{-1000}{-999}% + \TestInc{129}{130}% + \TestInc{2147483646}{2147483647}% + \TestInc{-2147483647}{-2147483646}% + \TestInc{12345678901234567890}{12345678901234567891}% + \TestInc{99999999999999999999}{100000000000000000000}% + \TestInc{-12345678901234567891}{-12345678901234567890}% + \TestInc{-100000000000000000000}{-99999999999999999999}% +\end{qstest} + +\begin{qstest}{dec}{dec}% + \TestDec{0}{-1}% + \TestDec{1}{0}% + \TestDec{-1}{-2}% + \TestDec{10}{9}% + \TestDec{-10}{-11}% + \TestDec{1000}{999}% + \TestDec{-999}{-1000}% + \TestDec{130}{129}% + \TestDec{2147483647}{2147483646}% + \TestDec{-2147483646}{-2147483647}% + \TestDec{12345678901234567891}{12345678901234567890}% + \TestDec{100000000000000000000}{99999999999999999999}% + \TestDec{-12345678901234567890}{-12345678901234567891}% + \TestDec{-99999999999999999999}{-100000000000000000000}% +\end{qstest} + +\begin{qstest}{add}{add}% + \TestAdd{0}{0}{0}% + \TestAdd{1}{0}{1}% + \TestAdd{0}{1}{1}% + \TestAdd{1}{2}{3}% + \TestAdd{-1}{-1}{-2}% + \TestAdd{2147483646}{1}{2147483647}% + \TestAdd{-2147483647}{2147483647}{0}% + \TestAdd{20}{-5}{15}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{-4}{1}{-3}% + \TestAdd{-1}{4}{3}% + \TestAdd{4}{-1}{3}% + \TestAdd{1}{-4}{-3}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{ -4 }{ 1 }{-3}% + \TestAdd{ -1 }{ 4 }{3}% + \TestAdd{ 4 }{ -1 }{3}% + \TestAdd{ 1 }{ -4 }{-3}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{876543210}{111111111}{987654321}% + \TestAdd{999999999}{2}{1000000001}% +\end{qstest} + +\begin{qstest}{sub}{sub} + \TestSub{0}{0}{0}% + \TestSub{1}{0}{1}% + \TestSub{1}{2}{-1}% + \TestSub{-1}{-1}{0}% + \TestSub{2147483646}{-1}{2147483647}% + \TestSub{-2147483647}{-2147483647}{0}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{-4}{1}{-5}% + \TestSub{-1}{4}{-5}% + \TestSub{4}{-1}{5}% + \TestSub{1}{-4}{5}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{ -4 }{ 1 }{-5}% + \TestSub{ -1 }{ 4 }{-5}% + \TestSub{ 4 }{ -1 }{5}% + \TestSub{ 1 }{ -4 }{5}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{1000000000}{2}{999999998}% + \TestSub{987654321}{111111111}{876543210}% +\end{qstest} + +\begin{qstest}{shl}{shl} + \TestShl{0}{0}% + \TestShl{1}{2}% + \TestShl{2}{4}% + \TestShl{5621}{11242}% + \TestShl{1073741823}{2147483646}% +\end{qstest} + +\begin{qstest}{shr}{shr} + \TestShr{0}{0}% + \TestShr{1}{0}% + \TestShr{2}{1}% + \TestShr{3}{1}% + \TestShr{4}{2}% + \TestShr{5}{2}% + \TestShr{6}{3}% + \TestShr{7}{3}% + \TestShr{8}{4}% + \TestShr{9}{4}% + \TestShr{10}{5}% + \TestShr{11}{5}% + \TestShr{12}{6}% + \TestShr{13}{6}% + \TestShr{14}{7}% + \TestShr{15}{7}% + \TestShr{16}{8}% + \TestShr{17}{8}% + \TestShr{18}{9}% + \TestShr{19}{9}% + \TestShr{20}{10}% + \TestShr{21}{10}% + \TestShr{22}{11}% + \TestShr{11241}{5620}% + \TestShr{73054202}{36527101}% + \TestShr{2147483646}{1073741823}% +\end{qstest} + +\begin{qstest}{mul}{mul} + \TestMul{0}{0}{0}% + \TestMul{1}{0}{0}% + \TestMul{0}{1}{0}% + \TestMul{1}{1}{1}% + \TestMul{3}{1}{3}% + \TestMul{1}{-3}{-3}% + \TestMul{-4}{-5}{20}% + \TestMul{3}{7}{21}% + \TestMul{7}{3}{21}% + \TestMul{3}{-7}{-21}% + \TestMul{7}{-3}{-21}% + \TestMul{-3}{7}{-21}% + \TestMul{-7}{3}{-21}% + \TestMul{-3}{-7}{21}% + \TestMul{-7}{-3}{21}% + \TestMul{12}{11}{132}% + \TestMul{999}{333}{332667}% + \TestMul{1000}{4321}{4321000}% + \TestMul{12345}{173955}{2147474475}% + \TestMul{1073741823}{2}{2147483646}% + \TestMul{2}{1073741823}{2147483646}% + \TestMul{-1073741823}{2}{-2147483646}% + \TestMul{2}{-1073741823}{-2147483646}% + \TestMul{6706022400}{13}{87178291200}% +\end{qstest} + +\begin{qstest}{sqr}{sqr} + \TestSqr{0}{0}% + \TestSqr{1}{1}% + \TestSqr{2}{4}% + \TestSqr{3}{9}% + \TestSqr{4}{16}% + \TestSqr{9}{81}% + \TestSqr{10}{100}% + \TestSqr{46340}{2147395600}% + \TestSqr{-1}{1}% + \TestSqr{-2}{4}% + \TestSqr{-46340}{2147395600}% +\end{qstest} + +\begin{qstest}{fac}{fac} + \TestFac{0}{1}% + \TestFac{1}{1}% + \TestFac{2}{2}% + \TestFac{3}{2*3}% + \TestFac{4}{2*3*4}% + \TestFac{5}{2*3*4*5}% + \TestFac{6}{2*3*4*5*6}% + \TestFac{7}{2*3*4*5*6*7}% + \TestFac{8}{2*3*4*5*6*7*8}% + \TestFac{9}{2*3*4*5*6*7*8*9}% + \TestFac{10}{2*3*4*5*6*7*8*9*10}% + \TestFac{11}{2*3*4*5*6*7*8*9*10*11}% + \TestFac{12}{2*3*4*5*6*7*8*9*10*11*12}% + \TestFacBig{13}{6227020800}% + \TestFacBig{14}{87178291200}% + \TestFacBig{15}{1307674368000}% + \TestFacBig{16}{20922789888000}% + \TestFacBig{17}{355687428096000}% + \TestFacBig{18}{6402373705728000}% + \TestFacBig{19}{121645100408832000}% + \TestFacBig{20}{2432902008176640000}% + \TestFacBig{21}{51090942171709440000}% + \TestFacBig{22}{1124000727777607680000}% +\end{qstest} + +\begin{qstest}{pow}{pow} + \TestPow{-2}{0}{1}% + \TestPow{-1}{0}{1}% + \TestPow{0}{0}{1}% + \TestPow{1}{0}{1}% + \TestPow{2}{0}{1}% + \TestPow{3}{0}{1}% + \TestPow{-2}{1}{-2}% + \TestPow{-1}{1}{-1}% + \TestPow{1}{1}{1}% + \TestPow{2}{1}{2}% + \TestPow{3}{1}{3}% + \TestPow{-2}{2}{4}% + \TestPow{-1}{2}{1}% + \TestPow{0}{2}{0}% + \TestPow{1}{2}{1}% + \TestPow{2}{2}{4}% + \TestPow{3}{2}{9}% + \TestPow{0}{1}{0}% + \TestPow{1}{-2}{1}% + \TestPow{1}{-1}{1}% + \TestPow{-1}{-2}{1}% + \TestPow{-1}{-1}{-1}% + \TestPow{-1}{3}{-1}% + \TestPow{-1}{4}{1}% + \TestPow{-2}{-1}{0}% + \TestPow{-2}{-2}{0}% + \TestPow{2}{3}{8}% + \TestPow{2}{4}{16}% + \TestPow{2}{5}{32}% + \TestPow{2}{6}{64}% + \TestPow{2}{7}{128}% + \TestPow{2}{8}{256}% + \TestPow{2}{9}{512}% + \TestPow{2}{10}{1024}% + \TestPow{-2}{3}{-8}% + \TestPow{-2}{4}{16}% + \TestPow{-2}{5}{-32}% + \TestPow{-2}{6}{64}% + \TestPow{-2}{7}{-128}% + \TestPow{-2}{8}{256}% + \TestPow{-2}{9}{-512}% + \TestPow{-2}{10}{1024}% + \TestPow{3}{3}{27}% + \TestPow{3}{4}{81}% + \TestPow{3}{5}{243}% + \TestPow{-3}{3}{-27}% + \TestPow{-3}{4}{81}% + \TestPow{-3}{5}{-243}% + \TestPow{2}{30}{1073741824}% + \TestPow{-3}{19}{-1162261467}% + \TestPow{5}{13}{1220703125}% + \TestPow{-7}{11}{-1977326743}% +\end{qstest} + +\begin{qstest}{div}{div} + \TestDiv{1}{1}{1}% + \TestDiv{2}{1}{2}% + \TestDiv{-2}{1}{-2}% + \TestDiv{2}{-1}{-2}% + \TestDiv{-2}{-1}{2}% + \TestDiv{15}{2}{7}% + \TestDiv{-16}{2}{-8}% + \TestDiv{1}{2}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{-2}{3}{0}% + \TestDiv{2}{-3}{0}% + \TestDiv{-2}{-3}{0}% + \TestDiv{13}{3}{4}% + \TestDiv{-13}{-3}{4}% + \TestDiv{-13}{3}{-4}% + \TestDiv{-6}{5}{-1}% + \TestDiv{-5}{5}{-1}% + \TestDiv{-4}{5}{0}% + \TestDiv{-3}{5}{0}% + \TestDiv{-2}{5}{0}% + \TestDiv{-1}{5}{0}% + \TestDiv{0}{5}{0}% + \TestDiv{1}{5}{0}% + \TestDiv{2}{5}{0}% + \TestDiv{3}{5}{0}% + \TestDiv{4}{5}{0}% + \TestDiv{5}{5}{1}% + \TestDiv{6}{5}{1}% + \TestDiv{-5}{4}{-1}% + \TestDiv{-4}{4}{-1}% + \TestDiv{-3}{4}{0}% + \TestDiv{-2}{4}{0}% + \TestDiv{-1}{4}{0}% + \TestDiv{0}{4}{0}% + \TestDiv{1}{4}{0}% + \TestDiv{2}{4}{0}% + \TestDiv{3}{4}{0}% + \TestDiv{4}{4}{1}% + \TestDiv{5}{4}{1}% + \TestDiv{12345}{678}{18}% + \TestDiv{32372}{5952}{5}% + \TestDiv{284271294}{18162}{15651}% + \TestDiv{217652429}{12561}{17327}% + \TestDiv{462028434}{5439}{84947}% + \TestDiv{2147483647}{1000}{2147483}% + \TestDiv{2147483647}{-1000}{-2147483}% + \TestDiv{-2147483647}{1000}{-2147483}% + \TestDiv{-2147483647}{-1000}{2147483}% + \TestDiv{0}{3}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{3}{3}{1}% + \TestDiv{4}{3}{1}% + \TestDiv{5}{3}{1}% + \TestDiv{6}{3}{2}% + \TestDiv{7}{3}{2}% + \TestDiv{8}{3}{2}% + \TestDiv{9}{3}{3}% + \TestDiv{10}{3}{3}% + \TestDiv{11}{3}{3}% + \TestDiv{12}{3}{4}% + \TestDiv{13}{3}{4}% + \TestDiv{14}{3}{4}% + \TestDiv{15}{3}{5}% + \TestDiv{16}{3}{5}% + \TestDiv{17}{3}{5}% + \TestDiv{18}{3}{6}% + \TestDiv{19}{3}{6}% + \TestDiv{20}{3}{6}% + \TestDiv{21}{3}{7}% + \TestDiv{22}{3}{7}% + \TestDiv{23}{3}{7}% + \TestDiv{24}{3}{8}% + \TestDiv{25}{3}{8}% + \TestDiv{26}{3}{8}% + \TestDiv{27}{3}{9}% + \TestDiv{28}{3}{9}% + \TestDiv{29}{3}{9}% + \TestDiv{30}{3}{10}% + \TestDiv{31}{3}{10}% + \TestDivBig{17363436332507}{24702}{702916214}% +\end{qstest} + +\begin{qstest}{mod}{mod} + \TestMod{-6}{5}{4}% + \TestMod{-5}{5}{0}% + \TestMod{-4}{5}{1}% + \TestMod{-3}{5}{2}% + \TestMod{-2}{5}{3}% + \TestMod{-1}{5}{4}% + \TestMod{0}{5}{0}% + \TestMod{1}{5}{1}% + \TestMod{2}{5}{2}% + \TestMod{3}{5}{3}% + \TestMod{4}{5}{4}% + \TestMod{5}{5}{0}% + \TestMod{6}{5}{1}% + \TestMod{-5}{4}{3}% + \TestMod{-4}{4}{0}% + \TestMod{-3}{4}{1}% + \TestMod{-2}{4}{2}% + \TestMod{-1}{4}{3}% + \TestMod{0}{4}{0}% + \TestMod{1}{4}{1}% + \TestMod{2}{4}{2}% + \TestMod{3}{4}{3}% + \TestMod{4}{4}{0}% + \TestMod{5}{4}{1}% + \TestMod{-6}{-5}{-1}% + \TestMod{-5}{-5}{0}% + \TestMod{-4}{-5}{-4}% + \TestMod{-3}{-5}{-3}% + \TestMod{-2}{-5}{-2}% + \TestMod{-1}{-5}{-1}% + \TestMod{0}{-5}{0}% + \TestMod{1}{-5}{-4}% + \TestMod{2}{-5}{-3}% + \TestMod{3}{-5}{-2}% + \TestMod{4}{-5}{-1}% + \TestMod{5}{-5}{0}% + \TestMod{6}{-5}{-4}% + \TestMod{-5}{-4}{-1}% + \TestMod{-4}{-4}{0}% + \TestMod{-3}{-4}{-3}% + \TestMod{-2}{-4}{-2}% + \TestMod{-1}{-4}{-1}% + \TestMod{0}{-4}{0}% + \TestMod{1}{-4}{-3}% + \TestMod{2}{-4}{-2}% + \TestMod{3}{-4}{-1}% + \TestMod{4}{-4}{0}% + \TestMod{5}{-4}{-3}% + \TestMod{2147483647}{1000}{647}% + \TestMod{2147483647}{-1000}{-353}% + \TestMod{-2147483647}{1000}{353}% + \TestMod{-2147483647}{-1000}{-647}% + \TestMod{ 0 }{ 4 }{0}% + \TestMod{ 1 }{ 4 }{1}% + \TestMod{ -1 }{ 4 }{3}% + \TestMod{ 0 }{ -4 }{0}% + \TestMod{ 1 }{ -4 }{-3}% + \TestMod{ -1 }{ -4 }{-1}% + \TestMod{18362}{25}{12}% +\end{qstest} + +\newcommand*{\TestError}[2]{% + \begingroup + \expandafter\def\csname BigIntCalcError:#1\endcsname{}% + \Expect*{#2}{0}% + \expandafter\def\csname BigIntCalcError:#1\endcsname{ERROR}% + \Expect*{#2}{0ERROR}% + \endgroup +} +\begin{qstest}{error}{error} + \TestError{FacNegative}{\bigintcalcFac{-1}}% + \TestError{FacNegative}{\bigintcalcFac{-2147483647}}% + \TestError{DivisionByZero}{\bigintcalcPow{0}{-1}}% + \TestError{DivisionByZero}{\bigintcalcDiv{1}{0}}% + \TestError{DivisionByZero}{\bigintcalcMod{1}{0}}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `bigintcalc-test2.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test3.tex b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test3.tex new file mode 100644 index 00000000000..67b97d45a8d --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc-test3.tex @@ -0,0 +1,825 @@ +%% +%% This is file `bigintcalc-test3.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bigintcalc.dtx (with options: `test2,noetex') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bigintcalc.dtx +%% and the derived files +%% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, +%% bigintcalc-test1.tex, bigintcalc-test2.tex, +%% bigintcalc-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\let\SavedNumexpr\numexpr +\let\numexpr\UNDEFINED +\makeatletter +\chardef\BIC@TestMode=1 % +\makeatother +\usepackage{bigintcalc}[2007/09/27] +\let\numexpr\SavedNumexpr +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\newcommand*{\TestSpaceAtEnd}[1]{% + \let\SavedNumexpr\numexpr + \let\numexpr\UNDEFINED + \edef\resultA{#1}% + \edef\resultB{#1 }% + \let\numexpr\SavedNumexpr + \Expect*{\resultA\space}*{\resultB}% +} +\newcommand*{\TestResult}[2]{% + \let\SavedNumexpr\numexpr + \let\numexpr\UNDEFINED + \edef\result{#1}% + \let\numexpr\SavedNumexpr + \Expect*{\result}{#2}% +} +\newcommand*{\TestResultTwoExpansions}[2]{% + \begingroup + \let\numexpr\UNDEFINED + \expandafter\expandafter\expandafter + \endgroup + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1}{#2}% +} +\newcount\TestCount +\newcommand*{\TestArg}[1]{#1} +\newcommand*{\TestTeXDivide}[2]{% + \TestCount=\TestArg{#1}\relax + \divide\TestCount by \TestArg{#2}\relax + \Expect*{\bigintcalcDiv{#1}{#2}}*{\the\TestCount}% +} +\newcommand*{\Test}[2]{% + \TestResult{#1}{#2}% + \TestResultTwoExpansions{#1}{#2}% + \TestSpaceAtEnd{#1}% +} +\newcommand*{\TestExch}[2]{\Test{#2}{#1}} +\newcommand*{\TestInv}[2]{% + \Test{\bigintcalcInv{#1}}{#2}% +} +\newcommand*{\TestAbs}[2]{% + \Test{\bigintcalcAbs{#1}}{#2}% +} +\newcommand*{\TestSgn}[2]{% + \Test{\bigintcalcSgn{#1}}{#2}% +} +\newcommand*{\TestMin}[3]{% + \Test{\bigintcalcMin{#1}{#2}}{#3}% +} +\newcommand*{\TestMax}[3]{% + \Test{\bigintcalcMax{#1}{#2}}{#3}% +} +\newcommand*{\TestCmp}[3]{% + \Test{\bigintcalcCmp{#1}{#2}}{#3}% +} +\newcommand*{\TestOdd}[2]{% + \Test{\bigintcalcOdd{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcOdd + \bigintcalcAbs{#1}!% + }{#2}% + }% + \x +} +\newcommand*{\TestInc}[2]{% + \Test{\bigintcalcInc{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcInc\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestDec}[2]{% + \Test{\bigintcalcDec{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDec\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestAdd}[3]{% + \Test{\bigintcalcAdd{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#2}!\bigintcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestSub}[3]{% + \Test{\bigintcalcSub{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcSub + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestShl}[2]{% + \Test{\bigintcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShl\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestShr}[2]{% + \Test{\bigintcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShr\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestMul}[3]{% + \Test{\bigintcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMul + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x +} +\newcommand*{\TestSqr}[2]{% + \Test{\bigintcalcSqr{#1}}{#2}% +} +\newcommand*{\TestFac}[2]{% + \expandafter\TestExch\expandafter{% + \the\numexpr#2% + }{\bigintcalcFac{#1}}% +} +\newcommand*{\TestFacBig}[2]{% + \Test{\bigintcalcFac{#1}}{#2}% +} +\newcommand*{\TestPow}[3]{% + \Test{\bigintcalcPow{#1}{#2}}{#3}% +} +\newcommand*{\TestDiv}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \TestTeXDivide{#1}{#2}% +} +\newcommand*{\TestDivBig}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDiv\bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% +} +\newcommand*{\TestMod}[3]{% + \Test{\bigintcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\bigintcalcSgn{#1} 0% + \or + \ifcase\bigintcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\bigintcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMod + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x + \fi +} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +\makeatletter + +\begin{qstest}{inv}{inv}% + \TestInv{0}{0}% + \TestInv{1}{-1}% + \TestInv{-1}{1}% + \TestInv{10}{-10}% + \TestInv{-10}{10}% + \TestInv{2147483647}{-2147483647}% + \TestInv{-2147483647}{2147483647}% + \TestInv{12345678901234567890}{-12345678901234567890}% + \TestInv{-12345678901234567890}{12345678901234567890}% + \TestInv{ 0 }{0}% + \TestInv{ 1 }{-1}% + \TestInv{--1}{-1}% + \TestInv{\number\z@}{0}% + \TestInv{\ifx\relax\relax1\fi}{-1}% + \TestInv{\ifx\relax\relax-\fi\ifx234\else1\fi}{1}% +\end{qstest} + +\begin{qstest}{abs}{abs}% + \TestAbs{0}{0}% + \TestAbs{1}{1}% + \TestAbs{-1}{1}% + \TestAbs{10}{10}% + \TestAbs{-10}{10}% + \TestAbs{2147483647}{2147483647}% + \TestAbs{-2147483647}{2147483647}% + \TestAbs{12345678901234567890}{12345678901234567890}% + \TestAbs{-12345678901234567890}{12345678901234567890}% + \TestAbs{ 0 }{0}% + \TestAbs{ 1 }{1}% + \TestAbs{--1}{1}% + \TestAbs{-+-+1}{1}% + \TestAbs{00000000000}{0}% + \TestAbs{00000001000}{1000}% + \TestAbs{\ifx\relax\relax 0\else 1\fi}{0}% +\end{qstest} + +\begin{qstest}{sign}{sign}% + \TestSgn{0}{0}% + \TestSgn{1}{1}% + \TestSgn{-1}{-1}% + \TestSgn{10}{1}% + \TestSgn{-10}{-1}% + \TestSgn{2147483647}{1}% + \TestSgn{-2147483647}{-1}% + \TestSgn{12345678901234567890}{1}% + \TestSgn{-12345678901234567890}{-1}% + \TestSgn{ 0 }{0}% + \TestSgn{ 2 }{1}% + \TestSgn{ -2 }{-1}% + \TestSgn{--2}{1}% + \TestSgn{\number\z@}{0}% + \TestSgn{\number\@ne}{1}% + \TestSgn{\number\m@ne}{-1}% + \TestSgn{% + -+-+\number\z@\number\z@ + \iftrue1\fi\iftrue2\fi\iftrue3\fi + }{1}% +\end{qstest} + +\begin{qstest}{min}{min}% + \TestMin{0}{1}{0}% + \TestMin{1}{0}{0}% + \TestMin{-10}{-20}{-20}% + \TestMin{ 1 }{ 2 }{1}% + \TestMin{ 2 }{ 1 }{1}% + \TestMin{1}{1}{1}% + \TestMin{\number\z@}{\number\@ne}{0}% + \TestMin{\number\@ne}{\number\m@ne}{-1}% +\end{qstest} + +\begin{qstest}{max}{max}% + \TestMax{0}{1}{1}% + \TestMax{1}{0}{1}% + \TestMax{-10}{-20}{-10}% + \TestMax{ 1 }{ 2 }{2}% + \TestMax{ 2 }{ 1 }{2}% + \TestMax{1}{1}{1}% + \TestMax{\number\z@}{\number\@ne}{1}% + \TestMax{\number\@ne}{\number\m@ne}{1}% +\end{qstest} + +\begin{qstest}{cmp}{cmp}% + \TestCmp{0}{0}{0}% + \TestCmp{-21}{17}{-1}% + \TestCmp{3}{4}{-1}% + \TestCmp{-10}{-10}{0}% + \TestCmp{-10}{-11}{1}% + \TestCmp{100}{5}{1}% + \TestCmp{9}{10}{-1}% + \TestCmp{10}{9}{1}% + \TestCmp{ 3 }{ 3 }{0}% + \TestCmp{-9}{-10}{1}% + \TestCmp{-10}{-9}{-1}% + \TestCmp{-3}{-3}{0}% + \TestCmp{0}{-2}{1}% + \TestCmp{0}{2}{-1}% + \TestCmp{2}{0}{1}% + \TestCmp{-2}{0}{-1}% + \TestCmp{12}{11}{1}% + \TestCmp{11}{12}{-1}% + \TestCmp{2147483647}{-2147483647}{1}% + \TestCmp{-2147483647}{2147483647}{-1}% + \TestCmp{2147483647}{2147483647}{0}% + \TestCmp{\number\z@}{\number\@ne}{-1}% + \TestCmp{\number\@ne}{\number\m@ne}{1}% + \TestCmp{ 4 }{ 5 }{-1}% + \TestCmp{ -3 }{ -7 }{1}% +\end{qstest} + +\begin{qstest}{odd}{odd} +\tracingmacros=1 + \TestOdd{0}{0}% + \TestOdd{1}{1}% + \TestOdd{2}{0}% + \TestOdd{3}{1}% + \TestOdd{14}{0}% + \TestOdd{15}{1}% + \TestOdd{12345678901234567896}{0}% + \TestOdd{12345678901234567897}{1}% +\end{qstest} + +\begin{qstest}{inc}{inc}% + \TestInc{0}{1}% + \TestInc{1}{2}% + \TestInc{-1}{0}% + \TestInc{10}{11}% + \TestInc{-10}{-9}% + \TestInc{ 3 }{4}% + \TestInc{999}{1000}% + \TestInc{-1000}{-999}% + \TestInc{129}{130}% + \TestInc{2147483646}{2147483647}% + \TestInc{-2147483647}{-2147483646}% + \TestInc{12345678901234567890}{12345678901234567891}% + \TestInc{99999999999999999999}{100000000000000000000}% + \TestInc{-12345678901234567891}{-12345678901234567890}% + \TestInc{-100000000000000000000}{-99999999999999999999}% +\end{qstest} + +\begin{qstest}{dec}{dec}% + \TestDec{0}{-1}% + \TestDec{1}{0}% + \TestDec{-1}{-2}% + \TestDec{10}{9}% + \TestDec{-10}{-11}% + \TestDec{1000}{999}% + \TestDec{-999}{-1000}% + \TestDec{130}{129}% + \TestDec{2147483647}{2147483646}% + \TestDec{-2147483646}{-2147483647}% + \TestDec{12345678901234567891}{12345678901234567890}% + \TestDec{100000000000000000000}{99999999999999999999}% + \TestDec{-12345678901234567890}{-12345678901234567891}% + \TestDec{-99999999999999999999}{-100000000000000000000}% +\end{qstest} + +\begin{qstest}{add}{add}% + \TestAdd{0}{0}{0}% + \TestAdd{1}{0}{1}% + \TestAdd{0}{1}{1}% + \TestAdd{1}{2}{3}% + \TestAdd{-1}{-1}{-2}% + \TestAdd{2147483646}{1}{2147483647}% + \TestAdd{-2147483647}{2147483647}{0}% + \TestAdd{20}{-5}{15}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{-4}{1}{-3}% + \TestAdd{-1}{4}{3}% + \TestAdd{4}{-1}{3}% + \TestAdd{1}{-4}{-3}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{ -4 }{ 1 }{-3}% + \TestAdd{ -1 }{ 4 }{3}% + \TestAdd{ 4 }{ -1 }{3}% + \TestAdd{ 1 }{ -4 }{-3}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{876543210}{111111111}{987654321}% + \TestAdd{999999999}{2}{1000000001}% +\end{qstest} + +\begin{qstest}{sub}{sub} + \TestSub{0}{0}{0}% + \TestSub{1}{0}{1}% + \TestSub{1}{2}{-1}% + \TestSub{-1}{-1}{0}% + \TestSub{2147483646}{-1}{2147483647}% + \TestSub{-2147483647}{-2147483647}{0}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{-4}{1}{-5}% + \TestSub{-1}{4}{-5}% + \TestSub{4}{-1}{5}% + \TestSub{1}{-4}{5}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{ -4 }{ 1 }{-5}% + \TestSub{ -1 }{ 4 }{-5}% + \TestSub{ 4 }{ -1 }{5}% + \TestSub{ 1 }{ -4 }{5}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{1000000000}{2}{999999998}% + \TestSub{987654321}{111111111}{876543210}% +\end{qstest} + +\begin{qstest}{shl}{shl} + \TestShl{0}{0}% + \TestShl{1}{2}% + \TestShl{2}{4}% + \TestShl{5621}{11242}% + \TestShl{1073741823}{2147483646}% +\end{qstest} + +\begin{qstest}{shr}{shr} + \TestShr{0}{0}% + \TestShr{1}{0}% + \TestShr{2}{1}% + \TestShr{3}{1}% + \TestShr{4}{2}% + \TestShr{5}{2}% + \TestShr{6}{3}% + \TestShr{7}{3}% + \TestShr{8}{4}% + \TestShr{9}{4}% + \TestShr{10}{5}% + \TestShr{11}{5}% + \TestShr{12}{6}% + \TestShr{13}{6}% + \TestShr{14}{7}% + \TestShr{15}{7}% + \TestShr{16}{8}% + \TestShr{17}{8}% + \TestShr{18}{9}% + \TestShr{19}{9}% + \TestShr{20}{10}% + \TestShr{21}{10}% + \TestShr{22}{11}% + \TestShr{11241}{5620}% + \TestShr{73054202}{36527101}% + \TestShr{2147483646}{1073741823}% +\end{qstest} + +\begin{qstest}{mul}{mul} + \TestMul{0}{0}{0}% + \TestMul{1}{0}{0}% + \TestMul{0}{1}{0}% + \TestMul{1}{1}{1}% + \TestMul{3}{1}{3}% + \TestMul{1}{-3}{-3}% + \TestMul{-4}{-5}{20}% + \TestMul{3}{7}{21}% + \TestMul{7}{3}{21}% + \TestMul{3}{-7}{-21}% + \TestMul{7}{-3}{-21}% + \TestMul{-3}{7}{-21}% + \TestMul{-7}{3}{-21}% + \TestMul{-3}{-7}{21}% + \TestMul{-7}{-3}{21}% + \TestMul{12}{11}{132}% + \TestMul{999}{333}{332667}% + \TestMul{1000}{4321}{4321000}% + \TestMul{12345}{173955}{2147474475}% + \TestMul{1073741823}{2}{2147483646}% + \TestMul{2}{1073741823}{2147483646}% + \TestMul{-1073741823}{2}{-2147483646}% + \TestMul{2}{-1073741823}{-2147483646}% + \TestMul{6706022400}{13}{87178291200}% +\end{qstest} + +\begin{qstest}{sqr}{sqr} + \TestSqr{0}{0}% + \TestSqr{1}{1}% + \TestSqr{2}{4}% + \TestSqr{3}{9}% + \TestSqr{4}{16}% + \TestSqr{9}{81}% + \TestSqr{10}{100}% + \TestSqr{46340}{2147395600}% + \TestSqr{-1}{1}% + \TestSqr{-2}{4}% + \TestSqr{-46340}{2147395600}% +\end{qstest} + +\begin{qstest}{fac}{fac} + \TestFac{0}{1}% + \TestFac{1}{1}% + \TestFac{2}{2}% + \TestFac{3}{2*3}% + \TestFac{4}{2*3*4}% + \TestFac{5}{2*3*4*5}% + \TestFac{6}{2*3*4*5*6}% + \TestFac{7}{2*3*4*5*6*7}% + \TestFac{8}{2*3*4*5*6*7*8}% + \TestFac{9}{2*3*4*5*6*7*8*9}% + \TestFac{10}{2*3*4*5*6*7*8*9*10}% + \TestFac{11}{2*3*4*5*6*7*8*9*10*11}% + \TestFac{12}{2*3*4*5*6*7*8*9*10*11*12}% + \TestFacBig{13}{6227020800}% + \TestFacBig{14}{87178291200}% + \TestFacBig{15}{1307674368000}% + \TestFacBig{16}{20922789888000}% + \TestFacBig{17}{355687428096000}% + \TestFacBig{18}{6402373705728000}% + \TestFacBig{19}{121645100408832000}% + \TestFacBig{20}{2432902008176640000}% + \TestFacBig{21}{51090942171709440000}% + \TestFacBig{22}{1124000727777607680000}% +\end{qstest} + +\begin{qstest}{pow}{pow} + \TestPow{-2}{0}{1}% + \TestPow{-1}{0}{1}% + \TestPow{0}{0}{1}% + \TestPow{1}{0}{1}% + \TestPow{2}{0}{1}% + \TestPow{3}{0}{1}% + \TestPow{-2}{1}{-2}% + \TestPow{-1}{1}{-1}% + \TestPow{1}{1}{1}% + \TestPow{2}{1}{2}% + \TestPow{3}{1}{3}% + \TestPow{-2}{2}{4}% + \TestPow{-1}{2}{1}% + \TestPow{0}{2}{0}% + \TestPow{1}{2}{1}% + \TestPow{2}{2}{4}% + \TestPow{3}{2}{9}% + \TestPow{0}{1}{0}% + \TestPow{1}{-2}{1}% + \TestPow{1}{-1}{1}% + \TestPow{-1}{-2}{1}% + \TestPow{-1}{-1}{-1}% + \TestPow{-1}{3}{-1}% + \TestPow{-1}{4}{1}% + \TestPow{-2}{-1}{0}% + \TestPow{-2}{-2}{0}% + \TestPow{2}{3}{8}% + \TestPow{2}{4}{16}% + \TestPow{2}{5}{32}% + \TestPow{2}{6}{64}% + \TestPow{2}{7}{128}% + \TestPow{2}{8}{256}% + \TestPow{2}{9}{512}% + \TestPow{2}{10}{1024}% + \TestPow{-2}{3}{-8}% + \TestPow{-2}{4}{16}% + \TestPow{-2}{5}{-32}% + \TestPow{-2}{6}{64}% + \TestPow{-2}{7}{-128}% + \TestPow{-2}{8}{256}% + \TestPow{-2}{9}{-512}% + \TestPow{-2}{10}{1024}% + \TestPow{3}{3}{27}% + \TestPow{3}{4}{81}% + \TestPow{3}{5}{243}% + \TestPow{-3}{3}{-27}% + \TestPow{-3}{4}{81}% + \TestPow{-3}{5}{-243}% + \TestPow{2}{30}{1073741824}% + \TestPow{-3}{19}{-1162261467}% + \TestPow{5}{13}{1220703125}% + \TestPow{-7}{11}{-1977326743}% +\end{qstest} + +\begin{qstest}{div}{div} + \TestDiv{1}{1}{1}% + \TestDiv{2}{1}{2}% + \TestDiv{-2}{1}{-2}% + \TestDiv{2}{-1}{-2}% + \TestDiv{-2}{-1}{2}% + \TestDiv{15}{2}{7}% + \TestDiv{-16}{2}{-8}% + \TestDiv{1}{2}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{-2}{3}{0}% + \TestDiv{2}{-3}{0}% + \TestDiv{-2}{-3}{0}% + \TestDiv{13}{3}{4}% + \TestDiv{-13}{-3}{4}% + \TestDiv{-13}{3}{-4}% + \TestDiv{-6}{5}{-1}% + \TestDiv{-5}{5}{-1}% + \TestDiv{-4}{5}{0}% + \TestDiv{-3}{5}{0}% + \TestDiv{-2}{5}{0}% + \TestDiv{-1}{5}{0}% + \TestDiv{0}{5}{0}% + \TestDiv{1}{5}{0}% + \TestDiv{2}{5}{0}% + \TestDiv{3}{5}{0}% + \TestDiv{4}{5}{0}% + \TestDiv{5}{5}{1}% + \TestDiv{6}{5}{1}% + \TestDiv{-5}{4}{-1}% + \TestDiv{-4}{4}{-1}% + \TestDiv{-3}{4}{0}% + \TestDiv{-2}{4}{0}% + \TestDiv{-1}{4}{0}% + \TestDiv{0}{4}{0}% + \TestDiv{1}{4}{0}% + \TestDiv{2}{4}{0}% + \TestDiv{3}{4}{0}% + \TestDiv{4}{4}{1}% + \TestDiv{5}{4}{1}% + \TestDiv{12345}{678}{18}% + \TestDiv{32372}{5952}{5}% + \TestDiv{284271294}{18162}{15651}% + \TestDiv{217652429}{12561}{17327}% + \TestDiv{462028434}{5439}{84947}% + \TestDiv{2147483647}{1000}{2147483}% + \TestDiv{2147483647}{-1000}{-2147483}% + \TestDiv{-2147483647}{1000}{-2147483}% + \TestDiv{-2147483647}{-1000}{2147483}% + \TestDiv{0}{3}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{3}{3}{1}% + \TestDiv{4}{3}{1}% + \TestDiv{5}{3}{1}% + \TestDiv{6}{3}{2}% + \TestDiv{7}{3}{2}% + \TestDiv{8}{3}{2}% + \TestDiv{9}{3}{3}% + \TestDiv{10}{3}{3}% + \TestDiv{11}{3}{3}% + \TestDiv{12}{3}{4}% + \TestDiv{13}{3}{4}% + \TestDiv{14}{3}{4}% + \TestDiv{15}{3}{5}% + \TestDiv{16}{3}{5}% + \TestDiv{17}{3}{5}% + \TestDiv{18}{3}{6}% + \TestDiv{19}{3}{6}% + \TestDiv{20}{3}{6}% + \TestDiv{21}{3}{7}% + \TestDiv{22}{3}{7}% + \TestDiv{23}{3}{7}% + \TestDiv{24}{3}{8}% + \TestDiv{25}{3}{8}% + \TestDiv{26}{3}{8}% + \TestDiv{27}{3}{9}% + \TestDiv{28}{3}{9}% + \TestDiv{29}{3}{9}% + \TestDiv{30}{3}{10}% + \TestDiv{31}{3}{10}% + \TestDivBig{17363436332507}{24702}{702916214}% +\end{qstest} + +\begin{qstest}{mod}{mod} + \TestMod{-6}{5}{4}% + \TestMod{-5}{5}{0}% + \TestMod{-4}{5}{1}% + \TestMod{-3}{5}{2}% + \TestMod{-2}{5}{3}% + \TestMod{-1}{5}{4}% + \TestMod{0}{5}{0}% + \TestMod{1}{5}{1}% + \TestMod{2}{5}{2}% + \TestMod{3}{5}{3}% + \TestMod{4}{5}{4}% + \TestMod{5}{5}{0}% + \TestMod{6}{5}{1}% + \TestMod{-5}{4}{3}% + \TestMod{-4}{4}{0}% + \TestMod{-3}{4}{1}% + \TestMod{-2}{4}{2}% + \TestMod{-1}{4}{3}% + \TestMod{0}{4}{0}% + \TestMod{1}{4}{1}% + \TestMod{2}{4}{2}% + \TestMod{3}{4}{3}% + \TestMod{4}{4}{0}% + \TestMod{5}{4}{1}% + \TestMod{-6}{-5}{-1}% + \TestMod{-5}{-5}{0}% + \TestMod{-4}{-5}{-4}% + \TestMod{-3}{-5}{-3}% + \TestMod{-2}{-5}{-2}% + \TestMod{-1}{-5}{-1}% + \TestMod{0}{-5}{0}% + \TestMod{1}{-5}{-4}% + \TestMod{2}{-5}{-3}% + \TestMod{3}{-5}{-2}% + \TestMod{4}{-5}{-1}% + \TestMod{5}{-5}{0}% + \TestMod{6}{-5}{-4}% + \TestMod{-5}{-4}{-1}% + \TestMod{-4}{-4}{0}% + \TestMod{-3}{-4}{-3}% + \TestMod{-2}{-4}{-2}% + \TestMod{-1}{-4}{-1}% + \TestMod{0}{-4}{0}% + \TestMod{1}{-4}{-3}% + \TestMod{2}{-4}{-2}% + \TestMod{3}{-4}{-1}% + \TestMod{4}{-4}{0}% + \TestMod{5}{-4}{-3}% + \TestMod{2147483647}{1000}{647}% + \TestMod{2147483647}{-1000}{-353}% + \TestMod{-2147483647}{1000}{353}% + \TestMod{-2147483647}{-1000}{-647}% + \TestMod{ 0 }{ 4 }{0}% + \TestMod{ 1 }{ 4 }{1}% + \TestMod{ -1 }{ 4 }{3}% + \TestMod{ 0 }{ -4 }{0}% + \TestMod{ 1 }{ -4 }{-3}% + \TestMod{ -1 }{ -4 }{-1}% + \TestMod{18362}{25}{12}% +\end{qstest} + +\newcommand*{\TestError}[2]{% + \begingroup + \expandafter\def\csname BigIntCalcError:#1\endcsname{}% + \Expect*{#2}{0}% + \expandafter\def\csname BigIntCalcError:#1\endcsname{ERROR}% + \Expect*{#2}{0ERROR}% + \endgroup +} +\begin{qstest}{error}{error} + \TestError{FacNegative}{\bigintcalcFac{-1}}% + \TestError{FacNegative}{\bigintcalcFac{-2147483647}}% + \TestError{DivisionByZero}{\bigintcalcPow{0}{-1}}% + \TestError{DivisionByZero}{\bigintcalcDiv{1}{0}}% + \TestError{DivisionByZero}{\bigintcalcMod{1}{0}}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `bigintcalc-test3.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bigintcalc.pdf b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc.pdf Binary files differnew file mode 100644 index 00000000000..7bd2d03728a --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bigintcalc.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/bitset-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/bitset-test1.tex new file mode 100644 index 00000000000..c5baacfbc56 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bitset-test1.tex @@ -0,0 +1,73 @@ +%% +%% This is file `bitset-test1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bitset.dtx (with options: `test1') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bitset.dtx +%% and the derived files +%% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, +%% bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. +%% +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input bitset.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +\endinput +%% +%% End of file `bitset-test1.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bitset-test2.tex b/Master/texmf-dist/doc/latex/oberdiek/bitset-test2.tex new file mode 100644 index 00000000000..146141d3171 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bitset-test2.tex @@ -0,0 +1,1080 @@ +%% +%% This is file `bitset-test2.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bitset.dtx (with options: `test2,etex') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bitset.dtx +%% and the derived files +%% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, +%% bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\makeatletter +\makeatletter +\chardef\BitSet@TestMode=1 % +\makeatother +\usepackage{bitset}[2007/09/28] +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\makeatletter +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% +\fi +\let\orig@qstest\qstest +\let\orig@endqstest\endqstest +\def\qstest#1#2{% + \orig@qstest{#1}{#2}% + \setbox0\hbox\bgroup\begingroup\ignorespaces +} +\def\endqstest{% + \endgroup\egroup + \Expect*{\the\wd0}{0.0pt}% + \orig@endqstest +} +\newcounter{Test} + +\def\TestError#1#2{% + \begingroup + \setcounter{Test}{0}% + \sbox0{% + \def\@PackageError##1##2##3{% + \stepcounter{Test}% + \begingroup + \let\MessageBreak\relax + \Expect{##1}{bitset}% + \Expect*{##2}*{#1}% + \endgroup + }% + #2% + }% + \Expect*{\theTest}{1}% + \Expect*{\the\wd0}{0.0pt}% + \endgroup +} + +\def\TestErrorNegativeIndex#1#2{% + \TestError{Invalid negative index (#1)}{#2}% +} + +\def\TestGetterUndefined#1{% + \CheckUndef{dummy}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1{dummy}}{0}% +} + +\def\ExpectBitSet#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\csname BS@#1\endcsname}*{#2}% +} +\def\Check#1#2{% + \ExpectBitSet{#1}{#2}% +} +\def\CheckUndef#1{% + \begingroup + \Expect*{% + \expandafter + \ifx\csname BS@#1\endcsname\relax true\else false\fi + }{true}% + \endgroup +} +\def\RevCheck#1#2{% + \ExpectBitSet{#1}{\Reverse#2!!}% +} +\def\Set#1#2{% + \expandafter\def\csname BS@#1\endcsname{#2}% +} +\def\RevSet#1#2{% + \expandafter\edef\csname BS@#1\endcsname{% + \Reverse#2!!% + }% +} +\def\Reverse#1#2!#3!{% + \ifx\\#2\\% + #1#3% + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\Reverse#2!#1#3!}% +} +\begin{qstest}{Let}{Let} + \CheckUndef{abc}% + \CheckUndef{xyz}% + \bitsetLet{xyz}{abc}% + \CheckUndef{abc}% + \Check{xyz}{0}% + \Set{abc}{1}% + \Check{abc}{1}% + \Check{xyz}{0}% + \bitsetLet{xyz}{abc}% + \Check{abc}{1}% + \Check{xyz}{1}% + \Set{xyz}{11}% + \Check{abc}{1}% + \Check{xyz}{11}% +\end{qstest} + +\begin{qstest}{Reset}{Reset} + \bitsetReset{xyz}% + \Check{xyz}{0}% + \bitsetReset{abc}% + \Check{abc}{0}% + \Set{abc}{10101}% + \bitsetReset{abc}% + \Check{abc}{0}% +\end{qstest} + +\begin{qstest}{Get/Query}{Get/Query} + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGet{dummy}{0}% + }{0}% + \begingroup + \expandafter\def\csname BitSetError:NegativeIndex\endcsname{}% + \Set{abc}{1}% + \Expect*{\bitsetQuery{abc}{-1}{true}{false}}{false}% + \endgroup + \def\Test#1#2#3{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetGet{abc}{#2}}{#3}% + \Expect*{\bitsetQuery{abc}{#2}{true}{false}}% + *{\ifcase#3 false\or true\else error\fi}% + }% + \Test{1}{100}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{11}{1}{1}% + \Test{111}{1}{1}% + \Test{101}{1}{0}% + \Test{101}{2}{1}% + \Test{10100110011}{10}{1}% +\end{qstest} + +\begin{qstest}{Size}{Size} + \TestGetterUndefined\bitsetSize + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetSize{abc}}{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{2}% + \Test{11}{2}% + \Test{010}{2}% + \Test{011}{3}% + \Test{100110011}{9}% + \Test{0000011111000001111100000}{20}% + \Test{000000000000000000000000011111111111111111111}{45}% +\end{qstest} + +\begin{qstest}{Cardinality}{Cardinality} + \TestGetterUndefined\bitsetCardinality + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetCardinality{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{1}% + \Test{11}{2}% + \Test{010}{1}% + \Test{011}{2}% + \Test{100110011}{5}% + \Test{0000011111000001111100000}{10}% + \Test{000000000000000000000000011111111111111111111}{20}% +\end{qstest} + +\begin{qstest}{NextClearBit/NextSetBit}{NextClearBit/NextSetBit} + \def\Test#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \TestOp{abc}{#1}% + }{#2}% + }% + \def\Clear{\let\TestOp\bitsetNextClearBit}% + \def\Set{\let\TestOp\bitsetNextSetBit}% + \begingroup + \catcode`\:=11 % + \bitsetSetBin{abc}{1}% + \Clear + \Test{-1}{1\BitSetError:NegativeIndex}% + \Set + \Test{-1}{0\BitSetError:NegativeIndex}% + \endgroup + \let\BS@abc\@undefined + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetReset{abc}% + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1}% + \Clear + \Test{0}{1}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111000111000111000111}% + \Clear + \Test{0}{3}% + \Test{1}{3}% + \Test{2}{3}% + \Test{3}{3}% + \Test{4}{4}% + \Test{5}{5}% + \Test{6}{9}% + \Test{7}{9}% + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{11}{11}% + \Test{12}{15}% + \Test{13}{15}% + \Test{14}{15}% + \Test{15}{15}% + \Test{16}{16}% + \Test{17}{17}% + \Test{18}{21}% + \Test{19}{21}% + \Test{20}{21}% + \Test{21}{21}% + \Test{22}{22}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{3}{6}% + \Test{4}{6}% + \Test{5}{6}% + \Test{6}{6}% + \Test{7}{7}% + \Test{8}{8}% + \Test{9}{12}% + \Test{10}{12}% + \Test{11}{12}% + \Test{12}{12}% + \Test{13}{13}% + \Test{14}{14}% + \Test{15}{18}% + \Test{16}{18}% + \Test{17}{18}% + \Test{18}{18}% + \Test{19}{19}% + \Test{20}{20}% + \Test{21}{-1}% + \Test{22}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111}% + \Clear + \Test{6}{7}% + \Test{7}{7}% + \Test{8}{8}% + \Test{100}{100}% + \Set + \Test{6}{6}% + \Test{7}{-1}% + \Test{8}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{11111111}% + \Clear + \Test{7}{8}% + \Test{8}{8}% + \Test{9}{9}% + \Test{100}{100}% + \Set + \Test{7}{7}% + \Test{8}{-1}% + \Test{9}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111111111}% + \Clear + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{100}{100}% + \Set + \Test{8}{8}% + \Test{9}{-1}% + \Test{10}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111111}% + \Clear + \Test{9}{10}% + \Test{10}{10}% + \Test{11}{11}% + \Test{100}{100}% + \Set + \Test{9}{9}% + \Test{10}{-1}% + \Test{11}{-1}% + \Test{100}{-1}% +\end{qstest} + +\begin{qstest}{GetSetBitList}{GetSetBitList} + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{#2}% + }% + \Test{0}{}% + \Test{1}{0}% + \Test{10}{1}% + \Test{11}{0,1}% + \Test{10110100}{2,4,5,7}% + \Test{101101001010011}{0,1,4,6,9,11,12,14}% +\end{qstest} + +\begin{qstest}{GetDec}{GetDec} + \TestGetterUndefined\bitsetGetDec + \def\Test#1#2{% + \RevSet{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetDec{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{2}% + \Test{11}{3}% + \Test{100}{4}% + \Test{101}{5}% + \Test{110}{6}% + \Test{111}{7}% + \Test{1000}{8}% + \Test{000111}{7}% + \Test{1111111111111111% + 111111111111111}{2147483647}% + \Test{0001111111111111111% + 111111111111111}{2147483647}% + \Test{1000000000000000% + 0000000000000000}{2147483648}% + \Test{1000000000000000% + 00000000000000000}{4294967296}% + \Test{0001000000000000000% + 00000000000000000}{4294967296}% + \Test{1100000000000000% + 00000000000000011}{6442450947}% +\end{qstest} + +\begin{qstest}{Clear}{Clear} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetClear{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetClear{abc}{2}% + \RevCheck{abc}{0}% + \TestErrorNegativeIndex{-1}{\bitsetClear{abc}{-1}}% + \RevCheck{abc}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{0}% + \Test{111}{1}{101}% + \Test{111}{30}{111}% + \Test{0000111}{5}{0000111}% 111 would also be ok + \Test{10000111}{5}{10000111}% + \Test{1001001}{3}{1000001}% +\end{qstest} + +\begin{qstest}{Set}{Set} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetSet{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetSet{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetSet{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{1}% + \Test{100}{1}{110}% + \Test{111}{1}{111}% + \Test{11}{1}{11}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1001001}% +\end{qstest} + +\begin{qstest}{Flip}{Flip} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetFlip{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetFlip{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetFlip{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{0}% + \Test{0}{2}{100}% + \Test{100}{1}{110}% + \Test{111}{1}{101}% + \Test{11}{1}{1}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1000001}% + \Test{11111}{2}{11011}% +\end{qstest} + +\begin{qstest}{SetValue}{SetValue} + \def\Test#1#2{% + \TestError{Invalid bit value (#2) not in range 0..1}{% + \bitsetSetValue{abc}{#1}{#2}% + }% + }% + \Test{0}{-1}% + \Test{0}{2}% + \Test{0}{10}% + \def\Test#1#2#3{% + \let\BS@abc\@undefined + \bitsetSetValue{abc}{#1}{#2}% + \bitsetSetBin{result}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}% + \Test{0}{1}{1}% + \Test{1}{0}{0}% + \Test{1}{1}{10}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#4}% + \bitsetSetValue{abc}{#2}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}{0}% + \Test{0}{0}{0}{0}% + \Test{0}{0}{1}{1}% + \Test{0}{1}{0}{0}% + \Test{0}{1}{1}{10}% + \Test{1010}{2}{1}{1110}% + \Test{1010}{4}{1}{11010}% + \Test{1010}{6}{1}{1001010}% + \Test{1010}{1}{0}{1000}% + \Test{1010}{2}{0}{1010}% + \Test{1010}{3}{0}{10}% + \Test{1010}{4}{0}{1010}% + \Test{1010}{6}{0}{1010}% + \Test{1010}{2}{\csname iffalse\endcsname 0\else 1\fi}{1110}% + \Test{1010}{1}{\csname iffalse\endcsname 1\else 0\fi}{1000}% +\end{qstest} + +\begin{qstest}{IsDefined}{IsDefined} + \let\BS@abc\@undefined + \Expect*{\bitsetIsDefined{abc}{true}{false}}{false}% + \bitsetReset{abc}% + \Expect*{\bitsetIsDefined{abc}{true}{false}}{true}% +\end{qstest} + +\begin{qstest}{IsEmpty}{IsEmpty} + \let\BS@abc\@undefined + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetReset{abc}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetSet{abc}{1}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{false}% +\end{qstest} + +\begin{qstest}{Equals}{Equals} + \def\Test#1#2#3{% + \Expect*{\bitsetEquals{#1}{#2}{true}{false}}{#3}% + }% + \let\BS@abc\@undefined + \Test{abc}{abc}{true}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetReset{abc}% + \Test{abc}{abc}{true}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetReset{foo}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetSet{abc}{4}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetFlip{foo}{4}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% +\end{qstest} + +\begin{qstest}{Intersects}{Intersects} + \def\Test#1{% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#1}% + }% + \let\BS@abc\@undefined + \let\BS@foo\@undefined + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \let\BS@abc\@undefined + \Test{false}% + \Set{foo}{1}% + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{abc}{1}% + \Test{true}% + \let\BS@foo\@undefined + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#3}% + }% + \Test{1010}{0101}{false}% + \Test{0}{10}{false}% + \Test{1}{11}{true}% + \Test{11}{1}{true}% + \Test{10}{1}{false}% +\end{qstest} + +\begin{qstest}{And/AndNot/Or/Xor}{And/AndNot/Or/Xor} + \def\@Test#1#2#3#4#5{% + \begingroup + #5% + \begingroup + \let\BS@foo\@undefined + \csname bitset#1\endcsname{abc}{foo}% + \CheckUndef{foo}% + \Check{abc}{#2}% + \endgroup + \begingroup + \bitsetReset{foo}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0}% + \Check{abc}{#3}% + \endgroup + \begingroup + \def\BS@foo{0101}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0101}% + \Check{abc}{#4}% + \endgroup + \endgroup + }% + \def\Test#1{% + \def\Op{#1}% + \Test@ + }% + \def\Test@#1#2#3#4#5#6#7#8#9{% + \@Test\Op{#1}{#2}{#3}{% + \let\BS@abc\@undefined + }% + \@Test\Op{#4}{#5}{#6}{% + \bitsetReset{abc}% + }% + \@Test\Op{#7}{#8}{#9}{% + \def\BS@abc{1001}% + }% + }% + \Test{And}% + {0}{0}{0}% + {0}{0}{0}% + {0}{0}{0001}% + \Test{AndNot}% + {0}{0}{0}% + {0}{0}{0}% + {1001}{1001}{1}% + \Test{Or}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{1101}% + \Test{Xor}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{11}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \csname bitset\Op\endcsname{abc}{foo}% + \RevCheck{foo}{#2}% + \RevCheck{abc}{#3}% + }% + \def\Op{And}% + \Test{1}{111}{1}% + \Test{111}{1}{1}% + \Test{10}{111}{10}% + \Test{111}{10}{10}% + \Test{111}{1000}{0}% + \Test{1000}{111}{0}% + \def\Op{AndNot}% + \Test{1010}{11}{1000}% + \Test{100}{100}{0}% + \Test{111}{1111}{0}% + \Test{100}{111}{0}% + \def\Op{Or}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{1}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \def\Op{Xor}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{0}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \Test {110011001100}% + {111000111000111}% + {111110100001011}% + \Test{111000111000111}% + {110011001100}% + {111110100001011}% +\end{qstest} + +\begin{qstest}{GetUndef}{GetUndef, GetBin, GetOct, GetHex} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \x{abc}{#1}% + }{#2}% + }% + \let\x\bitsetGetBin + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \let\x\bitsetGetOct + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{00}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{000}% + \TestUndef{8}{000}% + \TestUndef{9}{000}% + \TestUndef{10}{0000}% + \let\x\bitsetGetHex + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{0}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{00}% + \TestUndef{8}{00}% + \TestUndef{9}{000}% + \TestUndef{10}{000}% + \TestUndef{12}{000}% + \TestUndef{13}{0000}% + \TestUndef{16}{0000}% + \TestUndef{17}{00000}% +\end{qstest} + +\begin{qstest}{SetBin}{SetBin} + \def\Test#1#2{% + \let\BS@abc\@undefined + \bitsetSetBin{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{01}% + \Test{11}{11}% + \Test{010}{01}% + \Test{011}{11}% + \Test{0010}{01}% + \Test{1010}{0101}% +\end{qstest} + +\begin{qstest}{SetOct}{SetOct} + \def\Test#1#2{% + \bitsetSetOct{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{0001}% + \Test{020}{00001}% + \Test{42}{010001}% + \Test{377}{11111111}% + \Test{0377}{11111111}% + \Test{76543210}{000100010110001101011111}% + \Test{ 0 7 0 7 1 }{100111000111}% +\end{qstest} + +\begin{qstest}{SetHex}{SetHex} + \def\Test#1#2{% + \bitsetSetHex{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{00001}% + \Test{020}{000001}% + \Test{42}{0100001}% + \Test{3F}{111111}% + \Test{03F}{111111}% + \Test{43210}{0000100001001100001}% + \Test{98765}{10100110111000011001}% + \Test{FEDCBA}{010111010011101101111111}% + \Test{ 0 F 0 F 1 }{1000111100001111}% +\end{qstest} + +\begin{qstest}{SetDec}{SetDec} + \def\Test#1#2{% + \bitsetSetDec{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{7}{111}% + \Test{8}{0001}% + \Test{001}{1}% + \Test{010}{0101}% + \Test{020}{00101}% + \Test{53}{101011}% + \Test{255}{11111111}% + \Test{256}{000000001}% + \Test{999999999}{111111111001001101011001110111}% + \Test{1000000000}{000000000101001101011001110111}% + \Test{4210987654}{01100001010010010111111101011111}% + \Test{2147483647}{1111111111111111111111111111111}% + \Test{2147483648}{00000000000000000000000000000001}% +\end{qstest} + +\begin{qstest}{GetBin}{GetBin} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#2}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \Test{-1}{0}% + \Test{0}{0}% + \Test{1}{0}% + \Test{1}{1}% + \Test{2}{01}% + \Test{2}{10}% + \Test{3}{010}% + \Test{2}{00}% + \Test{2}{01}% + \Test{8}{00101100}% + \Test{2}{10101}% + \Test{-100}{11011}% +\end{qstest} + +\begin{qstest}{GetOct}{GetOct} + \def\Test#1#2#3{% + \edef\x{\zap@space#1 \@empty}% + \edef\x{\noexpand\bitsetSetBin{abc}{\x}}% + \x + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetOct{abc}{#2}% + }{#3}% + }% + \Test{111 110 101 100 011 010 001 000}{0}{76543210}% + \Test{000 111}{0}{7}% + \Test{101 000}{-1}{50}% + \Test{111}{-1}{7}% + \Test{111}{0}{7}% + \Test{111}{1}{7}% + \Test{111}{3}{7}% + \Test{111}{4}{07}% + \Test{111}{6}{07}% + \Test{111}{7}{007}% + \Test{111 010}{6}{72}% + \Test{111 010}{7}{072}% + \Test{011 111}{0}{37}% + \Test{011 111}{6}{37}% + \Test{011 111}{7}{037}% + \Test{001 111}{0}{17}% + \Test{001 111}{6}{17}% + \Test{001 111}{7}{017}% +\end{qstest} + +\begin{qstest}{GetHex}{GetHex} + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetHex{abc}{#2}% + }{#3}% + }% + \Test{1111 1110 1101 1100 1011 1010 1001 1000}{0}{FEDCBA98}% + \Test{0111 0110 0101 0100 0011 0010 0001 0000}{0}{76543210}% + \Test{0000 1111}{0}{F}% + \Test{0101 0000}{-1}{50}% + \Test{1111}{-1}{F}% + \Test{1111}{0}{F}% + \Test{1111}{1}{F}% + \Test{1111}{4}{F}% + \Test{1111}{5}{0F}% + \Test{1111}{8}{0F}% + \Test{1111}{9}{00F}% + \Test{1111 0010}{8}{F2}% + \Test{1111 0010}{9}{0F2}% + \Test{0111 1111}{0}{7F}% + \Test{0111 1111}{8}{7F}% + \Test{0111 1111}{9}{07F}% + \Test{0011 1111}{0}{3F}% + \Test{0011 1111}{8}{3F}% + \Test{0011 1111}{9}{03F}% + \Test{0001 1111}{0}{1F}% + \Test{0001 1111}{8}{1F}% + \Test{0001 1111}{9}{01F}% +\end{qstest} + +\begin{qstest}{Range}{Range} + \TestError{% + Wrong index numbers in range [9..8]\MessageBreak% hash-ok + for clear/set/flip on bit set `abc'.\MessageBreak + The lower index exceeds the upper index.\MessageBreak + Canceling the operation as error recovery% + }{% + \bitsetSetRange{abc}{9}{8}% + }% + \def\TestErrorNegInd#1#2#3#4#5#6{% + \TestError{% + Negative index in range [#2..#3]\MessageBreak % hash-ok + for \string\bitset #1Range on bit set `abc'.\MessageBreak + Using [#4..#5] as error recovery% hash-ok + }{% + \csname bitset#1Range\endcsname{abc}{#2}{#3}% + \global\let\BS@global\BS@abc + }% + \Check{global}{#6}% + }% + \Set{abc}{111}% + \TestErrorNegInd{Clear}{-1}{0}{0}{0}{111}% + \TestErrorNegInd{Clear}{0}{-1}{0}{0}{111}% + \TestErrorNegInd{Clear}{-2}{2}{0}{2}{001}% + \bitsetReset{abc}% + \TestErrorNegInd{Set}{-1}{0}{0}{0}{0}% + \TestErrorNegInd{Set}{0}{-1}{0}{0}{0}% + \TestErrorNegInd{Set}{-2}{2}{0}{2}{11}% + \Set{abc}{101}% + \TestErrorNegInd{Flip}{-1}{0}{0}{0}{101}% + \TestErrorNegInd{Flip}{0}{-1}{0}{0}{101}% + \TestErrorNegInd{Flip}{-2}{2}{0}{2}{011}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \csname bitset\TestOp Range\endcsname{abc}{#2}{#3}% + \Expect*{\bitsetGetBin{abc}{0}}{#4}% + }% + \def\TestOp{Clear}% + \Test{0}{0}{1}{0}% + \Test{1111}{1}{2}{1101}% + \Test{1111}{1}{3}{1001}% + \Test{1111111100000000}{12}{14}{1100111100000000}% + \def\TestOp{Set}% + \Test{0}{0}{1}{1}% + \Test{1000}{1}{2}{1010}% + \Test{0}{1}{2}{10}% + \Test{1}{12}{15}{111000000000001}% + \Test{1111}{1}{3}{1111}% + \Test{1000000000000000}{12}{14}{1011000000000000}% + \def\TestOp{Flip}% + \Test{0}{0}{1}{1}% + \Test{1}{0}{1}{0}% + \Test{10101010}{1}{5}{10110100}% + \def\Test#1#2#3#4#5{% + \bitsetSetBin{abc}{#1}% + \bitsetSetValueRange{abc}{#2}{#3}{#4}% + \Expect*{\bitsetGetBin{abc}{0}}{#5}% + }% + \Test{0}{0}{1}{0}{0}% + \Test{0}{0}{1}{1}{1}% + \Test{1010}{1}{3}{0}{1000}% + \Test{1010}{1}{3}{1}{1110}% +\end{qstest} + +\begin{qstest}{ShiftLeft/ShiftRight}{ShiftLeft/ShiftRight} + \def\@Test#1#2{% + \let\BS@abc\@undefined + \csname bitsetShift#1\endcsname{abc}{#2}% + \Expect*{\BS@abc}{0}% + }% + \def\Test#1{% + \@Test{Left}{#1}% + \@Test{Right}{#1}% + }% + \Test{-16}% + \Test{-1}% + \Test{0}% + \Test{1}% + \Test{16}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#3}% + \csname bitsetShift\Op\endcsname{abc}{#2}% + \Expect*{\bitsetGetBin{abc}{0}}*{\bitsetGetBin{result}{0}}% + }% + \def\Op{Left}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{10}% + \Test{1}{-1}{0}% + \Test{10}{1}{100}% + \Test{10}{-1}{1}% + \Test{1}{32}{100000000000000000000000000000000}% + \Test{1}{-100}{0}% + \def\Op{Right}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{0}% + \Test{1}{-1}{10}% + \Test{10}{1}{1}% + \Test{10}{-1}{100}% + \Test{1}{-32}{100000000000000000000000000000000}% + \Test{1}{100}{0}% + \Test{110110110110110}{10}{11011}% + \Test{110110110110110}{100}{0}% + \Test{1}{100000}{0}% +\end{qstest} + +\begin{qstest}{Profile: Set}{Profile: Set} + \bitsetSet{abc}{4095}% + \global\let\BS@global\BS@abc +\end{qstest} + +\begin{qstest}{Profile: Get}{Profile: Get} + \edef\x{\bitsetGet{global}{4095}}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `bitset-test2.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bitset-test3.tex b/Master/texmf-dist/doc/latex/oberdiek/bitset-test3.tex new file mode 100644 index 00000000000..a53c82704c8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bitset-test3.tex @@ -0,0 +1,1098 @@ +%% +%% This is file `bitset-test3.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bitset.dtx (with options: `test2,noetex') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bitset.dtx +%% and the derived files +%% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, +%% bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\makeatletter +\let\SavedNumexpr\numexpr +\let\SavedIfcsname\ifcsname +\let\SavedCurrentgrouplevel\currentgrouplevel +\def\ETeXDisable{% + \let\ifcsname\@undefined + \let\numexpr\@undefined + \let\currentgrouplevel\@undefined +} +\ETeXDisable +\makeatletter +\chardef\BitSet@TestMode=1 % +\makeatother +\usepackage{bitset}[2007/09/28] +\def\ETeXEnable{% + \let\numexpr\SavedNumexpr + \let\ifcsname\SavedIfcsname + \let\currentgrouplevel\SavedCurrentgrouplevel +} +\ETeXEnable +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\makeatletter +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% +\fi +\let\orig@qstest\qstest +\let\orig@endqstest\endqstest +\def\qstest#1#2{% + \orig@qstest{#1}{#2}% + \setbox0\hbox\bgroup\begingroup\ignorespaces +} +\def\endqstest{% + \endgroup\egroup + \Expect*{\the\wd0}{0.0pt}% + \orig@endqstest +} +\newcounter{Test} + +\def\TestError#1#2{% + \begingroup + \setcounter{Test}{0}% + \sbox0{% + \def\@PackageError##1##2##3{% + \stepcounter{Test}% + \begingroup + \let\MessageBreak\relax + \ETeXEnable + \Expect{##1}{bitset}% + \Expect*{##2}*{#1}% + \endgroup + }% + \ETeXDisable + #2% + }% + \Expect*{\theTest}{1}% + \Expect*{\the\wd0}{0.0pt}% + \endgroup +} + +\def\TestErrorNegativeIndex#1#2{% + \TestError{Invalid negative index (#1)}{#2}% +} + +\def\TestGetterUndefined#1{% + \CheckUndef{dummy}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1{dummy}}{0}% +} + +\def\ExpectBitSet#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\csname BS@#1\endcsname}*{#2}% +} +\def\Check#1#2{% + \ExpectBitSet{#1}{#2}% +} +\def\CheckUndef#1{% + \begingroup + \Expect*{% + \expandafter + \ifx\csname BS@#1\endcsname\relax true\else false\fi + }{true}% + \endgroup +} +\def\RevCheck#1#2{% + \ExpectBitSet{#1}{\Reverse#2!!}% +} +\def\Set#1#2{% + \expandafter\def\csname BS@#1\endcsname{#2}% +} +\def\RevSet#1#2{% + \expandafter\edef\csname BS@#1\endcsname{% + \Reverse#2!!% + }% +} +\def\Reverse#1#2!#3!{% + \ifx\\#2\\% + #1#3% + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\Reverse#2!#1#3!}% +} +\begin{qstest}{Let}{Let} + \CheckUndef{abc}% + \CheckUndef{xyz}% + \bitsetLet{xyz}{abc}% + \CheckUndef{abc}% + \Check{xyz}{0}% + \Set{abc}{1}% + \Check{abc}{1}% + \Check{xyz}{0}% + \bitsetLet{xyz}{abc}% + \Check{abc}{1}% + \Check{xyz}{1}% + \Set{xyz}{11}% + \Check{abc}{1}% + \Check{xyz}{11}% +\end{qstest} + +\begin{qstest}{Reset}{Reset} + \bitsetReset{xyz}% + \Check{xyz}{0}% + \bitsetReset{abc}% + \Check{abc}{0}% + \Set{abc}{10101}% + \bitsetReset{abc}% + \Check{abc}{0}% +\end{qstest} + +\begin{qstest}{Get/Query}{Get/Query} + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGet{dummy}{0}% + }{0}% + \begingroup + \expandafter\def\csname BitSetError:NegativeIndex\endcsname{}% + \Set{abc}{1}% + \Expect*{\bitsetQuery{abc}{-1}{true}{false}}{false}% + \endgroup + \def\Test#1#2#3{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetGet{abc}{#2}}{#3}% + \Expect*{\bitsetQuery{abc}{#2}{true}{false}}% + *{\ifcase#3 false\or true\else error\fi}% + }% + \Test{1}{100}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{11}{1}{1}% + \Test{111}{1}{1}% + \Test{101}{1}{0}% + \Test{101}{2}{1}% + \Test{10100110011}{10}{1}% +\end{qstest} + +\begin{qstest}{Size}{Size} + \TestGetterUndefined\bitsetSize + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetSize{abc}}{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{2}% + \Test{11}{2}% + \Test{010}{2}% + \Test{011}{3}% + \Test{100110011}{9}% + \Test{0000011111000001111100000}{20}% + \Test{000000000000000000000000011111111111111111111}{45}% +\end{qstest} + +\begin{qstest}{Cardinality}{Cardinality} + \TestGetterUndefined\bitsetCardinality + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetCardinality{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{1}% + \Test{11}{2}% + \Test{010}{1}% + \Test{011}{2}% + \Test{100110011}{5}% + \Test{0000011111000001111100000}{10}% + \Test{000000000000000000000000011111111111111111111}{20}% +\end{qstest} + +\begin{qstest}{NextClearBit/NextSetBit}{NextClearBit/NextSetBit} + \def\Test#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \TestOp{abc}{#1}% + }{#2}% + }% + \def\Clear{\let\TestOp\bitsetNextClearBit}% + \def\Set{\let\TestOp\bitsetNextSetBit}% + \begingroup + \catcode`\:=11 % + \bitsetSetBin{abc}{1}% + \Clear + \Test{-1}{1\BitSetError:NegativeIndex}% + \Set + \Test{-1}{0\BitSetError:NegativeIndex}% + \endgroup + \let\BS@abc\@undefined + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetReset{abc}% + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1}% + \Clear + \Test{0}{1}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111000111000111000111}% + \Clear + \Test{0}{3}% + \Test{1}{3}% + \Test{2}{3}% + \Test{3}{3}% + \Test{4}{4}% + \Test{5}{5}% + \Test{6}{9}% + \Test{7}{9}% + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{11}{11}% + \Test{12}{15}% + \Test{13}{15}% + \Test{14}{15}% + \Test{15}{15}% + \Test{16}{16}% + \Test{17}{17}% + \Test{18}{21}% + \Test{19}{21}% + \Test{20}{21}% + \Test{21}{21}% + \Test{22}{22}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{3}{6}% + \Test{4}{6}% + \Test{5}{6}% + \Test{6}{6}% + \Test{7}{7}% + \Test{8}{8}% + \Test{9}{12}% + \Test{10}{12}% + \Test{11}{12}% + \Test{12}{12}% + \Test{13}{13}% + \Test{14}{14}% + \Test{15}{18}% + \Test{16}{18}% + \Test{17}{18}% + \Test{18}{18}% + \Test{19}{19}% + \Test{20}{20}% + \Test{21}{-1}% + \Test{22}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111}% + \Clear + \Test{6}{7}% + \Test{7}{7}% + \Test{8}{8}% + \Test{100}{100}% + \Set + \Test{6}{6}% + \Test{7}{-1}% + \Test{8}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{11111111}% + \Clear + \Test{7}{8}% + \Test{8}{8}% + \Test{9}{9}% + \Test{100}{100}% + \Set + \Test{7}{7}% + \Test{8}{-1}% + \Test{9}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111111111}% + \Clear + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{100}{100}% + \Set + \Test{8}{8}% + \Test{9}{-1}% + \Test{10}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111111}% + \Clear + \Test{9}{10}% + \Test{10}{10}% + \Test{11}{11}% + \Test{100}{100}% + \Set + \Test{9}{9}% + \Test{10}{-1}% + \Test{11}{-1}% + \Test{100}{-1}% +\end{qstest} + +\begin{qstest}{GetSetBitList}{GetSetBitList} + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{#2}% + }% + \Test{0}{}% + \Test{1}{0}% + \Test{10}{1}% + \Test{11}{0,1}% + \Test{10110100}{2,4,5,7}% + \Test{101101001010011}{0,1,4,6,9,11,12,14}% +\end{qstest} + +\begin{qstest}{GetDec}{GetDec} + \TestGetterUndefined\bitsetGetDec + \def\Test#1#2{% + \RevSet{abc}{#1}% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetDec{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{2}% + \Test{11}{3}% + \Test{100}{4}% + \Test{101}{5}% + \Test{110}{6}% + \Test{111}{7}% + \Test{1000}{8}% + \Test{000111}{7}% + \Test{1111111111111111% + 111111111111111}{2147483647}% + \Test{0001111111111111111% + 111111111111111}{2147483647}% + \Test{1000000000000000% + 0000000000000000}{2147483648}% + \Test{1000000000000000% + 00000000000000000}{4294967296}% + \Test{0001000000000000000% + 00000000000000000}{4294967296}% + \Test{1100000000000000% + 00000000000000011}{6442450947}% +\end{qstest} + +\begin{qstest}{Clear}{Clear} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetClear{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetClear{abc}{2}% + \RevCheck{abc}{0}% + \TestErrorNegativeIndex{-1}{\bitsetClear{abc}{-1}}% + \RevCheck{abc}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{0}% + \Test{111}{1}{101}% + \Test{111}{30}{111}% + \Test{0000111}{5}{0000111}% 111 would also be ok + \Test{10000111}{5}{10000111}% + \Test{1001001}{3}{1000001}% +\end{qstest} + +\begin{qstest}{Set}{Set} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetSet{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetSet{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetSet{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{1}% + \Test{100}{1}{110}% + \Test{111}{1}{111}% + \Test{11}{1}{11}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1001001}% +\end{qstest} + +\begin{qstest}{Flip}{Flip} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetFlip{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetFlip{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetFlip{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{0}% + \Test{0}{2}{100}% + \Test{100}{1}{110}% + \Test{111}{1}{101}% + \Test{11}{1}{1}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1000001}% + \Test{11111}{2}{11011}% +\end{qstest} + +\begin{qstest}{SetValue}{SetValue} + \def\Test#1#2{% + \TestError{Invalid bit value (#2) not in range 0..1}{% + \bitsetSetValue{abc}{#1}{#2}% + }% + }% + \Test{0}{-1}% + \Test{0}{2}% + \Test{0}{10}% + \def\Test#1#2#3{% + \let\BS@abc\@undefined + \bitsetSetValue{abc}{#1}{#2}% + \bitsetSetBin{result}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}% + \Test{0}{1}{1}% + \Test{1}{0}{0}% + \Test{1}{1}{10}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#4}% + \bitsetSetValue{abc}{#2}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}{0}% + \Test{0}{0}{0}{0}% + \Test{0}{0}{1}{1}% + \Test{0}{1}{0}{0}% + \Test{0}{1}{1}{10}% + \Test{1010}{2}{1}{1110}% + \Test{1010}{4}{1}{11010}% + \Test{1010}{6}{1}{1001010}% + \Test{1010}{1}{0}{1000}% + \Test{1010}{2}{0}{1010}% + \Test{1010}{3}{0}{10}% + \Test{1010}{4}{0}{1010}% + \Test{1010}{6}{0}{1010}% + \Test{1010}{2}{\csname iffalse\endcsname 0\else 1\fi}{1110}% + \Test{1010}{1}{\csname iffalse\endcsname 1\else 0\fi}{1000}% +\end{qstest} + +\begin{qstest}{IsDefined}{IsDefined} + \let\BS@abc\@undefined + \Expect*{\bitsetIsDefined{abc}{true}{false}}{false}% + \bitsetReset{abc}% + \Expect*{\bitsetIsDefined{abc}{true}{false}}{true}% +\end{qstest} + +\begin{qstest}{IsEmpty}{IsEmpty} + \let\BS@abc\@undefined + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetReset{abc}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetSet{abc}{1}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{false}% +\end{qstest} + +\begin{qstest}{Equals}{Equals} + \def\Test#1#2#3{% + \Expect*{\bitsetEquals{#1}{#2}{true}{false}}{#3}% + }% + \let\BS@abc\@undefined + \Test{abc}{abc}{true}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetReset{abc}% + \Test{abc}{abc}{true}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetReset{foo}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetSet{abc}{4}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetFlip{foo}{4}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% +\end{qstest} + +\begin{qstest}{Intersects}{Intersects} + \def\Test#1{% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#1}% + }% + \let\BS@abc\@undefined + \let\BS@foo\@undefined + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \let\BS@abc\@undefined + \Test{false}% + \Set{foo}{1}% + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{abc}{1}% + \Test{true}% + \let\BS@foo\@undefined + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#3}% + }% + \Test{1010}{0101}{false}% + \Test{0}{10}{false}% + \Test{1}{11}{true}% + \Test{11}{1}{true}% + \Test{10}{1}{false}% +\end{qstest} + +\begin{qstest}{And/AndNot/Or/Xor}{And/AndNot/Or/Xor} + \def\@Test#1#2#3#4#5{% + \begingroup + #5% + \begingroup + \let\BS@foo\@undefined + \csname bitset#1\endcsname{abc}{foo}% + \CheckUndef{foo}% + \Check{abc}{#2}% + \endgroup + \begingroup + \bitsetReset{foo}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0}% + \Check{abc}{#3}% + \endgroup + \begingroup + \def\BS@foo{0101}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0101}% + \Check{abc}{#4}% + \endgroup + \endgroup + }% + \def\Test#1{% + \def\Op{#1}% + \Test@ + }% + \def\Test@#1#2#3#4#5#6#7#8#9{% + \@Test\Op{#1}{#2}{#3}{% + \let\BS@abc\@undefined + }% + \@Test\Op{#4}{#5}{#6}{% + \bitsetReset{abc}% + }% + \@Test\Op{#7}{#8}{#9}{% + \def\BS@abc{1001}% + }% + }% + \Test{And}% + {0}{0}{0}% + {0}{0}{0}% + {0}{0}{0001}% + \Test{AndNot}% + {0}{0}{0}% + {0}{0}{0}% + {1001}{1001}{1}% + \Test{Or}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{1101}% + \Test{Xor}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{11}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \csname bitset\Op\endcsname{abc}{foo}% + \RevCheck{foo}{#2}% + \RevCheck{abc}{#3}% + }% + \def\Op{And}% + \Test{1}{111}{1}% + \Test{111}{1}{1}% + \Test{10}{111}{10}% + \Test{111}{10}{10}% + \Test{111}{1000}{0}% + \Test{1000}{111}{0}% + \def\Op{AndNot}% + \Test{1010}{11}{1000}% + \Test{100}{100}{0}% + \Test{111}{1111}{0}% + \Test{100}{111}{0}% + \def\Op{Or}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{1}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \def\Op{Xor}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{0}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \Test {110011001100}% + {111000111000111}% + {111110100001011}% + \Test{111000111000111}% + {110011001100}% + {111110100001011}% +\end{qstest} + +\begin{qstest}{GetUndef}{GetUndef, GetBin, GetOct, GetHex} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \x{abc}{#1}% + }{#2}% + }% + \let\x\bitsetGetBin + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \let\x\bitsetGetOct + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{00}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{000}% + \TestUndef{8}{000}% + \TestUndef{9}{000}% + \TestUndef{10}{0000}% + \let\x\bitsetGetHex + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{0}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{00}% + \TestUndef{8}{00}% + \TestUndef{9}{000}% + \TestUndef{10}{000}% + \TestUndef{12}{000}% + \TestUndef{13}{0000}% + \TestUndef{16}{0000}% + \TestUndef{17}{00000}% +\end{qstest} + +\begin{qstest}{SetBin}{SetBin} + \def\Test#1#2{% + \let\BS@abc\@undefined + \bitsetSetBin{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{01}% + \Test{11}{11}% + \Test{010}{01}% + \Test{011}{11}% + \Test{0010}{01}% + \Test{1010}{0101}% +\end{qstest} + +\begin{qstest}{SetOct}{SetOct} + \def\Test#1#2{% + \bitsetSetOct{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{0001}% + \Test{020}{00001}% + \Test{42}{010001}% + \Test{377}{11111111}% + \Test{0377}{11111111}% + \Test{76543210}{000100010110001101011111}% + \Test{ 0 7 0 7 1 }{100111000111}% +\end{qstest} + +\begin{qstest}{SetHex}{SetHex} + \def\Test#1#2{% + \bitsetSetHex{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{00001}% + \Test{020}{000001}% + \Test{42}{0100001}% + \Test{3F}{111111}% + \Test{03F}{111111}% + \Test{43210}{0000100001001100001}% + \Test{98765}{10100110111000011001}% + \Test{FEDCBA}{010111010011101101111111}% + \Test{ 0 F 0 F 1 }{1000111100001111}% +\end{qstest} + +\begin{qstest}{SetDec}{SetDec} + \def\Test#1#2{% + \bitsetSetDec{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{7}{111}% + \Test{8}{0001}% + \Test{001}{1}% + \Test{010}{0101}% + \Test{020}{00101}% + \Test{53}{101011}% + \Test{255}{11111111}% + \Test{256}{000000001}% + \Test{999999999}{111111111001001101011001110111}% + \Test{1000000000}{000000000101001101011001110111}% + \Test{4210987654}{01100001010010010111111101011111}% + \Test{2147483647}{1111111111111111111111111111111}% + \Test{2147483648}{00000000000000000000000000000001}% +\end{qstest} + +\begin{qstest}{GetBin}{GetBin} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#2}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \Test{-1}{0}% + \Test{0}{0}% + \Test{1}{0}% + \Test{1}{1}% + \Test{2}{01}% + \Test{2}{10}% + \Test{3}{010}% + \Test{2}{00}% + \Test{2}{01}% + \Test{8}{00101100}% + \Test{2}{10101}% + \Test{-100}{11011}% +\end{qstest} + +\begin{qstest}{GetOct}{GetOct} + \def\Test#1#2#3{% + \edef\x{\zap@space#1 \@empty}% + \edef\x{\noexpand\bitsetSetBin{abc}{\x}}% + \x + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetOct{abc}{#2}% + }{#3}% + }% + \Test{111 110 101 100 011 010 001 000}{0}{76543210}% + \Test{000 111}{0}{7}% + \Test{101 000}{-1}{50}% + \Test{111}{-1}{7}% + \Test{111}{0}{7}% + \Test{111}{1}{7}% + \Test{111}{3}{7}% + \Test{111}{4}{07}% + \Test{111}{6}{07}% + \Test{111}{7}{007}% + \Test{111 010}{6}{72}% + \Test{111 010}{7}{072}% + \Test{011 111}{0}{37}% + \Test{011 111}{6}{37}% + \Test{011 111}{7}{037}% + \Test{001 111}{0}{17}% + \Test{001 111}{6}{17}% + \Test{001 111}{7}{017}% +\end{qstest} + +\begin{qstest}{GetHex}{GetHex} + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetHex{abc}{#2}% + }{#3}% + }% + \Test{1111 1110 1101 1100 1011 1010 1001 1000}{0}{FEDCBA98}% + \Test{0111 0110 0101 0100 0011 0010 0001 0000}{0}{76543210}% + \Test{0000 1111}{0}{F}% + \Test{0101 0000}{-1}{50}% + \Test{1111}{-1}{F}% + \Test{1111}{0}{F}% + \Test{1111}{1}{F}% + \Test{1111}{4}{F}% + \Test{1111}{5}{0F}% + \Test{1111}{8}{0F}% + \Test{1111}{9}{00F}% + \Test{1111 0010}{8}{F2}% + \Test{1111 0010}{9}{0F2}% + \Test{0111 1111}{0}{7F}% + \Test{0111 1111}{8}{7F}% + \Test{0111 1111}{9}{07F}% + \Test{0011 1111}{0}{3F}% + \Test{0011 1111}{8}{3F}% + \Test{0011 1111}{9}{03F}% + \Test{0001 1111}{0}{1F}% + \Test{0001 1111}{8}{1F}% + \Test{0001 1111}{9}{01F}% +\end{qstest} + +\begin{qstest}{Range}{Range} + \TestError{% + Wrong index numbers in range [9..8]\MessageBreak% hash-ok + for clear/set/flip on bit set `abc'.\MessageBreak + The lower index exceeds the upper index.\MessageBreak + Canceling the operation as error recovery% + }{% + \bitsetSetRange{abc}{9}{8}% + }% + \def\TestErrorNegInd#1#2#3#4#5#6{% + \TestError{% + Negative index in range [#2..#3]\MessageBreak % hash-ok + for \string\bitset #1Range on bit set `abc'.\MessageBreak + Using [#4..#5] as error recovery% hash-ok + }{% + \csname bitset#1Range\endcsname{abc}{#2}{#3}% + \global\let\BS@global\BS@abc + }% + \Check{global}{#6}% + }% + \Set{abc}{111}% + \TestErrorNegInd{Clear}{-1}{0}{0}{0}{111}% + \TestErrorNegInd{Clear}{0}{-1}{0}{0}{111}% + \TestErrorNegInd{Clear}{-2}{2}{0}{2}{001}% + \bitsetReset{abc}% + \TestErrorNegInd{Set}{-1}{0}{0}{0}{0}% + \TestErrorNegInd{Set}{0}{-1}{0}{0}{0}% + \TestErrorNegInd{Set}{-2}{2}{0}{2}{11}% + \Set{abc}{101}% + \TestErrorNegInd{Flip}{-1}{0}{0}{0}{101}% + \TestErrorNegInd{Flip}{0}{-1}{0}{0}{101}% + \TestErrorNegInd{Flip}{-2}{2}{0}{2}{011}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \csname bitset\TestOp Range\endcsname{abc}{#2}{#3}% + \Expect*{\bitsetGetBin{abc}{0}}{#4}% + }% + \def\TestOp{Clear}% + \Test{0}{0}{1}{0}% + \Test{1111}{1}{2}{1101}% + \Test{1111}{1}{3}{1001}% + \Test{1111111100000000}{12}{14}{1100111100000000}% + \def\TestOp{Set}% + \Test{0}{0}{1}{1}% + \Test{1000}{1}{2}{1010}% + \Test{0}{1}{2}{10}% + \Test{1}{12}{15}{111000000000001}% + \Test{1111}{1}{3}{1111}% + \Test{1000000000000000}{12}{14}{1011000000000000}% + \def\TestOp{Flip}% + \Test{0}{0}{1}{1}% + \Test{1}{0}{1}{0}% + \Test{10101010}{1}{5}{10110100}% + \def\Test#1#2#3#4#5{% + \bitsetSetBin{abc}{#1}% + \bitsetSetValueRange{abc}{#2}{#3}{#4}% + \Expect*{\bitsetGetBin{abc}{0}}{#5}% + }% + \Test{0}{0}{1}{0}{0}% + \Test{0}{0}{1}{1}{1}% + \Test{1010}{1}{3}{0}{1000}% + \Test{1010}{1}{3}{1}{1110}% +\end{qstest} + +\begin{qstest}{ShiftLeft/ShiftRight}{ShiftLeft/ShiftRight} + \def\@Test#1#2{% + \let\BS@abc\@undefined + \csname bitsetShift#1\endcsname{abc}{#2}% + \Expect*{\BS@abc}{0}% + }% + \def\Test#1{% + \@Test{Left}{#1}% + \@Test{Right}{#1}% + }% + \Test{-16}% + \Test{-1}% + \Test{0}% + \Test{1}% + \Test{16}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#3}% + \csname bitsetShift\Op\endcsname{abc}{#2}% + \Expect*{\bitsetGetBin{abc}{0}}*{\bitsetGetBin{result}{0}}% + }% + \def\Op{Left}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{10}% + \Test{1}{-1}{0}% + \Test{10}{1}{100}% + \Test{10}{-1}{1}% + \Test{1}{32}{100000000000000000000000000000000}% + \Test{1}{-100}{0}% + \def\Op{Right}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{0}% + \Test{1}{-1}{10}% + \Test{10}{1}{1}% + \Test{10}{-1}{100}% + \Test{1}{-32}{100000000000000000000000000000000}% + \Test{1}{100}{0}% + \Test{110110110110110}{10}{11011}% + \Test{110110110110110}{100}{0}% + \Test{1}{100000}{0}% +\end{qstest} + +\begin{qstest}{Profile: Set}{Profile: Set} + \bitsetSet{abc}{4095}% + \global\let\BS@global\BS@abc +\end{qstest} + +\begin{qstest}{Profile: Get}{Profile: Get} + \edef\x{\bitsetGet{global}{4095}}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `bitset-test3.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/bitset.pdf b/Master/texmf-dist/doc/latex/oberdiek/bitset.pdf Binary files differnew file mode 100644 index 00000000000..63d66e5ca3b --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/bitset.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/bmpsize.pdf b/Master/texmf-dist/doc/latex/oberdiek/bmpsize.pdf Binary files differindex 38a9d015985..1682862d0e4 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/bmpsize.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/bmpsize.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/bookmark-example.tex b/Master/texmf-dist/doc/latex/oberdiek/bookmark-example.tex index 3b9f96c73a3..2f37d6a4868 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/bookmark-example.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/bookmark-example.tex @@ -36,7 +36,7 @@ open, openlevel=2, atend -]{bookmark}[2007/07/13] +]{bookmark}[2007/09/25] \bookmarksetup{color=blue} diff --git a/Master/texmf-dist/doc/latex/oberdiek/bookmark.pdf b/Master/texmf-dist/doc/latex/oberdiek/bookmark.pdf Binary files differindex bc3a7579cd7..bd3871ea352 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/bookmark.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/bookmark.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/catchfile.pdf b/Master/texmf-dist/doc/latex/oberdiek/catchfile.pdf Binary files differindex 3a35aacfec7..358a40fb0b6 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/catchfile.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/catchfile.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/centernot.pdf b/Master/texmf-dist/doc/latex/oberdiek/centernot.pdf Binary files differindex 20dd81068b3..70a386e60db 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/centernot.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/centernot.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/chemarr.pdf b/Master/texmf-dist/doc/latex/oberdiek/chemarr.pdf Binary files differindex e6dfd612014..2b54bf53e66 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/chemarr.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/chemarr.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/classlist.pdf b/Master/texmf-dist/doc/latex/oberdiek/classlist.pdf Binary files differindex 2004fb73c0c..7e89d712854 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/classlist.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/classlist.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/colonequals.pdf b/Master/texmf-dist/doc/latex/oberdiek/colonequals.pdf Binary files differindex 878227378f8..5afe5c47c2d 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/colonequals.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/colonequals.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/dvipscol.pdf b/Master/texmf-dist/doc/latex/oberdiek/dvipscol.pdf Binary files differindex 8e4dc085b94..a7b397aae97 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/dvipscol.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/dvipscol.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/embedfile.pdf b/Master/texmf-dist/doc/latex/oberdiek/embedfile.pdf Binary files differindex 16879df7209..096ba1907f9 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/embedfile.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/embedfile.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/engord.pdf b/Master/texmf-dist/doc/latex/oberdiek/engord.pdf Binary files differindex 491fe2b0317..58cca6539f6 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/engord.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/engord.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/epstopdf-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/epstopdf-test1.tex new file mode 100644 index 00000000000..86f8a5979e4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/epstopdf-test1.tex @@ -0,0 +1,78 @@ +%% +%% This is file `epstopdf-test1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% epstopdf.dtx (with options: `test1') +%% +%% This is a generated file. +%% +%% Copyright (C) 2001, 2006, 2007 by +%% Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file epstopdf.dtx +%% and the derived files +%% epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv, +%% epstopdf-test1.tex. +%% +\input miniltx.tex\relax +\def\Gin@driver{pdftex.def} +\input graphicx.sty\relax +\resetatcatcode +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input epstopdf.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +\endinput +%% +%% End of file `epstopdf-test1.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/epstopdf.pdf b/Master/texmf-dist/doc/latex/oberdiek/epstopdf.pdf Binary files differindex 473b244bf42..e0ddff965a1 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/epstopdf.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/epstopdf.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/etexcmds.pdf b/Master/texmf-dist/doc/latex/oberdiek/etexcmds.pdf Binary files differindex df64101c42d..8bc0f6bc822 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/etexcmds.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/etexcmds.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/example-mycolorsetup.sty b/Master/texmf-dist/doc/latex/oberdiek/example-mycolorsetup.sty index 8b58b76c8e5..25a123d91d7 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/example-mycolorsetup.sty +++ b/Master/texmf-dist/doc/latex/oberdiek/example-mycolorsetup.sty @@ -26,15 +26,15 @@ %% This work consists of the main source file kvoptions.dtx %% and the derived files %% kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, -%% example-mycolorsetup.sty. +%% example-mycolorsetup.sty, kvoptions-test1.tex. %% %% No we don't need the option 'color'. -%% With color support option 'emphcolor' will dynamically change -%% the color of \emph statements. +%% With color support option 'emphcolor' will dynamically +%% change the color of \emph statements. % Package identification % ----------------------- \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{example-mycolorsetup}[2007/06/11 Managing my colors] +\ProvidesPackage{example-mycolorsetup}[2007/10/02 Managing my colors] \RequirePackage{ifpdf} \RequirePackage{kvoptions} @@ -92,7 +92,8 @@ }% % Pass the option to package color. % Again it is better to expand \CurrentOption. - \expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{color}% + \expandafter\PassOptionsToPackage + \expandafter{\CurrentOption}{color}% \else % Package color does not take options with values. % We provide the standard LaTeX error. diff --git a/Master/texmf-dist/doc/latex/oberdiek/flags.pdf b/Master/texmf-dist/doc/latex/oberdiek/flags.pdf Binary files differindex dca6f662d3d..8f4f4c5bcf4 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/flags.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/flags.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/grfext-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/grfext-test1.tex new file mode 100644 index 00000000000..4d8e64b1138 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/grfext-test1.tex @@ -0,0 +1,75 @@ +%% +%% This is file `grfext-test1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% grfext.dtx (with options: `test1') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file grfext.dtx +%% and the derived files +%% grfext.sty, grfext.pdf, grfext.ins, grfext.drv, +%% grfext-test1.tex, grfext-test2.tex. +%% +\input miniltx.tex\relax +\resetatcatcode +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input grfext.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +\endinput +%% +%% End of file `grfext-test1.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/grfext-test2.tex b/Master/texmf-dist/doc/latex/oberdiek/grfext-test2.tex new file mode 100644 index 00000000000..514e0710c2d --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/grfext-test2.tex @@ -0,0 +1,169 @@ +%% +%% This is file `grfext-test2.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% grfext.dtx (with options: `test2') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file grfext.dtx +%% and the derived files +%% grfext.sty, grfext.pdf, grfext.ins, grfext.drv, +%% grfext-test1.tex, grfext-test2.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\usepackage[pdftex]{graphics} +\usepackage{grfext}[2007/09/30] +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\makeatletter +\let\orig@qstest\qstest +\let\orig@endqstest\endqstest +\def\qstest#1#2{% + \orig@qstest{#1}{#2}% + \setbox0\hbox\bgroup\begingroup\ignorespaces +} +\def\endqstest{% + \endgroup\egroup + \Expect*{\the\wd0}{0.0pt}% + \orig@endqstest +} +\def\Test{\@ifnextchar\bgroup\TestInitList\TestInitCmd}% +\def\TestInitList#1{% + \def\Gin@extensions{#1}% + \@Test +} +\def\TestInitCmd#1{% + \let\Gin@extensions#1\relax + \@Test +} +\def\@Test#1#2{% + \TestCmd{#1}% + \expandafter\Expect\expandafter*{\Gin@extensions}{#2}% +} +\begin{qstest}{AppendGraphicsExtensions}{AppendGraphicsExtensions} + \let\TestCmd\AppendGraphicsExtensions + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.foo,.test}% + \Test{.foo,.bar}{.test}{.foo,.bar,.test}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.foo,.test}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar,.test}% + \Test{.foo}{.test,.bar}{.foo,.test,.bar}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \Test{.foo}{ .test ,.bar , .x, .y }{.foo,.test,.bar,.x,.y}% + \def\TestCmd{\AppendGraphicsExtensions*}% + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.test}{.test}{.test}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.test,.bar}% + \Test{.foo}{.test,.bar}{.foo}% + \Test{.foo}{.test,.foo}{.foo}% + \DeclareGraphicsRule{.test}{test}{.test}{}% + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.foo,.test}% + \Test{.foo,.bar}{.test}{.foo,.bar,.test}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.foo,.test}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar,.test}% + \Test{.foo}{.test,.bar}{.foo,.test}% + \Test{.foo}{.test,.foo}{.foo,.test}% + \DeclareGraphicsRule{.bar}{bar}{.bar}{}% + \Test{.foo}{.test,.bar}{.foo,.test,.bar}% + \Test{.bar}{.test,.bar}{.test,.bar}% + \Test{.bar}{.bar,.test}{.bar,.test}% +\end{qstest} +\begin{qstest}{PrependGraphicsExtensions}{PrependGraphicsExtensions} + \let\TestCmd\PrependGraphicsExtensions + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.test,.foo}% + \Test{.foo,.bar}{.test}{.test,.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.test,.foo}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.test,.foo,.bar}% + \Test{.foo}{.test,.bar}{.test,.bar,.foo}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \Test{.foo}{ .test ,.bar , .x, .y }{.test,.bar,.x,.y,.foo}% + \def\TestCmd{\PrependGraphicsExtensions*}% + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.test}{.test}{.test}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.test,.bar}% + \DeclareGraphicsRule{.test}{test}{.test}{}% + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.test,.foo}% + \Test{.foo,.bar}{.test}{.test,.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.test,.foo}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.test,.foo,.bar}% + \Test{.foo}{.test,.bar}{.test,.foo}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \DeclareGraphicsRule{.bar}{bar}{.bar}{}% + \Test{.foo}{.test,.bar}{.test,.bar,.foo}% + \Test{.bar}{.test,.bar}{.test,.bar}% + \Test{.bar}{.bar,.test}{.bar,.test}% +\end{qstest} +\begin{qstest}{RemoveGraphicsExtensions}{RemoveGraphicsExtensions} + \let\TestCmd\RemoveGraphicsExtensions + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{}% + \Test{.foo,.test}{.test}{.foo}% + \Test{.test,.foo}{.test}{.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar}% + \Test{.test,.test}{.test}{}% + \Test{.foo,.test,.bar,.test,.test,.bar}{.test}{.foo,.bar,.bar}% + \Test{.foo,.test,.bar,.foo,.test,.bar}{.test,.bar}{.foo,.foo}% + \Test{.foo,.test,.bar,.foo,.test,.bar}{ .test , .bar }{.foo,.foo}% +\end{qstest} +\begin{document} +\end{document} +\endinput +%% +%% End of file `grfext-test2.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/grfext.pdf b/Master/texmf-dist/doc/latex/oberdiek/grfext.pdf Binary files differnew file mode 100644 index 00000000000..cbbc935c8e7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/grfext.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/grffile.pdf b/Master/texmf-dist/doc/latex/oberdiek/grffile.pdf Binary files differindex 4300cbcfd67..6fcc0b72d3d 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/grffile.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/grffile.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/holtxdoc.pdf b/Master/texmf-dist/doc/latex/oberdiek/holtxdoc.pdf Binary files differindex f0bd0b4382d..f25036ee563 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/holtxdoc.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/holtxdoc.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/hycolor.pdf b/Master/texmf-dist/doc/latex/oberdiek/hycolor.pdf Binary files differindex 886869ff5fd..fd2b832c00c 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/hycolor.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/hycolor.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/hypbmsec.pdf b/Master/texmf-dist/doc/latex/oberdiek/hypbmsec.pdf Binary files differindex 0f11ac7e7f1..05602d321d4 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/hypbmsec.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/hypbmsec.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/hypcap.pdf b/Master/texmf-dist/doc/latex/oberdiek/hypcap.pdf Binary files differindex e0eff055795..35d7632dfff 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/hypcap.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/hypcap.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/hypdestopt.pdf b/Master/texmf-dist/doc/latex/oberdiek/hypdestopt.pdf Binary files differindex f07ab610914..43e229a83fd 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/hypdestopt.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/hypdestopt.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/hypdoc.pdf b/Master/texmf-dist/doc/latex/oberdiek/hypdoc.pdf Binary files differindex cc9da5e337d..7fa447c6033 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/hypdoc.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/hypdoc.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/ifdraft.pdf b/Master/texmf-dist/doc/latex/oberdiek/ifdraft.pdf Binary files differindex 5c8482788c0..ade2cd5a7e3 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/ifdraft.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/ifdraft.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/iflang.pdf b/Master/texmf-dist/doc/latex/oberdiek/iflang.pdf Binary files differindex 114445b261a..df6371bf6ab 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/iflang.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/iflang.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/ifpdf.pdf b/Master/texmf-dist/doc/latex/oberdiek/ifpdf.pdf Binary files differindex d86aac82fac..6b5ad56372d 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/ifpdf.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/ifpdf.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/ifvtex.pdf b/Master/texmf-dist/doc/latex/oberdiek/ifvtex.pdf Binary files differindex 13118cfc8eb..580daf5cb9c 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/ifvtex.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/ifvtex.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/infwarerr.pdf b/Master/texmf-dist/doc/latex/oberdiek/infwarerr.pdf Binary files differindex 15a8262dc71..3821ac1eda9 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/infwarerr.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/infwarerr.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/inputenx.pdf b/Master/texmf-dist/doc/latex/oberdiek/inputenx.pdf Binary files differindex 506a04bf47a..9203ca9e90e 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/inputenx.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/inputenx.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test2.tex b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test2.tex index 696816c6f80..8242acd1ee7 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test2.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test2.tex @@ -32,9 +32,9 @@ \nofiles \documentclass{article} \makeatletter -\chardef\IntCalc@TestMode=1 % +\chardef\InCa@TestMode=1 % \makeatother -\usepackage{intcalc}[2007/09/09] +\usepackage{intcalc}[2007/09/27] \usepackage{qstest} \IncludeTests{*} \LogTests{log}{*}{*} @@ -67,6 +67,9 @@ \newcommand*{\TestInv}[2]{% \Test{\intcalcInv{#1}}{#2}% } +\newcommand*{\TestNum}[2]{% + \Test{\intcalcNum{#1}}{#2}% +} \newcommand*{\TestAbs}[2]{% \Test{\intcalcAbs{#1}}{#2}% } @@ -84,24 +87,92 @@ } \newcommand*{\TestInc}[2]{% \Test{\intcalcInc{#1}}{#2}% + \ifnum\intcalcNum{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcInc\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestDec}[2]{% \Test{\intcalcDec{#1}}{#2}% + \ifnum\intcalcNum{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDec\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestAdd}[3]{% \Test{\intcalcAdd{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#2}!\intcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestSub}[3]{% \Test{\intcalcSub{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcSub + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestShl}[2]{% \Test{\intcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShl\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestShr}[2]{% \Test{\intcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShr\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestMul}[3]{% \Test{\intcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMul\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x } \newcommand*{\TestSqr}[2]{% \Test{\intcalcSqr{#1}}{#2}% @@ -115,12 +186,93 @@ \newcommand*{\TestDiv}[3]{% \Test{\intcalcDiv{#1}{#2}}{#3}% \TestTeXDivide{#1}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDiv\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% } \newcommand*{\TestMod}[3]{% \Test{\intcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\intcalcSgn{#1} 0% + \or + \ifcase\intcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\intcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMod + \intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x + \fi } +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi \makeatletter +\begin{qstest}{num}{num}% + \TestNum{0}{0}% + \TestNum{1}{1}% + \TestNum{-1}{-1}% + \TestNum{10}{10}% + \TestNum{-10}{-10}% + \TestNum{2147483647}{2147483647}% + \TestNum{-2147483647}{-2147483647}% + \TestNum{ 0 }{0}% + \TestNum{ 1 }{1}% + \TestNum{--1}{1}% + \TestNum{ - + - + 4 }{4}% + \TestNum{\z@}{0}% + \TestNum{\@ne}{1}% + \TestNum{\m@ne}{-1}% + \TestNum{-10+30}{20}% + \TestNum{10-30}{-20}% +\end{qstest} + \begin{qstest}{inv}{inv}% \TestInv{0}{0}% \TestInv{1}{-1}% @@ -324,6 +476,8 @@ \TestShl{1}{2}% \TestShl{5621}{11242}% \TestShl{1073741823}{2147483646}% + \TestShl{-1}{-2}% + \TestShl{-5621}{-11242}% \end{qstest} \begin{qstest}{shr}{shr} @@ -353,6 +507,10 @@ \TestShr{11241}{5620}% \TestShr{73054202}{36527101}% \TestShr{2147483646}{1073741823}% + \TestShr{-1}{0}% + \TestShr{-2}{-1}% + \TestShr{-3}{-1}% + \TestShr{-11241}{-5620}% \end{qstest} \begin{qstest}{mul}{mul} @@ -583,11 +741,11 @@ \TestError{FacNegative}{\intcalcFac{-2147483647}}% \TestError{FacOverflow}{\intcalcFac{13}}% \TestError{FacOverflow}{\intcalcFac{2147483647}}% - \TestError{ShlNegativeNumber}{\intcalcShl{-1}}% - \TestError{ShrNegativeNumber}{\intcalcShr{-1}}% \TestError{DivisionByZero}{\intcalcPow{0}{-1}}% \TestError{DivisionByZero}{\intcalcDiv{1}{0}}% \TestError{DivisionByZero}{\intcalcMod{1}{0}}% + \TestError{DivisionByZero}{\IntCalcDiv1!0!}% + \TestError{DivisionByZero}{\IntCalcMod1!0!}% \end{qstest} \begin{document} diff --git a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test3.tex b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test3.tex index c01bff1c246..4874311d1f0 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test3.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test3.tex @@ -4,7 +4,7 @@ %% %% The original source files were: %% -%% intcalc.dtx (with options: `test3,noetex') +%% intcalc.dtx (with options: `test2,noetex') %% %% This is a generated file. %% @@ -34,9 +34,9 @@ \let\SavedNumexpr\numexpr \let\numexpr\UNDEFINED \makeatletter -\chardef\IntCalc@TestMode=1 % +\chardef\InCa@TestMode=1 % \makeatother -\usepackage{intcalc}[2007/09/09] +\usepackage{intcalc}[2007/09/27] \let\numexpr\SavedNumexpr \usepackage{qstest} \IncludeTests{*} @@ -80,6 +80,9 @@ \newcommand*{\TestInv}[2]{% \Test{\intcalcInv{#1}}{#2}% } +\newcommand*{\TestNum}[2]{% + \Test{\intcalcNum{#1}}{#2}% +} \newcommand*{\TestAbs}[2]{% \Test{\intcalcAbs{#1}}{#2}% } @@ -97,24 +100,92 @@ } \newcommand*{\TestInc}[2]{% \Test{\intcalcInc{#1}}{#2}% + \ifnum\intcalcNum{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcInc\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestDec}[2]{% \Test{\intcalcDec{#1}}{#2}% + \ifnum\intcalcNum{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDec\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestAdd}[3]{% \Test{\intcalcAdd{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#2}!\intcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestSub}[3]{% \Test{\intcalcSub{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcSub + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestShl}[2]{% \Test{\intcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShl\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestShr}[2]{% \Test{\intcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShr\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestMul}[3]{% \Test{\intcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMul\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x } \newcommand*{\TestSqr}[2]{% \Test{\intcalcSqr{#1}}{#2}% @@ -128,12 +199,91 @@ \newcommand*{\TestDiv}[3]{% \Test{\intcalcDiv{#1}{#2}}{#3}% \TestTeXDivide{#1}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDiv\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% } \newcommand*{\TestMod}[3]{% \Test{\intcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\intcalcSgn{#1} 0% + \or + \ifcase\intcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\intcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMod + \intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x + \fi } +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi \makeatletter +\begin{qstest}{num}{num}% + \TestNum{0}{0}% + \TestNum{1}{1}% + \TestNum{-1}{-1}% + \TestNum{10}{10}% + \TestNum{-10}{-10}% + \TestNum{2147483647}{2147483647}% + \TestNum{-2147483647}{-2147483647}% + \TestNum{ 0 }{0}% + \TestNum{ 1 }{1}% + \TestNum{--1}{1}% + \TestNum{ - + - + 4 }{4}% + \TestNum{\z@}{0}% + \TestNum{\@ne}{1}% + \TestNum{\m@ne}{-1}% +\end{qstest} + \begin{qstest}{inv}{inv}% \TestInv{0}{0}% \TestInv{1}{-1}% @@ -324,6 +474,8 @@ \TestShl{1}{2}% \TestShl{5621}{11242}% \TestShl{1073741823}{2147483646}% + \TestShl{-1}{-2}% + \TestShl{-5621}{-11242}% \end{qstest} \begin{qstest}{shr}{shr} @@ -353,6 +505,10 @@ \TestShr{11241}{5620}% \TestShr{73054202}{36527101}% \TestShr{2147483646}{1073741823}% + \TestShr{-1}{0}% + \TestShr{-2}{-1}% + \TestShr{-3}{-1}% + \TestShr{-11241}{-5620}% \end{qstest} \begin{qstest}{mul}{mul} @@ -576,11 +732,11 @@ \TestError{FacNegative}{\intcalcFac{-2147483647}}% \TestError{FacOverflow}{\intcalcFac{13}}% \TestError{FacOverflow}{\intcalcFac{2147483647}}% - \TestError{ShlNegativeNumber}{\intcalcShl{-1}}% - \TestError{ShrNegativeNumber}{\intcalcShr{-1}}% \TestError{DivisionByZero}{\intcalcPow{0}{-1}}% \TestError{DivisionByZero}{\intcalcDiv{1}{0}}% \TestError{DivisionByZero}{\intcalcMod{1}{0}}% + \TestError{DivisionByZero}{\IntCalcDiv1!0!}% + \TestError{DivisionByZero}{\IntCalcMod1!0!}% \end{qstest} \begin{document} diff --git a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test4.tex b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test4.tex index 9d4d2391743..021744f16dd 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/intcalc-test4.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/intcalc-test4.tex @@ -32,9 +32,9 @@ \nofiles \documentclass{article} \makeatletter -\chardef\IntCalc@TestMode=1 % +\chardef\InCa@TestMode=1 % \makeatother -\usepackage{intcalc}[2007/09/09] +\usepackage{intcalc}[2007/09/27] \usepackage{qstest} \IncludeTests{*} \LogTests{log}{*}{*} @@ -58,6 +58,7 @@ \TestDo{#1}{#2}% \TestDo{#2}{#1}% } +\let\TestNum\TestOne \let\TestInv\TestOne \let\TestAbs\TestOne \let\TestSgn\TestOne @@ -78,6 +79,25 @@ \let\TestMod\TestTwo \makeatletter +\begin{qstest}{num}{num}% + \TestNum{0}{0}% + \TestNum{1}{1}% + \TestNum{-1}{-1}% + \TestNum{10}{10}% + \TestNum{-10}{-10}% + \TestNum{2147483647}{2147483647}% + \TestNum{-2147483647}{-2147483647}% + \TestNum{ 0 }{0}% + \TestNum{ 1 }{1}% + \TestNum{--1}{1}% + \TestNum{ - + - + 4 }{4}% + \TestNum{\z@}{0}% + \TestNum{\@ne}{1}% + \TestNum{\m@ne}{-1}% + \TestNum{-10+30}{20}% + \TestNum{10-30}{-20}% +\end{qstest} + \begin{qstest}{inv}{inv}% \TestInv{0}{0}% \TestInv{1}{-1}% @@ -281,6 +301,8 @@ \TestShl{1}{2}% \TestShl{5621}{11242}% \TestShl{1073741823}{2147483646}% + \TestShl{-1}{-2}% + \TestShl{-5621}{-11242}% \end{qstest} \begin{qstest}{shr}{shr} @@ -310,6 +332,10 @@ \TestShr{11241}{5620}% \TestShr{73054202}{36527101}% \TestShr{2147483646}{1073741823}% + \TestShr{-1}{0}% + \TestShr{-2}{-1}% + \TestShr{-3}{-1}% + \TestShr{-11241}{-5620}% \end{qstest} \begin{qstest}{mul}{mul} diff --git a/Master/texmf-dist/doc/latex/oberdiek/intcalc.pdf b/Master/texmf-dist/doc/latex/oberdiek/intcalc.pdf Binary files differindex a3978b992e8..161a3b40d2b 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/intcalc.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/intcalc.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvoptions-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/kvoptions-test1.tex new file mode 100644 index 00000000000..de0a68d2468 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/kvoptions-test1.tex @@ -0,0 +1,78 @@ +%% +%% This is file `kvoptions-test1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% kvoptions.dtx (with options: `test1') +%% +%% This is a generated file. +%% +%% Copyright (C) 2004, 2006, 2007 by +%% Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file kvoptions.dtx +%% and the derived files +%% kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, +%% example-mycolorsetup.sty, kvoptions-test1.tex. +%% +%% No we don't need the option 'color'. +%% With color support option 'emphcolor' will dynamically +%% change the color of \emph statements. +\input miniltx.tex\relax +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input kvoptions.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +\endinput +%% +%% End of file `kvoptions-test1.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvoptions.pdf b/Master/texmf-dist/doc/latex/oberdiek/kvoptions.pdf Binary files differindex 57996c95bab..89e71b5133b 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/kvoptions.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/kvoptions.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-example.tex b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-example.tex index 1466159e2db..8f78800f374 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-example.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-example.tex @@ -25,7 +25,8 @@ %% This work consists of the main source file kvsetkeys.dtx %% and the derived files %% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, -%% kvsetkeys-example.tex, kvsetkeys-test1.tex. +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex. %% \documentclass{article} \usepackage[T1]{fontenc} diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test1.tex b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test1.tex index 718ce0bced8..14225a1cd0b 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test1.tex +++ b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test1.tex @@ -25,7 +25,8 @@ %% This work consists of the main source file kvsetkeys.dtx %% and the derived files %% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, -%% kvsetkeys-example.tex, kvsetkeys-test1.tex. +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex. %% \catcode`\@=11 % \def\RestoreCatcodes{} diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test2.tex b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test2.tex new file mode 100644 index 00000000000..739944bab57 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test2.tex @@ -0,0 +1,264 @@ +%% +%% This is file `kvsetkeys-test2.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% kvsetkeys.dtx (with options: `test2') +%% +%% This is a generated file. +%% +%% Copyright (C) 2006, 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file kvsetkeys.dtx +%% and the derived files +%% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\makeatletter +\chardef\KVS@TestMode=1 % +\makeatother +\usepackage{kvsetkeys}[2007/09/29] +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +\makeatletter +\def\@makeactive#1{% + \catcode`#1=13\relax +} +\@makeactive\, +\def,{\errmessage{COMMA}} +\@makeother\, +\@makeactive\= +\def={\errmessage{EQUALS}} +\@makeother\= + +\begin{qstest}{normalize}{normalize,active-chars,space-removal}% + \def\Test#1#2{% + \@makeother\,% + \@makeother\=% + \scantokens{\toks@={#2}}% + \edef\Result{\the\toks@}% + \@makeother\,% + \@makeother\=% + \@Test{#1}% + \@makeactive\,% + \@Test{#1}% + \@makeactive\=% + \@Test{#1}% + \@makeother\,% + \@Test{#1}% + \@makeother\=% + }% + \def\@Test#1{% + \scantokens{\kv@normalize{#1}}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\expandafter\kv@list\expandafter}\expandafter{\Result}% + \Expect*{\ifx\kv@list\Result true\else false\fi}{true}% + }% + \Test{}{,}% + \Test{,}{,}% + \Test{,,}{,}% + \Test{,,,}{,}% + \Test{ , }{,}% + \Test{{a}}{,{a},}% + \Test{,{a}}{,{a},}% + \Test{{a},}{,{a},}% + \Test{{a},{b}}{,{a},{b},}% + \Test{{b}={c},{}=,{}={},{d}=}{,{b}={c},{}=,{}={},{d}=,}% + \Test{{}}{,{},}% + \Test{{},{},{}}{,{},{},{},}% + \Test{=}{,=,}% + \Test{=,=,=}{,=,=,=,}% + \def\TestSet#1{% + \Test{#1#1}{,}% + \Test{#1#1,#1#1}{,}% + \Test{#1#1,#1#1,#1#1}{,}% + \Test{#1#1#1#1#1}{,}% + \Test{{a}#1#1=#1#1{b}}{,{a}={b},}% + }% + \TestSet{ }% + \begingroup + \let\saved@normalize\kv@normalize + \def\kv@normalize#1{% + \saved@normalize{#1}% + \@onelevel@sanitize\kv@list + \@onelevel@sanitize\Result + }% + \Test{#,#=#,{#}={#},{#}=,{#}}{,#,#=#,{#}={#},{#}=,{#},}% + \endgroup + \begingroup + \def\Test#1#2{% + \edef\Result{#2}% + \@Test{#1}% + }% + \Test{{ a = b }}{,{ a = b },}% + \@makeactive\,% + \Test{{,}}{\string,{\noexpand,}\string,}% + \@makeother\,% + \@makeactive\=% + \Test{a={=}}{,a\string={\noexpand=},}% + \endgroup + \Test{a=b}{,a=b,}% + \Test{a={b}}{,a={b},}% + \Test{a ={b}}{,a={b},}% + \Test{a= {b}}{,a={b},}% + \Test{a = {b}}{,a={b},}% + \Test{a = {b} ,}{,a={b},}% + \Test{a}{,a,}% + \Test{ a}{,a,}% + \Test{a }{,a,}% + \Test{ a }{,a,}% + \Test{, a ,}{,a,}% + \Test{, a b ,}{,a b,}% + \Test{,a ,}{,a,}% + \Test{ a =}{,a=,}% + \Test{ a = }{,a=,}% + \Test{a =}{,a=,}% + \Test{{a} =}{,{a}=,}% + \Test{{a}= {}}{,{a}={},}% + \Test{, a = {}}{,a={},}% + \Test{a,,b}{,a,b,}% + \Test{a=\fi}{,a=\fi,}% + \Test{a=\iffalse}{,a=\iffalse,}% + \Test{a=\iffalse,b=\fi}{,a=\iffalse,b=\fi,}% +\end{qstest} + +\begin{qstest}{parse}{parse,brace-removal} + \def\Processor#1#2{% + \expandafter\Expect\expandafter{\kv@key}{#1}% + \toks@{#2}% + \edef\x{\the\toks@}% + \ifx\kv@value\relax + \Expect*{\the\toks@}{}% + \def\Value{<>}% + \else + \edef\Value{[\the\toks@]}% + \@onelevel@sanitize\Value + \fi + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]=\Value}% + \else + \edef\Result{\Result,[\the\toks@]=\Value}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \kv@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[]=<>}% + \Test{{{{}}}}{[{}]=<>}% + \Test{a}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{{a}}}{[a]=<>}% + \Test{{{{a}}}}{[{a}]=<>}% + \Test{a=}{[a]=[]}% + \Test{{a}=}{[a]=[]}% + \Test{{{a}}=}{[{a}]=[]}% + \Test{a={}}{[a]=[]}% + \Test{{a}={{}}}{[a]=[{}]}% + \Test{a=b}{[a]=[b]}% + \Test{a=\fi}{[a]=[\fi]}% + \Test{a=\iffalse}{[a]=[\iffalse]}% + \Test{a=\iffalse,b=\fi}{[a]=[\iffalse],[b]=[\fi]}% + \Test{{ a = b }}{[ a ]=[ b ]}% + \Test{{{ a = b }}}{[ a = b ]=<>}% +\end{qstest} + +\begin{qstest}{comma}{comma,parse} + \def\Processor#1{% + \expandafter\Expect\expandafter{\comma@entry}{#1}% + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]}% + \else + \edef\Result{\Result,[\the\toks@]}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \comma@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% +\tracingmacros=1 + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[{}]}% + \Test{a}{[a]}% + \Test{{a}}{[a]}% + \Test{{{a}}}{[{a}]}% + \Test{a=}{[a=]}% + \Test{a\fi}{[a\fi]}% + \Test{a\iffalse}{[a\iffalse]}% + \Test{\iffalse,\fi}{[\iffalse],[\fi]}% + \Test{ a , b , c }{[a],[b],[c]}% + \Test{ { } ,{ }, { }, { } , { } }{[ ],[ ],[ ],[ ],[ ]}% + \Test{ {{}} ,{{}}, {{}}, {{}} , {{}} }{[{}],[{}],[{}],[{}],[{}]}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `kvsetkeys-test2.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test3.tex b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test3.tex new file mode 100644 index 00000000000..fcf53c96479 --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys-test3.tex @@ -0,0 +1,267 @@ +%% +%% This is file `kvsetkeys-test3.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% kvsetkeys.dtx (with options: `test2,noetex') +%% +%% This is a generated file. +%% +%% Copyright (C) 2006, 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file kvsetkeys.dtx +%% and the derived files +%% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex. +%% +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\let\SavedUnexpanded\unexpanded +\let\unexpanded\UNDEFINED +\makeatletter +\chardef\KVS@TestMode=1 % +\makeatother +\usepackage{kvsetkeys}[2007/09/29] +\let\unexpanded\SavedUnexpanded +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +\makeatletter +\def\@makeactive#1{% + \catcode`#1=13\relax +} +\@makeactive\, +\def,{\errmessage{COMMA}} +\@makeother\, +\@makeactive\= +\def={\errmessage{EQUALS}} +\@makeother\= + +\begin{qstest}{normalize}{normalize,active-chars,space-removal}% + \def\Test#1#2{% + \@makeother\,% + \@makeother\=% + \scantokens{\toks@={#2}}% + \edef\Result{\the\toks@}% + \@makeother\,% + \@makeother\=% + \@Test{#1}% + \@makeactive\,% + \@Test{#1}% + \@makeactive\=% + \@Test{#1}% + \@makeother\,% + \@Test{#1}% + \@makeother\=% + }% + \def\@Test#1{% + \scantokens{\kv@normalize{#1}}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\expandafter\kv@list\expandafter}\expandafter{\Result}% + \Expect*{\ifx\kv@list\Result true\else false\fi}{true}% + }% + \Test{}{,}% + \Test{,}{,}% + \Test{,,}{,}% + \Test{,,,}{,}% + \Test{ , }{,}% + \Test{{a}}{,{a},}% + \Test{,{a}}{,{a},}% + \Test{{a},}{,{a},}% + \Test{{a},{b}}{,{a},{b},}% + \Test{{b}={c},{}=,{}={},{d}=}{,{b}={c},{}=,{}={},{d}=,}% + \Test{{}}{,{},}% + \Test{{},{},{}}{,{},{},{},}% + \Test{=}{,=,}% + \Test{=,=,=}{,=,=,=,}% + \def\TestSet#1{% + \Test{#1#1}{,}% + \Test{#1#1,#1#1}{,}% + \Test{#1#1,#1#1,#1#1}{,}% + \Test{#1#1#1#1#1}{,}% + \Test{{a}#1#1=#1#1{b}}{,{a}={b},}% + }% + \TestSet{ }% + \begingroup + \let\saved@normalize\kv@normalize + \def\kv@normalize#1{% + \saved@normalize{#1}% + \@onelevel@sanitize\kv@list + \@onelevel@sanitize\Result + }% + \Test{#,#=#,{#}={#},{#}=,{#}}{,#,#=#,{#}={#},{#}=,{#},}% + \endgroup + \begingroup + \def\Test#1#2{% + \edef\Result{#2}% + \@Test{#1}% + }% + \Test{{ a = b }}{,{ a = b },}% + \@makeactive\,% + \Test{{,}}{\string,{\noexpand,}\string,}% + \@makeother\,% + \@makeactive\=% + \Test{a={=}}{,a\string={\noexpand=},}% + \endgroup + \Test{a=b}{,a=b,}% + \Test{a={b}}{,a={b},}% + \Test{a ={b}}{,a={b},}% + \Test{a= {b}}{,a={b},}% + \Test{a = {b}}{,a={b},}% + \Test{a = {b} ,}{,a={b},}% + \Test{a}{,a,}% + \Test{ a}{,a,}% + \Test{a }{,a,}% + \Test{ a }{,a,}% + \Test{, a ,}{,a,}% + \Test{, a b ,}{,a b,}% + \Test{,a ,}{,a,}% + \Test{ a =}{,a=,}% + \Test{ a = }{,a=,}% + \Test{a =}{,a=,}% + \Test{{a} =}{,{a}=,}% + \Test{{a}= {}}{,{a}={},}% + \Test{, a = {}}{,a={},}% + \Test{a,,b}{,a,b,}% + \Test{a=\fi}{,a=\fi,}% + \Test{a=\iffalse}{,a=\iffalse,}% + \Test{a=\iffalse,b=\fi}{,a=\iffalse,b=\fi,}% +\end{qstest} + +\begin{qstest}{parse}{parse,brace-removal} + \def\Processor#1#2{% + \expandafter\Expect\expandafter{\kv@key}{#1}% + \toks@{#2}% + \edef\x{\the\toks@}% + \ifx\kv@value\relax + \Expect*{\the\toks@}{}% + \def\Value{<>}% + \else + \edef\Value{[\the\toks@]}% + \@onelevel@sanitize\Value + \fi + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]=\Value}% + \else + \edef\Result{\Result,[\the\toks@]=\Value}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \kv@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[]=<>}% + \Test{{{{}}}}{[{}]=<>}% + \Test{a}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{{a}}}{[a]=<>}% + \Test{{{{a}}}}{[{a}]=<>}% + \Test{a=}{[a]=[]}% + \Test{{a}=}{[a]=[]}% + \Test{{{a}}=}{[{a}]=[]}% + \Test{a={}}{[a]=[]}% + \Test{{a}={{}}}{[a]=[{}]}% + \Test{a=b}{[a]=[b]}% + \Test{a=\fi}{[a]=[\fi]}% + \Test{a=\iffalse}{[a]=[\iffalse]}% + \Test{a=\iffalse,b=\fi}{[a]=[\iffalse],[b]=[\fi]}% + \Test{{ a = b }}{[ a ]=[ b ]}% + \Test{{{ a = b }}}{[ a = b ]=<>}% +\end{qstest} + +\begin{qstest}{comma}{comma,parse} + \def\Processor#1{% + \expandafter\Expect\expandafter{\comma@entry}{#1}% + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]}% + \else + \edef\Result{\Result,[\the\toks@]}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \comma@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% +\tracingmacros=1 + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[{}]}% + \Test{a}{[a]}% + \Test{{a}}{[a]}% + \Test{{{a}}}{[{a}]}% + \Test{a=}{[a=]}% + \Test{a\fi}{[a\fi]}% + \Test{a\iffalse}{[a\iffalse]}% + \Test{\iffalse,\fi}{[\iffalse],[\fi]}% + \Test{ a , b , c }{[a],[b],[c]}% + \Test{ { } ,{ }, { }, { } , { } }{[ ],[ ],[ ],[ ],[ ]}% + \Test{ {{}} ,{{}}, {{}}, {{}} , {{}} }{[{}],[{}],[{}],[{}],[{}]}% +\end{qstest} + +\begin{document} +\end{document} +\endinput +%% +%% End of file `kvsetkeys-test3.tex'. diff --git a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys.pdf b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys.pdf Binary files differindex eb2c8c0652b..f4110fab0cf 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/kvsetkeys.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/makerobust.pdf b/Master/texmf-dist/doc/latex/oberdiek/makerobust.pdf Binary files differindex 77dfad4fa94..413c98d4b42 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/makerobust.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/makerobust.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/oberdiek.pdf b/Master/texmf-dist/doc/latex/oberdiek/oberdiek.pdf Binary files differindex 621d9703be5..c4df5f6495a 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/oberdiek.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/oberdiek.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pagesel.pdf b/Master/texmf-dist/doc/latex/oberdiek/pagesel.pdf Binary files differindex 0be191a8819..806c3dda08b 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pagesel.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pagesel.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcol.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcol.pdf Binary files differindex be5d4d31346..f3d4f4c5628 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcol.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcol.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcolfoot.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcolfoot.pdf Binary files differindex 48ae28c940f..77fc0928449 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcolfoot.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcolfoot.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcolmk.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcolmk.pdf Binary files differindex 7e34d34f014..b16a1b630ba 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcolmk.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcolmk.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcolparallel.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcolparallel.pdf Binary files differindex ab399713002..a1334f403a8 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcolparallel.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcolparallel.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcolparcolumns.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcolparcolumns.pdf Binary files differindex 4e252de7e10..a3d9de705ec 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcolparcolumns.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcolparcolumns.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfcrypt.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfcrypt.pdf Binary files differindex 52eda074d29..8a2084591b2 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfcrypt.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfcrypt.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdfescape.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdfescape.pdf Binary files differindex 107c2f93d17..d2b50f80033 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdfescape.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdfescape.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pdflscape.pdf b/Master/texmf-dist/doc/latex/oberdiek/pdflscape.pdf Binary files differindex d9d0beb4611..1dd1bf2072a 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pdflscape.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pdflscape.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/picture.pdf b/Master/texmf-dist/doc/latex/oberdiek/picture.pdf Binary files differindex caeacfcc186..10c07b6e977 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/picture.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/picture.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/pmboxdraw.pdf b/Master/texmf-dist/doc/latex/oberdiek/pmboxdraw.pdf Binary files differindex de133485a5b..6444b6f8ea0 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/pmboxdraw.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/pmboxdraw.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/refcount.pdf b/Master/texmf-dist/doc/latex/oberdiek/refcount.pdf Binary files differindex 135dc0c67af..8e0f11e5705 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/refcount.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/refcount.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/selinput.pdf b/Master/texmf-dist/doc/latex/oberdiek/selinput.pdf Binary files differindex e14700e609b..aa83acad4ca 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/selinput.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/selinput.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/setouterhbox.pdf b/Master/texmf-dist/doc/latex/oberdiek/setouterhbox.pdf Binary files differindex 69044ed98d9..37dbbe7249c 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/setouterhbox.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/setouterhbox.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/settobox.pdf b/Master/texmf-dist/doc/latex/oberdiek/settobox.pdf Binary files differindex 4bde244f1ea..cc2a25a8a01 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/settobox.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/settobox.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/soulutf8.pdf b/Master/texmf-dist/doc/latex/oberdiek/soulutf8.pdf Binary files differindex e8604c214a7..43de362e3c2 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/soulutf8.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/soulutf8.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/stackrel.pdf b/Master/texmf-dist/doc/latex/oberdiek/stackrel.pdf Binary files differindex d2eccc9186c..f8fffdf3a11 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/stackrel.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/stackrel.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/stringenc.pdf b/Master/texmf-dist/doc/latex/oberdiek/stringenc.pdf Binary files differindex 754122c52fc..b07bf55f954 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/stringenc.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/stringenc.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/tabularht.pdf b/Master/texmf-dist/doc/latex/oberdiek/tabularht.pdf Binary files differindex 964eb41f869..4d27a653e9a 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/tabularht.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/tabularht.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/tabularkv.pdf b/Master/texmf-dist/doc/latex/oberdiek/tabularkv.pdf Binary files differindex 11132898a58..1f490de7b75 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/tabularkv.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/tabularkv.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/telprint.pdf b/Master/texmf-dist/doc/latex/oberdiek/telprint.pdf Binary files differindex 226f45a0f38..b36039cf50c 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/telprint.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/telprint.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/transparent.pdf b/Master/texmf-dist/doc/latex/oberdiek/transparent.pdf Binary files differindex 7d5ea1e9227..230735afb84 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/transparent.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/transparent.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/twoopt.pdf b/Master/texmf-dist/doc/latex/oberdiek/twoopt.pdf Binary files differindex cdd894dd434..27d558ccf4e 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/twoopt.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/twoopt.pdf diff --git a/Master/texmf-dist/doc/latex/oberdiek/zref.pdf b/Master/texmf-dist/doc/latex/oberdiek/zref.pdf Binary files differindex 30fd5d536f9..655eb8704a0 100644 --- a/Master/texmf-dist/doc/latex/oberdiek/zref.pdf +++ b/Master/texmf-dist/doc/latex/oberdiek/zref.pdf diff --git a/Master/texmf-dist/source/latex/oberdiek/bigintcalc.dtx b/Master/texmf-dist/source/latex/oberdiek/bigintcalc.dtx new file mode 100644 index 00000000000..28432ecc585 --- /dev/null +++ b/Master/texmf-dist/source/latex/oberdiek/bigintcalc.dtx @@ -0,0 +1,4371 @@ +% \iffalse meta-comment +% +% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 of this license or (at your option) any later +% version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status "maintained". +% +% This Current Maintainer of this work is Heiko Oberdiek. +% +% This work consists of the main source file bigintcalc.dtx +% and the derived files +% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, +% bigintcalc-test1.tex, bigintcalc-test2.tex, +% bigintcalc-test3.tex. +% +% Distribution: +% CTAN:macros/latex/contrib/oberdiek/bigintcalc.dtx +% CTAN:macros/latex/contrib/oberdiek/bigintcalc.pdf +% +% Unpacking: +% (a) If bigintcalc.ins is present: +% tex bigintcalc.ins +% (b) Without bigintcalc.ins: +% tex bigintcalc.dtx +% (c) If you insist on using LaTeX +% latex \let\install=y\input{bigintcalc.dtx} +% (quote the arguments according to the demands of your shell) +% +% Documentation: +% (a) If bigintcalc.drv is present: +% latex bigintcalc.drv +% (b) Without bigintcalc.drv: +% latex bigintcalc.dtx; ... +% The class ltxdoc loads the configuration file ltxdoc.cfg +% if available. Here you can specify further options, e.g. +% use A4 as paper format: +% \PassOptionsToClass{a4paper}{article} +% +% Programm calls to get the documentation (example): +% pdflatex bigintcalc.dtx +% makeindex -s gind.ist bigintcalc.idx +% pdflatex bigintcalc.dtx +% makeindex -s gind.ist bigintcalc.idx +% pdflatex bigintcalc.dtx +% +% Installation: +% TDS:tex/generic/oberdiek/bigintcalc.sty +% TDS:doc/latex/oberdiek/bigintcalc.pdf +% TDS:doc/latex/oberdiek/bigintcalc-test1.tex +% TDS:doc/latex/oberdiek/bigintcalc-test2.tex +% TDS:doc/latex/oberdiek/bigintcalc-test3.tex +% TDS:source/latex/oberdiek/bigintcalc.dtx +% +%<*ignore> +\begingroup + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase 0\ifx\install y1\fi\expandafter + \ifx\csname processbatchFile\endcsname\relax\else1\fi + \ifx\fmtname\x\else 1\fi\relax +\else\csname fi\endcsname +%</ignore> +%<*install> +\input docstrip.tex +\Msg{************************************************************************} +\Msg{* Installation} +\Msg{* Package: bigintcalc 2007/09/27 v1.0 Expandable big integer calculations (HO)} +\Msg{************************************************************************} + +\keepsilent +\askforoverwritefalse + +\preamble + +This is a generated file. + +Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in + http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. + +This work has the LPPL maintenance status "maintained". + +This Current Maintainer of this work is Heiko Oberdiek. + +This work consists of the main source file bigintcalc.dtx +and the derived files + bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, + bigintcalc-test1.tex, bigintcalc-test2.tex, + bigintcalc-test3.tex. + +\endpreamble + +\generate{% + \file{bigintcalc.ins}{\from{bigintcalc.dtx}{install}}% + \file{bigintcalc.drv}{\from{bigintcalc.dtx}{driver}}% + \usedir{tex/generic/oberdiek}% + \file{bigintcalc.sty}{\from{bigintcalc.dtx}{package}}% + \usedir{doc/latex/oberdiek}% + \file{bigintcalc-test1.tex}{\from{bigintcalc.dtx}{test1}}% + \file{bigintcalc-test2.tex}{\from{bigintcalc.dtx}{test2,etex}}% + \file{bigintcalc-test3.tex}{\from{bigintcalc.dtx}{test2,noetex}}% +} + +\obeyspaces +\Msg{************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file into a directory searched by TeX:} +\Msg{*} +\Msg{* bigintcalc.sty} +\Msg{*} +\Msg{* To produce the documentation run the file `bigintcalc.drv'} +\Msg{* through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{************************************************************************} + +\endbatchfile +%</install> +%<*ignore> +\fi +%</ignore> +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{bigintcalc.drv}% + [2007/09/27 v1.0 Expandable big integer calculations (HO)]% +\documentclass{ltxdoc} +\usepackage{holtxdoc} +\usepackage{wasysym} +\let\iint\relax +\let\iiint\relax +\usepackage[fleqn]{amsmath} + +\DeclareMathOperator{\opInv}{Inv} +\DeclareMathOperator{\opAbs}{Abs} +\DeclareMathOperator{\opSgn}{Sgn} +\DeclareMathOperator{\opMin}{Min} +\DeclareMathOperator{\opMax}{Max} +\DeclareMathOperator{\opCmp}{Cmp} +\DeclareMathOperator{\opOdd}{Odd} +\DeclareMathOperator{\opInc}{Inc} +\DeclareMathOperator{\opDec}{Dec} +\DeclareMathOperator{\opAdd}{Add} +\DeclareMathOperator{\opSub}{Sub} +\DeclareMathOperator{\opShl}{Shl} +\DeclareMathOperator{\opShr}{Shr} +\DeclareMathOperator{\opMul}{Mul} +\DeclareMathOperator{\opSqr}{Sqr} +\DeclareMathOperator{\opFac}{Fac} +\DeclareMathOperator{\opPow}{Pow} +\DeclareMathOperator{\opDiv}{Div} +\DeclareMathOperator{\opMod}{Mod} +\DeclareMathOperator{\opInt}{Int} +\DeclareMathOperator{\opODD}{ifodd} + +\newcommand*{\Def}{% + \ensuremath{% + \mathrel{\mathop{:}}=% + }% +} +\newcommand*{\op}[1]{% + \textsf{#1}% +} +\begin{document} + \DocInput{bigintcalc.dtx}% +\end{document} +%</driver> +% \fi +% +% \CheckSum{3507} +% +% \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 +% Lower-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 +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \GetFileInfo{bigintcalc.drv} +% +% \title{The \xpackage{bigintcalc} package} +% \date{2007/09/27 v1.0} +% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} +% +% \maketitle +% +% \begin{abstract} +% This package provides expandable arithmetic operations +% with big integers that can exceed \TeX's number limits. +% \end{abstract} +% +% \tableofcontents +% +% \section{Documentation} +% +% \subsection{Introduction} +% +% Package \xpackage{bigintcalc} defines arithmetic operations +% that deal with big integers. Big integers can be given +% either as explicit integer number or as macro code +% that expands to an explicit number. \emph{Big} means that +% there is no limit on the size of the number. Big integers +% may exceed \TeX's range limitation of -2147483647 and 2147483647. +% Only memory issues will limit the usable range. +% +% In opposite to package \xpackage{intcalc} +% unexpandable command tokens are not supported, even if +% they are valid \TeX\ numbers like count registers or +% commands created by \cs{chardef}. Nevertheless they may +% be used, if they are prefixed by \cs{number}. +% +% Also \eTeX's \cs{numexpr} expressions are not supported +% directly in the manner of package \xpackage{intcalc}. +% However they can be given if \cs{the}\cs{numexpr} +% or \cs{number}\cs{numexpr} are used. +% +% The operations have the form of macros that take one or +% two integers as parameter and return the integer result. +% The macro name is a three letter operation name prefixed +% by the package name, e.g. \cs{bigintcalcAdd}|{10}{43}| returns +% |53|. +% +% The macros are fully expandable, exactly two expansion +% steps generate the result. Therefore the operations +% may be used nearly everywhere in \TeX, even inside +% \cs{csname}, file names, or other +% expandable contexts. +% +% \subsection{Conditions} +% +% \subsubsection{Preconditions} +% +% \begin{itemize} +% \item +% Arguments can be anything that expands to a number that consists +% of optional signs and digits. +% \item +% The arguments and return values must be sound. +% Zero as divisor or factorials of negative numbers will cause errors. +% \end{itemize} +% +% \subsubsection{Postconditions} +% +% Additional properties of the macros apart from calculating +% a correct result (of course \smiley): +% \begin{itemize} +% \item +% The macros are fully expandable. Thus they can +% be used inside \cs{edef}, \cs{csname}, +% for example. +% \item +% Furthermore exactly two expansion steps calculate the result. +% \item +% The number consists of one optional minus sign and one or more +% digits. The first digit is larger than zero for +% numbers that consists of more than one digit. +% +% In short, the number format is exactly the same as +% \cs{number} generates, but without its range limitation. +% And the tokens (minus sign, digits) +% have catcode 12 (other). +% \item +% Call by value is simulated. First the arguments are +% converted to numbers. Then these numbers are used +% in the calculations. +% +% Remember that arguments +% may contain expensive macros or \eTeX\ expressions. +% This strategy avoids multiple evaluations of such +% arguments. +% \end{itemize} +% +% \subsection{Error handling} +% +% Some errors are detected by the macros, example: division by zero. +% In this cases an undefined control sequence is called and causes +% a TeX error message, example: \cs{BigIntCalcError:DivisionByZero}. +% The name of the control sequence contains +% the reason for the error. The \TeX\ error may be ignored. +% Then the operation returns zero as result. +% Because the macros are supposed to work in expandible contexts. +% An traditional error message, however, is not expandable and +% would break these contexts. +% +% \subsection{Operations} +% +% Some definition equations below use the function $\opInt$ +% that converts a real number to an integer. The number +% is truncated that means rounding to zero: +% \begin{gather*} +% \opInt(x) \Def +% \begin{cases} +% \lfloor x\rfloor & \text{if $x\geq0$}\\ +% \lceil x\rceil & \text{otherwise} +% \end{cases} +% \end{gather*} +% +% \subsubsection{\op{Num}} +% +% \begin{declcs}{bigintcalcNum} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcNum} converts its argument to a normalized integer +% number without unnecessary leading zeros or signs. +% The result matches the regular expression: +%\begin{quote} +%\begin{verbatim} +%0|-?[1-9][0-9]* +%\end{verbatim} +%\end{quote} +% +% \subsubsection{\op{Inv}, \op{Abs}, \op{Sgn}} +% +% \begin{declcs}{bigintcalcInv} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcInv} switches the sign. +% \begin{gather*} +% \opInv(x) \Def -x +% \end{gather*} +% +% \begin{declcs}{bigintcalcAbs} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcAbs} returns the absolute value +% of integer \meta{x}. +% \begin{gather*} +% \opAbs(x) \Def \vert x\vert +% \end{gather*} +% +% \begin{declcs}{bigintcalcSgn} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcSgn} encodes the sign of \meta{x} as number. +% \begin{gather*} +% \opSgn(x) \Def +% \begin{cases} +% -1& \text{if $x<0$}\\ +% 0& \text{if $x=0$}\\ +% 1& \text{if $x>0$} +% \end{cases} +% \end{gather*} +% These return values can easily be distinguished by \cs{ifcase}: +%\begin{quote} +%\begin{verbatim} +%\ifcase\bigintcalcSgn{<x>} +% $x=0$ +%\or +% $x>0$ +%\else +% $x<0$ +%\fi +%\end{verbatim} +%\end{quote} +% +% \subsubsection{\op{Min}, \op{Max}, \op{Cmp}} +% +% \begin{declcs}{bigintcalcMin} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcMin} returns the smaller of the two integers. +% \begin{gather*} +% \opMin(x,y) \Def +% \begin{cases} +% x & \text{if $x<y$}\\ +% y & \text{otherwise} +% \end{cases} +% \end{gather*} +% +% \begin{declcs}{bigintcalcMax} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcMax} returns the larger of the two integers. +% \begin{gather*} +% \opMax(x,y) \Def +% \begin{cases} +% x & \text{if $x>y$}\\ +% y & \text{otherwise} +% \end{cases} +% \end{gather*} +% +% \begin{declcs}{bigintcalcCmp} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcCmp} encodes the comparison result as number: +% \begin{gather*} +% \opCmp(x,y) \Def +% \begin{cases} +% -1 & \text{if $x<y$}\\ +% 0 & \text{if $x=y$}\\ +% 1 & \text{if $x>y$} +% \end{cases} +% \end{gather*} +% These values can be distinguished by \cs{ifcase}: +%\begin{quote} +%\begin{verbatim} +%\ifcase\bigintcalcCmp{<x>}{<y>} +% $x=y$ +%\or +% $x>y$ +%\else +% $x<y$ +%\fi +%\end{verbatim} +%\end{quote} +% +% \subsubsection{\op{Odd}} +% +% \begin{declcs}{bigintcalcOdd} \M{x} +% \end{declcs} +% \begin{gather*} +% \opOdd(x) \Def +% \begin{cases} +% 1 & \text{if $x$ is odd}\\ +% 0 & \text{if $x$ is even} +% \end{cases} +% \end{gather*} +% +% \subsubsection{\op{Inc}, \op{Dec}, \op{Add}, \op{Sub}} +% +% \begin{declcs}{bigintcalcInc} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcInc} increments \meta{x} by one. +% \begin{gather*} +% \opInc(x) \Def x + 1 +% \end{gather*} +% +% \begin{declcs}{bigintcalcDec} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcDec} decrements \meta{x} by one. +% \begin{gather*} +% \opDec(x) \Def x - 1 +% \end{gather*} +% +% \begin{declcs}{bigintcalcAdd} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcAdd} adds the two numbers. +% \begin{gather*} +% \opAdd(x, y) \Def x + y +% \end{gather*} +% +% \begin{declcs}{bigintcalcSub} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcSub} calculates the difference. +% \begin{gather*} +% \opSub(x, y) \Def x - y +% \end{gather*} +% +% \subsubsection{\op{Shl}, \op{Shr}} +% +% \begin{declcs}{bigintcalcShl} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcShl} implements shifting to the left that +% means the number is multiplied by two. +% The sign is preserved. +% \begin{gather*} +% \opShl(x) \Def x*2 +% \end{gather*} +% +% \begin{declcs}{bigintcalcShr} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcShr} implements shifting to the right. +% That is equivalent to an integer division by two. +% The sign is preserved. +% \begin{gather*} +% \opShr(x) \Def \opInt(x/2) +% \end{gather*} +% +% \subsubsection{\op{Mul}, \op{Sqr}, \op{Fac}, \op{Pow}} +% +% \begin{declcs}{bigintcalcMul} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcMul} calculates the product of +% \meta{x} and \meta{y}. +% \begin{gather*} +% \opMul(x,y) \Def x*y +% \end{gather*} +% +% \begin{declcs}{bigintcalcSqr} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcSqr} returns the square product. +% \begin{gather*} +% \opSqr(x) \Def x^2 +% \end{gather*} +% +% \begin{declcs}{bigintcalcFac} \M{x} +% \end{declcs} +% Macro \cs{bigintcalcFac} returns the factorial of \meta{x}. +% Negative numbers are not permitted. +% \begin{gather*} +% \opFac(x) \Def x!\qquad\text{for $x\geq0$} +% \end{gather*} +% ($0! = 1$) +% +% \begin{declcs}{bigintcalcPow} M{x} M{y} +% \end{declcs} +% Macro \cs{bigintcalcPow} calculates the value of \meta{x} to the +% power of \meta{y}. The error ``division by zero'' is thrown +% if \meta{x} is zero and \meta{y} is negative. +% permitted: +% \begin{gather*} +% \opPow(x,y) \Def +% \opInt(x^y)\qquad\text{for $x\neq0$ or $y\geq0$} +% \end{gather*} +% ($0^0 = 1$) +% +% \subsubsection{\op{Div}, \op{Mul}} +% +% \begin{declcs}{bigintcalcDiv} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcDiv} performs an integer division. +% Argument \meta{y} must not be zero. +% \begin{gather*} +% \opDiv(x,y) \Def \opInt(x/y)\qquad\text{for $y\neq0$} +% \end{gather*} +% +% \begin{declcs}{bigintcalcMod} \M{x} \M{y} +% \end{declcs} +% Macro \cs{bigintcalcMod} gets the remainder of the integer +% division. The sign follows the divisor \meta{y}. +% Argument \meta{y} must not be zero. +% \begin{gather*} +% \opMod(x,y) \Def x\mathrel{\%}y\qquad\text{for $y\neq0$} +% \end{gather*} +% The result ranges: +% \begin{gather*} +% -\vert y\vert < \opMod(x,y) \leq 0\qquad\text{for $y<0$}\\ +% 0 \leq \opMod(x,y) < y\qquad\text{for $y\geq0$} +% \end{gather*} +% +% \subsection{Interface for programmers} +% +% If the programmer can ensure some more properties about +% the arguments of the operations, then the following +% macros are a little more efficient. +% +% In general numbers must obey the following constraints: +% \begin{itemize} +% \item Plain number: digit tokens only, no command tokens. +% \item Non-negative. Signs are forbidden. +% \item Delimited by exclamation mark. Curly braces +% around the number are not allowed and will +% break the code. +% \end{itemize} +% +% \begin{declcs}{BigIntCalcOdd} \meta{number} |!| +% \end{declcs} +% |1|/|0| is returned if \meta{number} is odd/even. +% +% \begin{declcs}{BigIntCalcInc} \meta{number} |!| +% \end{declcs} +% Incrementation. +% +% \begin{declcs}{BigIntCalcDec} \meta{number} |!| +% \end{declcs} +% Decrementation, positive number without zero. +% +% \begin{declcs}{BigIntCalcAdd} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Addition, $A\geq B$. +% +% \begin{declcs}{BigIntCalcSub} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Subtraction, $A\geq B$. +% +% \begin{declcs}{BigIntCalcShl} \meta{number} |!| +% \end{declcs} +% Left shift (multiplication with two). +% +% \begin{declcs}{BigIntCalcShr} \meta{number} |!| +% \end{declcs} +% Right shift (integer division by two). +% +% \begin{declcs}{BigIntCalcMul} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Multiplication, $A\geq B$. +% +% \begin{declcs}{BigIntCalcDiv} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Division operation. +% +% \begin{declcs}{BigIntCalcMod} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Modulo operation. +% +% +% \StopEventually{ +% } +% +% \section{Implementation} +% +% \begin{macrocode} +%<*package> +% \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@bigintcalc.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{bigintcalc}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +% \end{macrocode} +% Package identification: +% \begin{macrocode} +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@bigintcalc.sty\endcsname +\ProvidesPackage{bigintcalc}% + [2007/09/27 v1.0 Expandable big integer calculations (HO)] +% \end{macrocode} +% +% \subsection{Catcodes} +% +% \begin{macrocode} +\expandafter\edef\csname BIC@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\BIC@AtEnd{% + \BIC@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{36}{14}% $ (comment!) +\TMP@EnsureCode{38}{14}% & (comment!) +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{11}% : (letter!) +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{63}{14}% ? (comment!) +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname BIC@TestMode\endcsname\relax +\else + \catcode63=9 % ? (ignore) +\fi +? \let\BIC@@TestMode\BIC@TestMode +% \end{macrocode} +% +% \subsection{\eTeX\ detection} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname numexpr\endcsname\relax + \catcode36=9 % $ (ignore) +\else + \catcode38=9 % & (ignore) +\fi +% \end{macrocode} +% +% \subsection{Help macros} +% +% \begin{macro}{\BIC@Fi} +% \begin{macrocode} +\let\BIC@Fi\fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AfterFi} +% \begin{macrocode} +\def\BIC@AfterFi#1#2\BIC@Fi{\fi#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AfterFiFi} +% \begin{macrocode} +\def\BIC@AfterFiFi#1#2\BIC@Fi{\fi\fi#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AfterFiFiFi} +% \begin{macrocode} +\def\BIC@AfterFiFiFi#1#2\BIC@Fi{\fi\fi\fi#1}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@Space} +% \begin{macrocode} +\begingroup + \def\x#1{\endgroup + \let\BIC@Space= #1% + }% +\x{ } +% \end{macrocode} +% \end{macro} +% +% \subsection{Expand number} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfescapehex\endcsname\relax +% \end{macrocode} +% +% \begin{macro}{\BIC@Expand} +% \begin{macrocode} + \def\BIC@Expand#1{% + \romannumeral0% + \BIC@@Expand#1!\@nil{}% + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Expand} +% \begin{macrocode} + \def\BIC@@Expand#1#2\@nil#3{% + \expandafter\ifcat\noexpand#1\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {% + \expandafter\BIC@@Expand#1#2\@nil{#3}% + }{% + \ifx#1!% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + { #3}{% + \BIC@@Expand#2\@nil{#3#1}% + }% + }% + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@firstoftwo} +% \begin{macrocode} + \expandafter\ifx\csname @firstoftwo\endcsname\relax + \long\def\@firstoftwo#1#2{#1}% + \fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@secondoftwo} +% \begin{macrocode} + \expandafter\ifx\csname @secondoftwo\endcsname\relax + \long\def\@secondoftwo#1#2{#2}% + \fi +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\else +% \end{macrocode} +% \begin{macro}{\BIC@Expand} +% \begin{macrocode} + \def\BIC@Expand#1{% + \pdfunescapehex{% + \expandafter\BIC@StripHexSpace\pdfescapehex{#1}20\@nil + }% + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@StripHexSpace} +% \begin{macrocode} + \def\BIC@StripHexSpace#120#2\@nil{% + #1% + \ifx\\#2\\% + \else + \BIC@AfterFi{% + \BIC@StripHexSpace#2\@nil + }% + \BIC@Fi + }% +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +\fi +% \end{macrocode} +% +% \subsection{Normalize expanded number} +% +% \begin{macro}{\BIC@Normalize} +% |#1|: result sign\\ +% |#2|: first token of number +% \begin{macrocode} +\def\BIC@Normalize#1#2{% + \ifx#2-% + \ifx\\#1\\% + \BIC@AfterFiFi{% + \BIC@Normalize-% + }% + \else + \BIC@AfterFiFi{% + \BIC@Normalize{}% + }% + \fi + \else + \ifx#2+% + \BIC@AfterFiFi{% + \BIC@Normalize{#1}% + }% + \else + \ifx#20% + \BIC@AfterFiFiFi{% + \BIC@NormalizeZero{#1}% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@NormalizeDigits#1#2% + }% + \fi + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@NormalizeZero} +% \begin{macrocode} +\def\BIC@NormalizeZero#1#2{% + \ifx#2!% + \BIC@AfterFi{ 0}% + \else + \ifx#20% + \BIC@AfterFiFi{% + \BIC@NormalizeZero{#1}% + }% + \else + \BIC@AfterFiFi{% + \BIC@NormalizeDigits#1#2% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@NormalizeDigits} +% \begin{macrocode} +\def\BIC@NormalizeDigits#1!{ #1} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Num}} +% +% \begin{macro}{\bigintcalcNum} +% \begin{macrocode} +\def\bigintcalcNum#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Normalize + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \BIC@Expand{#1}!% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Inv}, \op{Abs}, \op{Sgn}} +% +% +% \begin{macro}{\bigintcalcInv} +% \begin{macrocode} +\def\bigintcalcInv#1{% + \romannumeral0\expandafter\expandafter\expandafter\BIC@Space + \bigintcalcNum{-#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bigintcalcAbs} +% \begin{macrocode} +\def\bigintcalcAbs#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Abs + \bigintcalcNum{#1}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Abs} +% \begin{macrocode} +\def\BIC@Abs#1{% + \ifx#1-% + \expandafter\BIC@Space + \else + \expandafter\BIC@Space + \expandafter#1% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bigintcalcSgn} +% \begin{macrocode} +\def\bigintcalcSgn#1{% + \number + \expandafter\expandafter\expandafter\BIC@Sgn + \bigintcalcNum{#1}! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Sgn} +% \begin{macrocode} +\def\BIC@Sgn#1#2!{% + \ifx#1-% + -1% + \else + \ifx#10% + 0% + \else + 1% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Cmp}, \op{Min}, \op{Max}} +% +% \begin{macro}{\bigintcalcCmp} +% \begin{macrocode} +\def\bigintcalcCmp#1#2{% + \number + \expandafter\expandafter\expandafter\BIC@Cmp + \bigintcalcNum{#2}!{#1}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Cmp} +% \begin{macrocode} +\def\BIC@Cmp#1!#2{% + \expandafter\expandafter\expandafter\BIC@@Cmp + \bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Cmp} +% \begin{macrocode} +\def\BIC@@Cmp#1#2!#3#4!{% + \ifx#1-% + \ifx#3-% + \BIC@AfterFiFi{% + \BIC@@Cmp#4!#2!% + }% + \else + \BIC@AfterFiFi{% + -1 % + }% + \fi + \else + \ifx#3-% + \BIC@AfterFiFi{% + 1 % + }% + \else + \BIC@AfterFiFi{% + \BIC@CmpLength#1#2!#3#4!#1#2!#3#4!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@PosCmp} +% \begin{macrocode} +\def\BIC@PosCmp#1!#2!{% + \BIC@CmpLength#1!#2!#1!#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@CmpLength} +% \begin{macrocode} +\def\BIC@CmpLength#1#2!#3#4!{% + \ifx\\#2\\% + \ifx\\#4\\% + \BIC@AfterFiFi\BIC@CmpDiff + \else + \BIC@AfterFiFi{% + \BIC@CmpResult{-1}% + }% + \fi + \else + \ifx\\#4\\% + \BIC@AfterFiFi{% + \BIC@CmpResult1% + }% + \else + \BIC@AfterFiFi{% + \BIC@CmpLength#2!#4!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@CmpResult} +% \begin{macrocode} +\def\BIC@CmpResult#1#2!#3!{#1 } +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@CmpDiff} +% \begin{macrocode} +\def\BIC@CmpDiff#1#2!#3#4!{% + \ifnum#1<#3 % + \BIC@AfterFi{% + -1 % + }% + \else + \ifnum#1>#3 % + \BIC@AfterFiFi{% + 1 % + }% + \else + \ifx\\#2\\% + \BIC@AfterFiFiFi{% + 0 % + }% + \else + \BIC@AfterFiFiFi{% + \BIC@CmpDiff#2!#4!% + }% + \fi + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bigintcalcMin} +% \begin{macrocode} +\def\bigintcalcMin#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@MinMax + \bigintcalcNum{#1}!-!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bigintcalcMax} +% \begin{macrocode} +\def\bigintcalcMax#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@MinMax + \bigintcalcNum{#1}!!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@MinMax} +% |#1|: $x$\\ +% |#2|: sign for comparison\\ +% |#3|: $y$ +% \begin{macrocode} +\def\BIC@MinMax#1!#2!#3{% + \expandafter\expandafter\expandafter\BIC@@MinMax + \bigintcalcNum{#3}!#1!#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@MinMax} +% |#1|: $y$\\ +% |#2|: $x$\\ +% |#3|: sign for comparison +% \begin{macrocode} +\def\BIC@@MinMax#1!#2!#3!{% + \ifnum\BIC@@Cmp#1!#2!=#31 % + \BIC@AfterFi{ #1}% + \else + \BIC@AfterFi{ #2}% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Odd}} +% +% \begin{macro}{\bigintcalcOdd} +% \begin{macrocode} +\def\bigintcalcOdd#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Odd + \bigintcalcAbs{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcOdd} +% \begin{macrocode} +\def\BigIntCalcOdd#1!{% + \romannumeral0% + \BIC@Odd#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Odd} +% |#1|: $x$ +% \begin{macrocode} +\def\BIC@Odd#1#2{% + \ifx#2!% + \ifodd#1 % + \BIC@AfterFiFi{ 1}% + \else + \BIC@AfterFiFi{ 0}% + \fi + \else + \expandafter\BIC@Odd\expandafter#2% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Inc}, \op{Dec}} +% +% \begin{macro}{\bigintcalcInc} +% \begin{macrocode} +\def\bigintcalcInc#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@IncSwitch + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@IncSwitch} +% \begin{macrocode} +\def\BIC@IncSwitch#1#2!{% + \ifcase\BIC@@Cmp#1#2!-1!% + \BIC@AfterFi{ 0}% + \or + \BIC@AfterFi{% + \BIC@Inc#1#2!{}% + }% + \else + \BIC@AfterFi{% + \expandafter-\romannumeral0% + \BIC@Dec#2!{}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bigintcalcDec} +% \begin{macrocode} +\def\bigintcalcDec#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@DecSwitch + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DecSwitch} +% \begin{macrocode} +\def\BIC@DecSwitch#1#2!{% + \ifcase\BIC@Sgn#1#2! % + \BIC@AfterFi{ -1}% + \or + \BIC@AfterFi{% + \BIC@Dec#1#2!{}% + }% + \else + \BIC@AfterFi{% + \expandafter-\romannumeral0% + \BIC@Inc#2!{}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BigIntCalcInc} +% \begin{macrocode} +\def\BigIntCalcInc#1!{% + \romannumeral0\BIC@Inc#1!{}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcDec} +% \begin{macrocode} +\def\BigIntCalcDec#1!{% + \romannumeral0\BIC@Dec#1!{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@Inc} +% \begin{macrocode} +\def\BIC@Inc#1#2!#3{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@@Inc1#1#3!{}% + }% + \else + \BIC@AfterFi{% + \BIC@Inc#2!{#1#3}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Inc} +% \begin{macrocode} +\def\BIC@@Inc#1#2#3!#4{% + \ifcase#1 % + \ifx\\#3\\% + \BIC@AfterFiFi{ #2#4}% + \else + \BIC@AfterFiFi{% + \BIC@@Inc0#3!{#2#4}% + }% + \fi + \else + \ifnum#2<9 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@Inc\the\numexpr#2+1\relax +$ \expandafter\expandafter\expandafter\BIC@@@Inc +$ \ifcase#2 \expandafter1% +$ \or\expandafter2% +$ \or\expandafter3% +$ \or\expandafter4% +$ \or\expandafter5% +$ \or\expandafter6% +$ \or\expandafter7% +$ \or\expandafter8% +$ \or\expandafter9% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi + 0#3!{#4}% + }% + \else + \BIC@AfterFiFi{% + \BIC@@@Inc01#3!{#4}% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@Inc} +% \begin{macrocode} +\def\BIC@@@Inc#1#2#3!#4{% + \ifx\\#3\\% + \ifnum#2=1 % + \BIC@AfterFiFi{ 1#1#4}% + \else + \BIC@AfterFiFi{ #1#4}% + \fi + \else + \BIC@AfterFi{% + \BIC@@Inc#2#3!{#1#4}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@Dec} +% \begin{macrocode} +\def\BIC@Dec#1#2!#3{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@@Dec1#1#3!{}% + }% + \else + \BIC@AfterFi{% + \BIC@Dec#2!{#1#3}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Dec} +% \begin{macrocode} +\def\BIC@@Dec#1#2#3!#4{% + \ifcase#1 % + \ifx\\#3\\% + \BIC@AfterFiFi{ #2#4}% + \else + \BIC@AfterFiFi{% + \BIC@@Dec0#3!{#2#4}% + }% + \fi + \else + \ifnum#2>0 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@Dec\the\numexpr#2-1\relax +$ \expandafter\expandafter\expandafter\BIC@@@Dec +$ \ifcase#2 +$? \BigIntCalcError:ThisCannotHappen% +$ \or\expandafter0% +$ \or\expandafter1% +$ \or\expandafter2% +$ \or\expandafter3% +$ \or\expandafter4% +$ \or\expandafter5% +$ \or\expandafter6% +$ \or\expandafter7% +$ \or\expandafter8% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi + 0#3!{#4}% + }% + \else + \BIC@AfterFiFi{% + \BIC@@@Dec91#3!{#4}% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@Dec} +% \begin{macrocode} +\def\BIC@@@Dec#1#2#3!#4{% + \ifx\\#3\\% + \ifcase#1 % + \ifx\\#4\\% + \BIC@AfterFiFiFi{ 0}% + \else + \BIC@AfterFiFiFi{ #4}% + \fi + \else + \BIC@AfterFiFi{ #1#4}% + \fi + \else + \BIC@AfterFi{% + \BIC@@Dec#2#3!{#1#4}% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Add}, \op{Sub}} +% +% \begin{macro}{\bigintcalcAdd} +% \begin{macrocode} +\def\bigintcalcAdd#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Add + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Add} +% \begin{macrocode} +\def\BIC@Add#1!#2{% + \expandafter\expandafter\expandafter + \BIC@AddSwitch\bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bigintcalcSub} +% \begin{macrocode} +\def\bigintcalcSub#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Add + \bigintcalcNum{-#2}!{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@AddSwitch} +% Decision table for \cs{BIC@AddSwitch}. +% \begin{quote} +% \begin{tabular}[t]{@{}|l|l|l|l|l|@{}} +% \hline +% $x<0$ & $y<0$ & $-x>-y$ & $-$ & $\opAdd(-x,-y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opAdd(-y,-x)$\\ +% \cline{2-5} +% & else & $-x> y$ & $-$ & $\opSub(-x, y)$\\ +% \cline{3-5} +% & & $-x= y$ & & $0$\\ +% \cline{3-5} +% & & else & $+$ & $\opSub( y,-x)$\\ +% \hline +% else & $y<0$ & $ x>-y$ & $+$ & $\opSub( x,-y)$\\ +% \cline{3-5} +% & & $ x=-y$ & & $0$\\ +% \cline{3-5} +% & & else & $-$ & $\opSub(-y, x)$\\ +% \cline{2-5} +% & else & $ x> y$ & $+$ & $\opAdd( x, y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opAdd( y, x)$\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\BIC@AddSwitch#1#2!#3#4!{% + \ifx#1-% x < 0 + \ifx#3-% y < 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!#4!!!% + }% + \else % -x <= -y + \BIC@AfterFiFiFi{% + \BIC@AddXY#4!#2!!!% + }% + \fi + \else % y >= 0 + \ifcase\BIC@PosCmp#2!#3#4!% -x = y + \BIC@AfterFiFiFi{ 0}% + \or % -x > y + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!#3#4!!!% + }% + \else % -x <= y + \BIC@AfterFiFiFi{% + \BIC@SubXY#3#4!#2!!!% + }% + \fi + \fi + \else % x >= 0 + \ifx#3-% y < 0 + \ifcase\BIC@PosCmp#1#2!#4!% x = -y + \BIC@AfterFiFiFi{ 0}% + \or % x > -y + \BIC@AfterFiFiFi{% + \BIC@SubXY#1#2!#4!!!% + }% + \else % x <= -y + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@SubXY#4!#1#2!!!% + }% + \fi + \else % y >= 0 + \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y + \BIC@AfterFiFiFi{% + \BIC@AddXY#1#2!#3#4!!!% + }% + \else % x <= y + \BIC@AfterFiFiFi{% + \BIC@AddXY#3#4!#1#2!!!% + }% + \fi + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BigIntCalcAdd} +% \begin{macrocode} +\def\BigIntCalcAdd#1!#2!{% + \romannumeral0\BIC@AddXY#1!#2!!!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcSub} +% \begin{macrocode} +\def\BigIntCalcSub#1!#2!{% + \romannumeral0\BIC@SubXY#1!#2!!!% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@AddXY} +% \begin{macrocode} +\def\BIC@AddXY#1#2!#3#4!#5!#6!{% + \ifx\\#2\\% + \ifx\\#3\\% + \BIC@AfterFiFi{% + \BIC@DoAdd0!#1#5!#60!% + }% + \else + \BIC@AfterFiFi{% + \BIC@DoAdd0!#1#5!#3#6!% + }% + \fi + \else + \ifx\\#4\\% + \ifx\\#3\\% + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!{}!#1#5!#60!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!{}!#1#5!#3#6!% + }% + \fi + \else + \BIC@AfterFiFi{% + \BIC@AddXY#2!#4!#1#5!#3#6!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DoAdd} +% |#1|: carry\\ +% |#2|: reverted result\\ +% |#3#4|: reverted $x$\\ +% |#5#6|: reverted $y$ +% \begin{macrocode} +\def\BIC@DoAdd#1#2!#3#4!#5#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% +& \expandafter\BIC@Space +& \the\numexpr#1+#3+#5\relax#2% +$ \expandafter\expandafter\expandafter\BIC@AddResult +$ \BIC@AddDigit#1#3#5#2% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@DoAdd + \BIC@AddDigit#1#3#5#2!#4!#6!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AddResult} +% \begin{macrocode} +$ \def\BIC@AddResult#1{% +$ \ifx#10% +$ \expandafter\BIC@Space +$ \else +$ \expandafter\BIC@Space\expandafter#1% +$ \fi +$ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AddDigit} +% |#1|: carry\\ +% |#2|: digit of $x$\\ +% |#3|: digit of $y$ +% \begin{macrocode} +\def\BIC@AddDigit#1#2#3{% + \romannumeral0% +& \expandafter\BIC@@AddDigit\the\numexpr#1+#2+#3!% +$ \expandafter\BIC@@AddDigit\number% +$ \csname +$ BIC@AddCarry% +$ \ifcase#1 % +$ #2% +$ \else +$ \ifcase#2 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi +$ \fi +$ \endcsname#3!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@AddDigit} +% \begin{macrocode} +\def\BIC@@AddDigit#1!{% + \ifnum#1<10 % + \BIC@AfterFi{ 0#1}% + \else + \BIC@AfterFi{ #1}% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AddCarry0} +% \begin{macrocode} +$ \expandafter\def\csname BIC@AddCarry0\endcsname#1{#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AddCarry10} +% \begin{macrocode} +$ \expandafter\def\csname BIC@AddCarry10\endcsname#1{1#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@AddCarry[1-9]} +% \begin{macrocode} +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@AddCarry#1\endcsname##1{% +$ \ifcase##1 #1\or +$ #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 0{1\or2\or3\or4\or5\or6\or7\or8\or9}% +$ \BIC@Temp 1{2\or3\or4\or5\or6\or7\or8\or9\or10}% +$ \BIC@Temp 2{3\or4\or5\or6\or7\or8\or9\or10\or11}% +$ \BIC@Temp 3{4\or5\or6\or7\or8\or9\or10\or11\or12}% +$ \BIC@Temp 4{5\or6\or7\or8\or9\or10\or11\or12\or13}% +$ \BIC@Temp 5{6\or7\or8\or9\or10\or11\or12\or13\or14}% +$ \BIC@Temp 6{7\or8\or9\or10\or11\or12\or13\or14\or15}% +$ \BIC@Temp 7{8\or9\or10\or11\or12\or13\or14\or15\or16}% +$ \BIC@Temp 8{9\or10\or11\or12\or13\or14\or15\or16\or17}% +$ \BIC@Temp 9{10\or11\or12\or13\or14\or15\or16\or17\or18}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@SubXY} +% Preconditions: +% \begin{itemize} +% \item $x > y$, $x \geq 0$, and $y >= 0$ +% \item digits($x$) = digits($y$) +% \end{itemize} +% \begin{macrocode} +\def\BIC@SubXY#1#2!#3#4!#5!#6!{% + \ifx\\#2\\% + \ifx\\#3\\% + \BIC@AfterFiFi{% + \BIC@DoSub0!#1#5!#60!% + }% + \else + \BIC@AfterFiFi{% + \BIC@DoSub0!#1#5!#3#6!% + }% + \fi + \else + \ifx\\#4\\% + \ifx\\#3\\% + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!{}!#1#5!#60!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!{}!#1#5!#3#6!% + }% + \fi + \else + \BIC@AfterFiFi{% + \BIC@SubXY#2!#4!#1#5!#3#6!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DoSub} +% |#1|: carry\\ +% |#2|: reverted result\\ +% |#3#4|: reverted x\\ +% |#5#6|: reverted y +% \begin{macrocode} +\def\BIC@DoSub#1#2!#3#4!#5#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@SubResult + \BIC@SubDigit#1#3#5#2% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@DoSub + \BIC@SubDigit#1#3#5#2!#4!#6!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@SubResult} +% \begin{macrocode} +\def\BIC@SubResult#1{% + \ifx#10% + \expandafter\BIC@SubResult + \else + \expandafter\BIC@Space\expandafter#1% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@SubDigit} +% |#1|: carry\\ +% |#2|: digit of $x$\\ +% |#3|: digit of $y$ +% \begin{macrocode} +\def\BIC@SubDigit#1#2#3{% + \romannumeral0% +& \expandafter\BIC@@SubDigit\the\numexpr#2-#3-#1!% +$ \expandafter\BIC@@AddDigit\number +$ \csname +$ BIC@SubCarry% +$ \ifcase#1 % +$ #3% +$ \else +$ \ifcase#3 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi +$ \fi +$ \endcsname#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@SubDigit} +% \begin{macrocode} +& \def\BIC@@SubDigit#1!{% +& \ifnum#1<0 % +& \BIC@AfterFi{% +& \expandafter\BIC@Space +& \expandafter1\the\numexpr#1+10\relax +& }% +& \else +& \BIC@AfterFi{ 0#1}% +& \BIC@Fi +& }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@SubCarry0} +% \begin{macrocode} +$ \expandafter\def\csname BIC@SubCarry0\endcsname#1{#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@SubCarry10}% +% \begin{macrocode} +$ \expandafter\def\csname BIC@SubCarry10\endcsname#1{1#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@SubCarry[1-9]} +% \begin{macrocode} +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@SubCarry#1\endcsname##1{% +$ \ifcase##1 #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 1{19\or0\or1\or2\or3\or4\or5\or6\or7\or8}% +$ \BIC@Temp 2{18\or19\or0\or1\or2\or3\or4\or5\or6\or7}% +$ \BIC@Temp 3{17\or18\or19\or0\or1\or2\or3\or4\or5\or6}% +$ \BIC@Temp 4{16\or17\or18\or19\or0\or1\or2\or3\or4\or5}% +$ \BIC@Temp 5{15\or16\or17\or18\or19\or0\or1\or2\or3\or4}% +$ \BIC@Temp 6{14\or15\or16\or17\or18\or19\or0\or1\or2\or3}% +$ \BIC@Temp 7{13\or14\or15\or16\or17\or18\or19\or0\or1\or2}% +$ \BIC@Temp 8{12\or13\or14\or15\or16\or17\or18\or19\or0\or1}% +$ \BIC@Temp 9{11\or12\or13\or14\or15\or16\or17\or18\or19\or0}% +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Shl}, \op{Shr}} +% +% \begin{macro}{\bigintcalcShl} +% \begin{macrocode} +\def\bigintcalcShl#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Shl + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Shl} +% \begin{macrocode} +\def\BIC@Shl#1#2!{% + \ifx#1-% + \BIC@AfterFi{% + \expandafter-\romannumeral0% +& \BIC@@Shl#2!!% +$ \BIC@AddXY#2!#2!!!% + }% + \else + \BIC@AfterFi{% +& \BIC@@Shl#1#2!!% +$ \BIC@AddXY#1#2!#1#2!!!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcShl} +% \begin{macrocode} +\def\BigIntCalcShl#1!{% + \romannumeral0% +& \BIC@@Shl#1!!% +$ \BIC@AddXY#1!#1!!!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Shl} +% \begin{macrocode} +& \def\BIC@@Shl#1#2!{% +& \ifx\\#2\\% +& \BIC@AfterFi{% +& \BIC@@@Shl0!#1% +& }% +& \else +& \BIC@AfterFi{% +& \BIC@@Shl#2!#1% +& }% +& \BIC@Fi +& }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@Shl} +% |#1|: carry\\ +% |#2|: result\\ +% |#3#4|: reverted number +% \begin{macrocode} +& \def\BIC@@@Shl#1#2!#3#4!{% +& \ifx\\#4\\% +& \BIC@AfterFi{% +& \expandafter\BIC@Space +& \the\numexpr#3*2+#1\relax#2% +& }% +& \else +& \BIC@AfterFi{% +& \expandafter\BIC@@@@Shl\the\numexpr#3*2+#1!#2!#4!% +& }% +& \BIC@Fi +& }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@@Shl} +% \begin{macrocode} +& \def\BIC@@@@Shl#1!{% +& \ifnum#1<10 % +& \BIC@AfterFi{% +& \BIC@@@Shl0#1% +& }% +& \else +& \BIC@AfterFi{% +& \BIC@@@Shl#1% +& }% +& \BIC@Fi +& }% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bigintcalcShr} +% \begin{macrocode} +\def\bigintcalcShr#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Shr + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Shr} +% \begin{macrocode} +\def\BIC@Shr#1#2!{% + \ifx#1-% + \expandafter-\romannumeral0% + \BIC@AfterFi{% + \BIC@@Shr#2!% + }% + \else + \BIC@AfterFi{% + \BIC@@Shr#1#2!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcShr} +% \begin{macrocode} +\def\BigIntCalcShr#1!{% + \romannumeral0% + \BIC@@Shr#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Shr} +% \begin{macrocode} +\def\BIC@@Shr#1#2!{% + \ifcase#1 % + \BIC@AfterFi{ 0}% + \or + \ifx\\#2\\% + \BIC@AfterFiFi{ 0}% + \else + \BIC@AfterFiFi{% + \BIC@@@Shr#1#2!!% + }% + \fi + \else + \BIC@AfterFi{% + \BIC@@@Shr0#1#2!!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@Shr} +% |#1|: carry\\ +% |#2#3|: number\\ +% |#4|: result +% \begin{macrocode} +\def\BIC@@@Shr#1#2#3!#4!{% + \ifx\\#3\\% + \ifodd#1#2 % + \BIC@AfterFiFi{% +& \expandafter\BIC@ShrResult\the\numexpr(#1#2-1)/2\relax +$ \expandafter\expandafter\expandafter\BIC@ShrResult +$ \csname BIC@ShrDigit#1#2\endcsname + #4!% + }% + \else + \BIC@AfterFiFi{% +& \expandafter\BIC@ShrResult\the\numexpr#1#2/2\relax +$ \expandafter\expandafter\expandafter\BIC@ShrResult +$ \csname BIC@ShrDigit#1#2\endcsname + #4!% + }% + \fi + \else + \ifodd#1#2 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@@Shr\the\numexpr(#1#2-1)/2\relax1% +$ \expandafter\expandafter\expandafter\BIC@@@@Shr +$ \csname BIC@ShrDigit#1#2\endcsname + #3!#4!% + }% + \else + \BIC@AfterFiFi{% +& \expandafter\BIC@@@@Shr\the\numexpr#1#2/2\relax0% +$ \expandafter\expandafter\expandafter\BIC@@@@Shr +$ \csname BIC@ShrDigit#1#2\endcsname + #3!#4!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ShrResult} +% \begin{macrocode} +& \def\BIC@ShrResult#1#2!{ #2#1}% +$ \def\BIC@ShrResult#1#2#3!{ #3#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@@Shr} +% |#1|: new digit\\ +% |#2|: carry\\ +% |#3|: remaining number\\ +% |#4|: result +% \begin{macrocode} +\def\BIC@@@@Shr#1#2#3!#4!{% + \BIC@@@Shr#2#3!#4#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ShrDigit[00-19]} +% \begin{macrocode} +$ \def\BIC@Temp#1#2#3#4{% +$ \expandafter\def\csname BIC@ShrDigit#1#2\endcsname{#3#4}% +$ }% +$ \BIC@Temp 0000% +$ \BIC@Temp 0101% +$ \BIC@Temp 0210% +$ \BIC@Temp 0311% +$ \BIC@Temp 0420% +$ \BIC@Temp 0521% +$ \BIC@Temp 0630% +$ \BIC@Temp 0731% +$ \BIC@Temp 0840% +$ \BIC@Temp 0941% +$ \BIC@Temp 1050% +$ \BIC@Temp 1151% +$ \BIC@Temp 1260% +$ \BIC@Temp 1361% +$ \BIC@Temp 1470% +$ \BIC@Temp 1571% +$ \BIC@Temp 1680% +$ \BIC@Temp 1781% +$ \BIC@Temp 1890% +$ \BIC@Temp 1991% +% \end{macrocode} +% \end{macro} +% +% \subsection{\cs{BIC@Tim}} +% +% \begin{macro}{\BIC@Tim} +% Macro \cs{BIC@Tim} implements ``Number \emph{tim}es digit''.\\ +% |#1|: plain number without sign\\ +% |#2|: digit +\def\BIC@Tim#1!#2{% + \romannumeral0% + \ifcase#2 % 0 + \BIC@AfterFi{ 0}% + \or % 1 + \BIC@AfterFi{ #1}% + \or % 2 + \BIC@AfterFi{% + \BIC@Shl#1!% + }% + \else % 3-9 + \BIC@AfterFi{% + \BIC@@Tim#1!!#2% + }% + \BIC@Fi +} +% \begin{macrocode} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Tim} +% |#1#2|: number\\ +% |#3|: reverted number +% \begin{macrocode} +\def\BIC@@Tim#1#2!{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@ProcessTim0!#1% + }% + \else + \BIC@AfterFi{% + \BIC@@Tim#2!#1% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessTim} +% |#1|: carry\\ +% |#2|: result\\ +% |#3#4|: reverted number\\ +% |#5|: digit +% \begin{macrocode} +\def\BIC@ProcessTim#1#2!#3#4!#5{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\BIC@Space +& \the\numexpr#3*#5+#1\relax +$ \romannumeral0\BIC@TimDigit#3#5#1% + #2% + }% + \else + \BIC@AfterFi{% + \expandafter\BIC@@ProcessTim +& \the\numexpr#3*#5+#1% +$ \romannumeral0\BIC@TimDigit#3#5#1% + !#2!#4!#5% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@ProcessTim} +% |#1#2|: carry?, new digit\\ +% |#3|: new number\\ +% |#4|: old number\\ +% |#5|: digit +% \begin{macrocode} +\def\BIC@@ProcessTim#1#2!{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@ProcessTim0#1% + }% + \else + \BIC@AfterFi{% + \BIC@ProcessTim#1#2% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@TimDigit} +% |#1|: digit 0--9\\ +% |#2|: digit 3--9\\ +% |#3|: carry 0--9 +% \begin{macrocode} +$ \def\BIC@TimDigit#1#2#3{% +$ \ifcase#1 % 0 +$ \BIC@AfterFi{ #3}% +$ \or % 1 +$ \BIC@AfterFi{% +$ \expandafter\BIC@Space +$ \number\csname BIC@AddCarry#2\endcsname#3 % +$ }% +$ \else +$ \ifcase#3 % +$ \BIC@AfterFiFi{% +$ \expandafter\BIC@Space +$ \number\csname BIC@MulDigit#2\endcsname#1 % +$ }% +$ \else +$ \BIC@AfterFiFi{% +$ \expandafter\BIC@Space +$ \romannumeral0% +$ \expandafter\BIC@AddXY +$ \number\csname BIC@MulDigit#2\endcsname#1!% +$ #3!!!% +$ }% +$ \fi +$ \BIC@Fi +$ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@MulDigit[3-9]} +% \begin{macrocode} +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@MulDigit#1\endcsname##1{% +$ \ifcase##1 0% +$ \or ##1% +$ \or #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 3{6\or9\or12\or15\or18\or21\or24\or27}% +$ \BIC@Temp 4{8\or12\or16\or20\or24\or28\or32\or36}% +$ \BIC@Temp 5{10\or15\or20\or25\or30\or35\or40\or45}% +$ \BIC@Temp 6{12\or18\or24\or30\or36\or42\or48\or54}% +$ \BIC@Temp 7{14\or21\or28\or35\or42\or49\or56\or63}% +$ \BIC@Temp 8{16\or24\or32\or40\or48\or56\or64\or72}% +$ \BIC@Temp 9{18\or27\or36\or45\or54\or63\or72\or81}% +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Mul}} +% +% \begin{macro}{\bigintcalcMul} +% \begin{macrocode} +\def\bigintcalcMul#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Mul + \bigintcalcNum{#1}!{#2}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Mul} +% \begin{macrocode} +\def\BIC@Mul#1!#2{% + \expandafter\expandafter\expandafter\BIC@MulSwitch + \bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@MulSwitch} +% Decision table for \cs{BIC@MulSwitch}. +% \begin{quote} +% \begin{tabular}[t]{@{}|l|l|l|l|l|@{}} +% \hline +% $x=0$ &\multicolumn{3}{l}{} &$0$\\ +% \hline +% $x>0$ & $y=0$ &\multicolumn2l{}&$0$\\ +% \cline{2-5} +% & $y>0$ & $ x> y$ & $+$ & $\opMul( x, y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opMul( y, x)$\\ +% \cline{2-5} +% & $y<0$ & $ x>-y$ & $-$ & $\opMul( x,-y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opMul(-y, x)$\\ +% \hline +% $x<0$ & $y=0$ &\multicolumn2l{}&$0$\\ +% \cline{2-5} +% & $y>0$ & $-x> y$ & $-$ & $\opMul(-x, y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opMul( y,-x)$\\ +% \cline{2-5} +% & $y<0$ & $-x>-y$ & $+$ & $\opMul(-x,-y)$\\ +% \cline{3-3}\cline{5-5} +% & & else & & $\opMul(-y,-x)$\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\BIC@MulSwitch#1#2!#3#4!{% + \ifcase\BIC@Sgn#1#2! % x = 0 + \BIC@AfterFi{ 0}% + \or % x > 0 + \ifcase\BIC@Sgn#3#4! % y = 0 + \BIC@AfterFiFi{ 0}% + \or % y > 0 + \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#1#2!#3#4!% + }% + \else % x <= y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#3#4!#1#2!% + }% + \fi + \else % y < 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#1#2!#4!=1 % x > -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#1#2!#4!% + }% + \else % x <= -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#4!#1#2!% + }% + \fi + \fi + \else % x < 0 + \ifcase\BIC@Sgn#3#4! % y = 0 + \BIC@AfterFiFi{ 0}% + \or % y > 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#2!#3#4!=1 % -x > y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#2!#3#4!% + }% + \else % -x <= y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#3#4!#2!% + }% + \fi + \else % y < 0 + \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#2!#4!% + }% + \else % -x <= -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#4!#2!% + }% + \fi + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcMul} +% \begin{macrocode} +\def\BigIntCalcMul#1!#2!{% + \romannumeral0% + \BIC@ProcessMul0!#1!#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessMul} +% |#1|: result\\ +% |#2|: number $x$\\ +% |#3#4|: number $y$ +% \begin{macrocode} +\def\BIC@ProcessMul#1!#2!#3#4!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@Space + \bigintcalcAdd{\BIC@Tim#2!#3}{#10}% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@ProcessMul + \bigintcalcAdd{\BIC@Tim#2!#3}{#10}!#2!#4!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% + +% \subsection{\op{Sqr}} +% +% \begin{macro}{\bigintcalcSqr} +% \begin{macrocode} +\def\bigintcalcSqr#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Sqr + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Sqr} +% \begin{macrocode} +\def\BIC@Sqr#1{% + \ifx#1-% + \expandafter\BIC@@Sqr + \else + \expandafter\BIC@@Sqr\expandafter#1% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@Sqr} +% \begin{macrocode} +\def\BIC@@Sqr#1!{% + \BIC@ProcessMul0!#1!#1!% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Fac}} +% +% \begin{macro}{\bigintcalcFac} +% \begin{macrocode} +\def\bigintcalcFac#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Fac + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Fac} +% \begin{macrocode} +\def\BIC@Fac#1#2!{% + \ifx#1-% + \BIC@AfterFi{ 0\BigIntCalcError:FacNegative}% + \else + \ifnum\BIC@PosCmp#1#2!13!<0 % + \ifcase#1#2 % + \BIC@AfterFiFiFi{ 1}% 0! + \or\BIC@AfterFiFiFi{ 1}% 1! + \or\BIC@AfterFiFiFi{ 2}% 2! + \or\BIC@AfterFiFiFi{ 6}% 3! + \or\BIC@AfterFiFiFi{ 24}% 4! + \or\BIC@AfterFiFiFi{ 120}% 5! + \or\BIC@AfterFiFiFi{ 720}% 6! + \or\BIC@AfterFiFiFi{ 5040}% 7! + \or\BIC@AfterFiFiFi{ 40320}% 8! + \or\BIC@AfterFiFiFi{ 362880}% 9! + \or\BIC@AfterFiFiFi{ 3628800}% 10! + \or\BIC@AfterFiFiFi{ 39916800}% 11! + \or\BIC@AfterFiFiFi{ 479001600}% 12! +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \else + \BIC@AfterFiFi{% + \BIC@ProcessFac#1#2!479001600!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessFac} +% |#1|: $n$\\ +% |#2|: result +% \begin{macrocode} +\def\BIC@ProcessFac#1!#2!{% + \ifnum\BIC@PosCmp#1!12!=0 % + \BIC@AfterFi{ #2}% + \else + \BIC@AfterFi{% + \expandafter\BIC@@ProcessFac + \romannumeral0\BIC@ProcessMul0!#2!#1!% + !#1!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@ProcessFac} +% |#1|: result\\ +% |#2|: $n$ +% \begin{macrocode} +\def\BIC@@ProcessFac#1!#2!{% + \expandafter\BIC@ProcessFac + \romannumeral0\BIC@Dec#2!{}% + !#1!% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Pow}} +% +% \begin{macro}{\bigintcalcPow} +% |#1|: basis\\ +% |#2|: power +% \begin{macrocode} +\def\bigintcalcPow#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Pow + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Pow} +% |#1|: basis\\ +% |#2|: power +% \begin{macrocode} +\def\BIC@Pow#1!#2{% + \expandafter\expandafter\expandafter\BIC@PowSwitch + \bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@PowSwitch} +% |#1#2|: power $y$\\ +% |#3#4|: basis $x$\\ +% Decision table for \cs{BIC@PowSwitch}. +% \begin{quote} +% \def\M#1{\multicolumn{#1}{l}{}}% +% \begin{tabular}[t]{@{}|l|l|l|l|@{}} +% \hline +% $y=0$ & \M{2} & $1$\\ +% \hline +% $y=1$ & \M{2} & $x$\\ +% \hline +% $y=2$ & $x<0$ & \M{1} & $\opMul(-x,-x)$\\ +% \cline{2-4} +% & else & \M{1} & $\opMul(x,x)$\\ +% \hline +% $y<0$ & $x=0$ & \M{1} & DivisionByZero\\ +% \cline{2-4} +% & $x=1$ & \M{1} & $1$\\ +% \cline{2-4} +% & $x=-1$ & $\opODD(y)$ & $-1$\\ +% \cline{3-4} +% & & else & $1$\\ +% \cline{2-4} +% & else ($\string|x\string|>1$) & \M{1} & $0$\\ +% \hline +% $y>2$ & $x=0$ & \M{1} & $0$\\ +% \cline{2-4} +% & $x=1$ & \M{1} & $1$\\ +% \cline{2-4} +% & $x=-1$ & $\opODD(y)$ & $-1$\\ +% \cline{3-4} +% & & else & $1$\\ +% \cline{2-4} +% & $x<-1$ ($x<0$) & $\opODD(y)$ & $-\opPow(-x,y)$\\ +% \cline{3-4} +% & & else & $\opPow(-x,y)$\\ +% \cline{2-4} +% & else ($x>1$) & \M{1} & $\opPow(x,y)$\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\BIC@PowSwitch#1#2!#3#4!{% + \ifcase\ifx\\#2\\% + \ifx#100 % y = 0 + \else\ifx#111 % y = 1 + \else\ifx#122 % y = 2 + \else4 % y > 2 + \fi\fi\fi + \else + \ifx#1-3 % y < 0 + \else4 % y > 2 + \fi + \fi + \BIC@AfterFi{ 1}% y = 0 + \or % y = 1 + \BIC@AfterFi{ #3#4}% + \or % y = 2 + \ifx#3-% x < 0 + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#4!#4!% + }% + \else % x >= 0 + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#3#4!#3#4!% + }% + \fi + \or % y < 0 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else\ifx#311 % x = 1 + \else3 % x > 1 + \fi\fi + \else + \ifcase\BIC@MinusOne#3#4! % + 3 % |x| > 1 + \or + 2 % x = -1 +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \fi + \BIC@AfterFiFi{ 0\BigIntCalcError:DivisionByZero}% x = 0 + \or % x = 1 + \BIC@AfterFiFi{ 1}% x = 1 + \or % x = -1 + \ifcase\BIC@ModTwo#2! % even(y) + \BIC@AfterFiFiFi{ 1}% + \or % odd(y) + \BIC@AfterFiFiFi{ -1}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % |x| > 1 + \BIC@AfterFiFi{ 0}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % y > 2 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else\ifx#311 % x = 1 + \else4 % x > 1 + \fi\fi + \else + \ifx#3-% + \ifcase\BIC@MinusOne#3#4! % + 3 % x < -1 + \else + 2 % x = -1 + \fi + \else + 4 % x > 1 + \fi + \fi + \BIC@AfterFiFi{ 0}% x = 0 + \or % x = 1 + \BIC@AfterFiFi{ 1}% x = 1 + \or % x = -1 + \ifcase\BIC@ModTwo#1#2! % even(y) + \BIC@AfterFiFiFi{ 1}% + \or % odd(y) + \BIC@AfterFiFiFi{ -1}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % x < -1 + \ifcase\BIC@ModTwo#1#2! % even(y) + \BIC@AfterFiFiFi{% + \BIC@PowRec#4!#1#2!1!% + }% + \or % odd(y) + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@PowRec#4!#1#2!1!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % x > 1 + \BIC@AfterFiFi{% + \BIC@PowRec#3#4!#1#2!1!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Help macros} +% +% \begin{macro}{\BIC@ModTwo} +% Macro \cs{BIC@ModTwo} expects a number without sign +% and returns digit |1| or |0| if the number is odd or even. +% \begin{macrocode} +\def\BIC@ModTwo#1#2!{% + \ifx\\#2\\% + \ifodd#1 % + \BIC@AfterFiFi1% + \else + \BIC@AfterFiFi0% + \fi + \else + \BIC@AfterFi{% + \BIC@ModTwo#2!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BIC@MinusOne} +% Macro \cs{BIC@MinusOne} expects a number and returns +% digit |1| if the number equals minus one and returns |0| otherwise. +% \begin{macrocode} +\def\BIC@MinusOne#1#2!{% + \ifx#1-% + \BIC@@MinusOne#2!% + \else + 0% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@MinusOne} +% \begin{macrocode} +\def\BIC@@MinusOne#1#2!{% + \ifx#11% + \ifx\\#2\\% + 1% + \else + 0% + \fi + \else + 0% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Recursive calculation} +% +% \begin{macro}{\BIC@PowRec} +%\begin{quote} +%\begin{verbatim} +%Pow(x, y) { +% PowRec(x, y, 1) +%} +%PowRec(x, y, r) { +% if y == 1 then +% return r +% else +% ifodd y then +% return PowRec(x*x, y div 2, r*x) % y div 2 = (y-1)/2 +% else +% return PowRec(x*x, y div 2, r) +% fi +% fi +%} +%\end{verbatim} +%\end{quote} +% |#1|: $x$ (basis)\\ +% |#2#3|: $y$ (power)\\ +% |#4|: $r$ (result) +% \begin{macrocode} +\def\BIC@PowRec#1!#2#3!#4!{% + \ifcase\ifx#21\ifx\\#3\\0 \else1 \fi\else1 \fi % y = 1 + \ifnum\BIC@PosCmp#1!#4!=1 % x > r + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#1!#4!% + }% + \else + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#4!#1!% + }% + \fi + \or + \ifcase\BIC@ModTwo#2#3! % even(y) + \BIC@AfterFiFi{% + \expandafter\BIC@@PowRec\romannumeral0% + \BIC@@Shr#2#3!% + !#1!#4!% + }% + \or % odd(y) + \ifnum\BIC@PosCmp#1!#4!=1 % x > r + \BIC@AfterFiFiFi{% + \expandafter\BIC@@@PowRec\romannumeral0% + \BIC@ProcessMul0!#1!#4!% + !#1!#2#3!% + }% + \else + \BIC@AfterFiFiFi{% + \expandafter\BIC@@@PowRec\romannumeral0% + \BIC@ProcessMul0!#1!#4!% + !#1!#2#3!% + }% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@PowRec} +% |#1|: $y/2$\\ +% |#2|: $x$\\ +% |#3|: new $r$ ($r$ or $r*x$) +% \begin{macrocode} +\def\BIC@@PowRec#1!#2!#3!{% + \expandafter\BIC@PowRec\romannumeral0% + \BIC@ProcessMul0!#2!#2!% + !#1!#3!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@@PowRec} +% |#1|: $r*x$ +% |#2|: $x$ +% |#3|: $y$ +% \begin{macrocode} +\def\BIC@@@PowRec#1!#2!#3!{% + \expandafter\BIC@@PowRec\romannumeral0% + \BIC@@Shr#3!% + !#2!#1!% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Div}} +% +% \begin{macro}{\bigintcalcDiv} +% |#1|: $x$\\ +% |#2|: $y$ (divisor) +% \begin{macrocode} +\def\bigintcalcDiv#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Div + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Div} +% |#1|: $x$\\ +% |#2|: $y$ +% \begin{macrocode} +\def\BIC@Div#1!#2{% + \expandafter\expandafter\expandafter\BIC@DivSwitchSign + \bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcDiv} +% \begin{macrocode} +\def\BigIntCalcDiv#1!#2!{% + \romannumeral0% + \BIC@DivSwitchSign#2!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivSwitchSign} +% Decision table for \cs{BIC@DivSwitchSign}. +% \begin{quote} +% \begin{tabular}{@{}|l|l|l|@{}} +% \hline +% $y=0$ & \multicolumn{1}{l}{} & DivisionByZero\\ +% \hline +% $y>0$ & $x=0$ & $0$\\ +% \cline{2-3} +% & $x>0$ & DivSwitch$(+,x,y)$\\ +% \cline{2-3} +% & $x<0$ & DivSwitch$(-,-x,y)$\\ +% \hline +% $y<0$ & $x=0$ & $0$\\ +% \cline{2-3} +% & $x>0$ & DivSwitch$(-,x,-y)$\\ +% \cline{2-3} +% & $x<0$ & DivSwitch$(+,-x,-y)$\\ +% \hline +% \end{tabular} +% \end{quote} +% |#1|: $y$ (divisor)\\ +% |#2|: $x$ +% \begin{macrocode} +\def\BIC@DivSwitchSign#1#2!#3#4!{% + \ifcase\BIC@Sgn#1#2! % y = 0 + \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}% + \or % y > 0 + \ifcase\BIC@Sgn#3#4! % x = 0 + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch{}#3#4!#1#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch-#4!#1#2!% + }% + \fi + \else % y < 0 + \ifcase\BIC@Sgn#3#4! % x = 0 + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch-#3#4!#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch{}#4!#2!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivSwitch} +% Decision table for \cs{BIC@DivSwitch}. +% \begin{quote} +% \begin{tabular}{@{}|l|l|l|@{}} +% \hline +% $y=x$ & \multicolumn{1}{l}{} & sign $1$\\ +% \hline +% $y>x$ & \multicolumn{1}{l}{} & $0$\\ +% \hline +% $y<x$ & $y=1$ & sign $x$\\ +% \cline{2-3} +% & $y=2$ & sign Shr$(x)$\\ +% \cline{2-3} +% & $y=4$ & sign Shr(Shr$(x)$)\\ +% \cline{2-3} +% & else & sign ProcessDiv$(x,y)$\\ +% \hline +% \end{tabular} +% \end{quote} +% |#1|: sign\\ +% |#2|: $x$\\ +% |#3#4|: $y$ ($y\ne 0$) +% \begin{macrocode} +\def\BIC@DivSwitch#1#2!#3#4!{% + \ifcase\BIC@PosCmp#3#4!#2!% y = x + \BIC@AfterFi{ #11}% + \or % y > x + \BIC@AfterFi{ 0}% + \else % y < x + \ifx\\#1\\% + \else + \expandafter-\romannumeral0% + \fi + \ifcase\ifx\\#4\\% + \ifx#310 % y = 1 + \else\ifx#321 % y = 2 + \else\ifx#342 % y = 4 + \else3 % y > 2 + \fi\fi\fi + \else + 3 % y > 2 + \fi + \BIC@AfterFiFi{ #2}% y = 1 + \or % y = 2 + \BIC@AfterFiFi{% + \BIC@@Shr#2!% + }% + \or % y = 4 + \BIC@AfterFiFi{% + \expandafter\BIC@@Shr\romannumeral0% + \BIC@@Shr#2!!% + }% + \or % y > 2 + \BIC@AfterFiFi{% + \BIC@DivStartX#2!#3#4!!!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessDiv} +% |#1#2|: $x$\\ +% |#3#4|: $y$\\ +% |#5|: collect first digits of $x$\\ +% |#6|: corresponding digits of $y$ +% \begin{macrocode} +\def\BIC@DivStartX#1#2!#3#4!#5!#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \BIC@DivStartYii#6#3#4!{#5#1}#2=!% + }% + \else + \BIC@AfterFi{% + \BIC@DivStartX#2!#4!#5#1!#6#3!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivStartYii} +% |#1|: $y$\\ +% |#2|: $x$, |=| +% \begin{macrocode} +\def\BIC@DivStartYii#1!{% + \expandafter\BIC@DivStartYiv\romannumeral0% + \BIC@Shl#1!% + !#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivStartYiv} +% |#1|: $2y$\\ +% |#2|: $y$\\ +% |#3|: $x$, |=| +% \begin{macrocode} +\def\BIC@DivStartYiv#1!{% + \expandafter\BIC@DivStartYvi\romannumeral0% + \BIC@Shl#1!% + !#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivStartYvi} +% |#1|: $4y$\\ +% |#2|: $2y$\\ +% |#3|: $y$\\ +% |#4|: $x$, |=| +% \begin{macrocode} +\def\BIC@DivStartYvi#1!#2!{% + \expandafter\BIC@DivStartYviii\romannumeral0% + \BIC@AddXY#1!#2!!!% + !#1!#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivStartYviii} +% |#1|: $6y$\\ +% |#2|: $4y$\\ +% |#3|: $2y$\\ +% |#4|: $y$\\ +% |#5|: $x$, |=| +% \begin{macrocode} +\def\BIC@DivStartYviii#1!#2!{% + \expandafter\BIC@DivStart\romannumeral0% + \BIC@Shl#2!% + !#1!#2!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivStart} +% |#1|: $8y$\\ +% |#2|: $6y$\\ +% |#3|: $4y$\\ +% |#4|: $2y$\\ +% |#5|: $y$\\ +% |#6|: $x$, |=| +% \begin{macrocode} +\def\BIC@DivStart#1!#2!#3!#4!#5!#6!{% + \BIC@ProcessDiv#6!!#5!#4!#3!#2!#1!=% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessDiv} +% |#1#2#3|: $x$, |=|\\ +% |#4|: result\\ +% |#5|: $y$\\ +% |#6|: $2y$\\ +% |#7|: $4y$\\ +% |#8|: $6y$\\ +% |#9|: $8y$ +% \begin{macrocode} +\def\BIC@ProcessDiv#1#2#3!#4!#5!{% + \ifcase\BIC@PosCmp#5!#1!% y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#41}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#41!#5!% + }% + \fi + \or % y > #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#40}}% + \else + \ifx\\#4\\% + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv{#1#2}#3!!#5!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv{#1#2}#3!#40!#5!% + }% + \fi + \fi + \else % y < #1 + \BIC@AfterFi{% + \BIC@@ProcessDiv{#1}#2#3!#4!#5!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivCleanup} +% |#1|: result\\ +% |#2|: garbage +% \begin{macrocode} +\def\BIC@DivCleanup#1#2={ #1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@@ProcessDiv} +% \begin{macrocode} +\def\BIC@@ProcessDiv#1#2#3!#4!#5!#6!#7!{% + \ifcase\BIC@PosCmp#7!#1!% 4y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#44}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#44!#5!#6!#7!% + }% + \fi + \or % 4y > #1 + \ifcase\BIC@PosCmp#6!#1!% 2y = #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#42}}% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv#2#3!#42!#5!#6!#7!% + }% + \fi + \or % 2y > #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#41}}% + \else + \BIC@AfterFiFiFi{% + \BIC@DivSub#1!#5!#2#3!#41!#5!#6!#7!% + }% + \fi + \else % 2y < #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#6!!!% + !#2#3!#4!#5!23% + #6!#7!% + }% + \fi + \else % 4y < #1 + \BIC@AfterFi{% + \BIC@@@ProcessDiv{#1}#2#3!#4!#5!#6!#7!% + }% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@DivSub} +% Next token group: |#1|-|#2| and next digit |#3|. +% \begin{macrocode} +\def\BIC@DivSub#1!#2!#3{% + \expandafter\BIC@ProcessDiv\expandafter{% + \romannumeral0% + \BIC@SubXY#1!#2!!!% + #3% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessDivII} +% |#1|: $x'-2y$\\ +% |#2#3|: remaining $x$, |=|\\ +% |#4|: result\\ +% |#5|: $y$\\ +% |#6|: first possible result digit\\ +% |#7|: second possible result digit +% \begin{macrocode} +\def\BIC@ProcessDivII#1!#2#3!#4!#5!#6#7{% + \ifcase\BIC@PosCmp#5!#1!% y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#4#7!#5!% + }% + \fi + \or % y > #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#6}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv{#1#2}#3!#4#6!#5!% + }% + \fi + \else % y < #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}% + \else + \BIC@AfterFiFi{% + \BIC@DivSub#1!#5!#2#3!#4#7!#5!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ProcessDivIV} +% |#1#2#3|: $x$, |=|, $x>4y$\\ +% |#4|: result\\ +% |#5|: $y$\\ +% |#6|: $2y$\\ +% |#7|: $4y$\\ +% |#8|: $6y$\\ +% |#9|: $8y$ +% \begin{macrocode} +\def\BIC@@@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9!{% + \ifcase\BIC@PosCmp#8!#1!% 6y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#46}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#46!#5!#6!#7!#8!#9!% + }% + \fi + \or % 6y > #1 + \BIC@AfterFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#7!!!% + !#2#3!#4!#5!45% + #6!#7!#8!#9!% + }% + \else % 6y < #1 + \ifcase\BIC@PosCmp#9!#1!% 8y = #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#48}}% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv#2#3!#48!#5!#6!#7!#8!#9!% + }% + \fi + \or % 8y > #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#8!!!% + !#2#3!#4!#5!67% + #6!#7!#8!#9!% + }% + \else % 8y < #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#9!!!% + !#2#3!#4!#5!89% + #6!#7!#8!#9!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{\op{Mod}} +% +% \begin{macro}{\bigintcalcMod} +% |#1|: $x$\\ +% |#2|: $y$ +% \begin{macrocode} +\def\bigintcalcMod#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Mod + \bigintcalcNum{#1}!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@Mod} +% |#1|: $x$\\ +% |#2|: $y$ +% \begin{macrocode} +\def\BIC@Mod#1!#2{% + \expandafter\expandafter\expandafter\BIC@ModSwitchSign + \bigintcalcNum{#2}!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BigIntCalcMod} +% \begin{macrocode} +\def\BigIntCalcMod#1!#2!{% + \romannumeral0% + \BIC@ModSwitchSign#2!#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ModSwitchSign} +% Decision table for \cs{BIC@ModSwitchSign}. +% \begin{quote} +% \begin{tabular}{@{}|l|l|l|@{}} +% \hline +% $y=0$ & \multicolumn{1}{l}{} & DivisionByZero\\ +% \hline +% $y>0$ & $x=0$ & $0$\\ +% \cline{2-3} +% & else & ModSwitch$(+,x,y)$\\ +% \hline +% $y<0$ & \multicolumn{1}{l}{} & ModSwitch$(-,-x,-y)$\\ +% \hline +% \end{tabular} +% \end{quote} +% |#1#2|: $y$\\ +% |#3#4|: $x$ +% \begin{macrocode} +\def\BIC@ModSwitchSign#1#2!#3#4!{% + \ifcase\ifx\\#2\\% + \ifx#100 % y = 0 + \else1 % y > 0 + \fi + \else + \ifx#1-2 % y < 0 + \else1 % y > 0 + \fi + \fi + \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}% + \or % y > 0 + \ifcase\ifx\\#4\\\ifx#300 \else1 \fi\else1 \fi % x = 0 + \BIC@AfterFiFi{ 0}% + \else + \BIC@AfterFiFi{% + \BIC@ModSwitch{}#3#4!#1#2!% + }% + \fi + \else % y < 0 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else1 % x > 0 + \fi + \else + \ifx#3-2 % x < 0 + \else1 % x > 0 + \fi + \fi + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@ModSwitch--#3#4!#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@ModSwitch-#4!#2!% + }% + \fi + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ModSwitch} +% Decision table for \cs{BIC@ModSwitch}. +% \begin{quote} +% \begin{tabular}{@{}|l|l|l|@{}} +% \hline +% $y=1$ & \multicolumn{1}{l}{} & $0$\\ +% \hline +% $y=2$ & ifodd$(x)$ & sign $1$\\ +% \cline{2-3} +% & else & $0$\\ +% \hline +% $y>2$ & $x<0$ & +% $z\leftarrow x-(x/y)*y;\quad (z<0)\mathbin{?}z+y\mathbin{:}z$\\ +% \cline{2-3} +% & $x>0$ & $x - (x/y) * y$\\ +% \hline +% \end{tabular} +% \end{quote} +% |#1|: sign\\ +% |#2#3|: $x$\\ +% |#4#5|: $y$ +% \begin{macrocode} +\def\BIC@ModSwitch#1#2#3!#4#5!{% + \ifcase\ifx\\#5\\% + \ifx#410 % y = 1 + \else\ifx#421 % y = 2 + \else2 % y > 2 + \fi\fi + \else2 % y > 2 + \fi + \BIC@AfterFi{ 0}% y = 1 + \or % y = 2 + \ifcase\BIC@ModTwo#2#3! % even(x) + \BIC@AfterFiFi{ 0}% + \or % odd(x) + \BIC@AfterFiFi{ #11}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % y > 2 + \ifx\\#1\\% + \else + \expandafter\BIC@Space\romannumeral0% + \expandafter\BIC@ModMinus\romannumeral0% + \fi + \ifx#2-% x < 0 + \BIC@AfterFiFi{% + \expandafter\expandafter\expandafter\BIC@ModX + \bigintcalcSub{#2#3}{% + \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}% + }!#4#5!% + }% + \else % x > 0 + \BIC@AfterFiFi{% + \expandafter\expandafter\expandafter\BIC@Space + \bigintcalcSub{#2#3}{% + \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}% + }% + }% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ModMinus} +% \begin{macrocode} +\def\BIC@ModMinus#1{% + \ifx#10% + \BIC@AfterFi{ 0}% + \else + \BIC@AfterFi{ -#1}% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BIC@ModX} +% |#1#2|: $z$\\ +% |#3|: $x$ +% \begin{macrocode} +\def\BIC@ModX#1#2!#3!{% + \ifx#1-% z < 0 + \BIC@AfterFi{% + \expandafter\BIC@Space\romannumeral0% + \BIC@SubXY#3!#2!!!% + }% + \else % z >= 0 + \BIC@AfterFi{ #1#2}% + \BIC@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\BIC@AtEnd +% \end{macrocode} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \section{Test} +% +% \subsection{Catcode checks for loading} +% +% \begin{macrocode} +%<*test1> +% \end{macrocode} +% \begin{macrocode} +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input bigintcalc.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +% \end{macrocode} +% \begin{macrocode} +%</test1> +% \end{macrocode} +% +% \subsection{Macro tests} +% +% \subsubsection{Preamble with test macro definitions} +% +% \begin{macrocode} +%<*test2> +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +%<noetex>\let\SavedNumexpr\numexpr +%<noetex>\let\numexpr\UNDEFINED +\makeatletter +\chardef\BIC@TestMode=1 % +\makeatother +\usepackage{bigintcalc}[2007/09/27] +%<noetex>\let\numexpr\SavedNumexpr +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\newcommand*{\TestSpaceAtEnd}[1]{% +%<noetex> \let\SavedNumexpr\numexpr +%<noetex> \let\numexpr\UNDEFINED + \edef\resultA{#1}% + \edef\resultB{#1 }% +%<noetex> \let\numexpr\SavedNumexpr + \Expect*{\resultA\space}*{\resultB}% +} +\newcommand*{\TestResult}[2]{% +%<noetex> \let\SavedNumexpr\numexpr +%<noetex> \let\numexpr\UNDEFINED + \edef\result{#1}% +%<noetex> \let\numexpr\SavedNumexpr + \Expect*{\result}{#2}% +} +\newcommand*{\TestResultTwoExpansions}[2]{% +%<*noetex> + \begingroup + \let\numexpr\UNDEFINED + \expandafter\expandafter\expandafter + \endgroup +%</noetex> + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1}{#2}% +} +\newcount\TestCount +%<etex>\newcommand*{\TestArg}[1]{\numexpr#1\relax} +%<noetex>\newcommand*{\TestArg}[1]{#1} +\newcommand*{\TestTeXDivide}[2]{% + \TestCount=\TestArg{#1}\relax + \divide\TestCount by \TestArg{#2}\relax + \Expect*{\bigintcalcDiv{#1}{#2}}*{\the\TestCount}% +} +\newcommand*{\Test}[2]{% + \TestResult{#1}{#2}% + \TestResultTwoExpansions{#1}{#2}% + \TestSpaceAtEnd{#1}% +} +\newcommand*{\TestExch}[2]{\Test{#2}{#1}} +\newcommand*{\TestInv}[2]{% + \Test{\bigintcalcInv{#1}}{#2}% +} +\newcommand*{\TestAbs}[2]{% + \Test{\bigintcalcAbs{#1}}{#2}% +} +\newcommand*{\TestSgn}[2]{% + \Test{\bigintcalcSgn{#1}}{#2}% +} +\newcommand*{\TestMin}[3]{% + \Test{\bigintcalcMin{#1}{#2}}{#3}% +} +\newcommand*{\TestMax}[3]{% + \Test{\bigintcalcMax{#1}{#2}}{#3}% +} +\newcommand*{\TestCmp}[3]{% + \Test{\bigintcalcCmp{#1}{#2}}{#3}% +} +\newcommand*{\TestOdd}[2]{% + \Test{\bigintcalcOdd{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcOdd + \bigintcalcAbs{#1}!% + }{#2}% + }% + \x +} +\newcommand*{\TestInc}[2]{% + \Test{\bigintcalcInc{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcInc\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestDec}[2]{% + \Test{\bigintcalcDec{#1}}{#2}% + \ifnum\bigintcalcSgn{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDec\bigintcalcNum{#1}!% + }{#2}% + }% + \x + \fi +} +\newcommand*{\TestAdd}[3]{% + \Test{\bigintcalcAdd{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcAdd + \bigintcalcNum{#2}!\bigintcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestSub}[3]{% + \Test{\bigintcalcSub{#1}{#2}}{#3}% + \ifnum\bigintcalcSgn{#1}>0 % + \ifnum\bigintcalcSgn{#2}> 0 % + \ifnum\bigintcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcSub + \bigintcalcNum{#1}!\bigintcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi +} +\newcommand*{\TestShl}[2]{% + \Test{\bigintcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShl\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestShr}[2]{% + \Test{\bigintcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcShr\bigintcalcAbs{#1}!% + }{\bigintcalcAbs{#2}}% + }% + \x +} +\newcommand*{\TestMul}[3]{% + \Test{\bigintcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMul + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x +} +\newcommand*{\TestSqr}[2]{% + \Test{\bigintcalcSqr{#1}}{#2}% +} +\newcommand*{\TestFac}[2]{% + \expandafter\TestExch\expandafter{% + \the\numexpr#2% + }{\bigintcalcFac{#1}}% +} +\newcommand*{\TestFacBig}[2]{% + \Test{\bigintcalcFac{#1}}{#2}% +} +\newcommand*{\TestPow}[3]{% + \Test{\bigintcalcPow{#1}{#2}}{#3}% +} +\newcommand*{\TestDiv}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \TestTeXDivide{#1}{#2}% +} +\newcommand*{\TestDivBig}[3]{% + \Test{\bigintcalcDiv{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcDiv\bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% +} +\newcommand*{\TestMod}[3]{% + \Test{\bigintcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\bigintcalcSgn{#1} 0% + \or + \ifcase\bigintcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\bigintcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\BigIntCalcMod + \bigintcalcAbs{#1}!\bigintcalcAbs{#2}!% + }{\bigintcalcAbs{#3}}% + }% + \x + \fi +} +% \end{macrocode} +% +% \subsubsection{Time} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +% \end{macrocode} +% +% \subsubsection{Test sets} +% +% \begin{macrocode} +\makeatletter + +\begin{qstest}{inv}{inv}% + \TestInv{0}{0}% + \TestInv{1}{-1}% + \TestInv{-1}{1}% + \TestInv{10}{-10}% + \TestInv{-10}{10}% + \TestInv{2147483647}{-2147483647}% + \TestInv{-2147483647}{2147483647}% + \TestInv{12345678901234567890}{-12345678901234567890}% + \TestInv{-12345678901234567890}{12345678901234567890}% + \TestInv{ 0 }{0}% + \TestInv{ 1 }{-1}% + \TestInv{--1}{-1}% + \TestInv{\number\z@}{0}% + \TestInv{\ifx\relax\relax1\fi}{-1}% + \TestInv{\ifx\relax\relax-\fi\ifx234\else1\fi}{1}% +\end{qstest} + +\begin{qstest}{abs}{abs}% + \TestAbs{0}{0}% + \TestAbs{1}{1}% + \TestAbs{-1}{1}% + \TestAbs{10}{10}% + \TestAbs{-10}{10}% + \TestAbs{2147483647}{2147483647}% + \TestAbs{-2147483647}{2147483647}% + \TestAbs{12345678901234567890}{12345678901234567890}% + \TestAbs{-12345678901234567890}{12345678901234567890}% + \TestAbs{ 0 }{0}% + \TestAbs{ 1 }{1}% + \TestAbs{--1}{1}% + \TestAbs{-+-+1}{1}% + \TestAbs{00000000000}{0}% + \TestAbs{00000001000}{1000}% + \TestAbs{\ifx\relax\relax 0\else 1\fi}{0}% +\end{qstest} + +\begin{qstest}{sign}{sign}% + \TestSgn{0}{0}% + \TestSgn{1}{1}% + \TestSgn{-1}{-1}% + \TestSgn{10}{1}% + \TestSgn{-10}{-1}% + \TestSgn{2147483647}{1}% + \TestSgn{-2147483647}{-1}% + \TestSgn{12345678901234567890}{1}% + \TestSgn{-12345678901234567890}{-1}% + \TestSgn{ 0 }{0}% + \TestSgn{ 2 }{1}% + \TestSgn{ -2 }{-1}% + \TestSgn{--2}{1}% + \TestSgn{\number\z@}{0}% + \TestSgn{\number\@ne}{1}% + \TestSgn{\number\m@ne}{-1}% + \TestSgn{% + -+-+\number\z@\number\z@ + \iftrue1\fi\iftrue2\fi\iftrue3\fi + }{1}% +\end{qstest} + +\begin{qstest}{min}{min}% + \TestMin{0}{1}{0}% + \TestMin{1}{0}{0}% + \TestMin{-10}{-20}{-20}% + \TestMin{ 1 }{ 2 }{1}% + \TestMin{ 2 }{ 1 }{1}% + \TestMin{1}{1}{1}% + \TestMin{\number\z@}{\number\@ne}{0}% + \TestMin{\number\@ne}{\number\m@ne}{-1}% +\end{qstest} + +\begin{qstest}{max}{max}% + \TestMax{0}{1}{1}% + \TestMax{1}{0}{1}% + \TestMax{-10}{-20}{-10}% + \TestMax{ 1 }{ 2 }{2}% + \TestMax{ 2 }{ 1 }{2}% + \TestMax{1}{1}{1}% + \TestMax{\number\z@}{\number\@ne}{1}% + \TestMax{\number\@ne}{\number\m@ne}{1}% +\end{qstest} + +\begin{qstest}{cmp}{cmp}% + \TestCmp{0}{0}{0}% + \TestCmp{-21}{17}{-1}% + \TestCmp{3}{4}{-1}% + \TestCmp{-10}{-10}{0}% + \TestCmp{-10}{-11}{1}% + \TestCmp{100}{5}{1}% + \TestCmp{9}{10}{-1}% + \TestCmp{10}{9}{1}% + \TestCmp{ 3 }{ 3 }{0}% + \TestCmp{-9}{-10}{1}% + \TestCmp{-10}{-9}{-1}% + \TestCmp{-3}{-3}{0}% + \TestCmp{0}{-2}{1}% + \TestCmp{0}{2}{-1}% + \TestCmp{2}{0}{1}% + \TestCmp{-2}{0}{-1}% + \TestCmp{12}{11}{1}% + \TestCmp{11}{12}{-1}% + \TestCmp{2147483647}{-2147483647}{1}% + \TestCmp{-2147483647}{2147483647}{-1}% + \TestCmp{2147483647}{2147483647}{0}% + \TestCmp{\number\z@}{\number\@ne}{-1}% + \TestCmp{\number\@ne}{\number\m@ne}{1}% + \TestCmp{ 4 }{ 5 }{-1}% + \TestCmp{ -3 }{ -7 }{1}% +\end{qstest} + +\begin{qstest}{odd}{odd} +\tracingmacros=1 + \TestOdd{0}{0}% + \TestOdd{1}{1}% + \TestOdd{2}{0}% + \TestOdd{3}{1}% + \TestOdd{14}{0}% + \TestOdd{15}{1}% + \TestOdd{12345678901234567896}{0}% + \TestOdd{12345678901234567897}{1}% +\end{qstest} + +\begin{qstest}{inc}{inc}% + \TestInc{0}{1}% + \TestInc{1}{2}% + \TestInc{-1}{0}% + \TestInc{10}{11}% + \TestInc{-10}{-9}% + \TestInc{ 3 }{4}% + \TestInc{999}{1000}% + \TestInc{-1000}{-999}% + \TestInc{129}{130}% + \TestInc{2147483646}{2147483647}% + \TestInc{-2147483647}{-2147483646}% + \TestInc{12345678901234567890}{12345678901234567891}% + \TestInc{99999999999999999999}{100000000000000000000}% + \TestInc{-12345678901234567891}{-12345678901234567890}% + \TestInc{-100000000000000000000}{-99999999999999999999}% +\end{qstest} + +\begin{qstest}{dec}{dec}% + \TestDec{0}{-1}% + \TestDec{1}{0}% + \TestDec{-1}{-2}% + \TestDec{10}{9}% + \TestDec{-10}{-11}% + \TestDec{1000}{999}% + \TestDec{-999}{-1000}% + \TestDec{130}{129}% + \TestDec{2147483647}{2147483646}% + \TestDec{-2147483646}{-2147483647}% + \TestDec{12345678901234567891}{12345678901234567890}% + \TestDec{100000000000000000000}{99999999999999999999}% + \TestDec{-12345678901234567890}{-12345678901234567891}% + \TestDec{-99999999999999999999}{-100000000000000000000}% +\end{qstest} + +\begin{qstest}{add}{add}% + \TestAdd{0}{0}{0}% + \TestAdd{1}{0}{1}% + \TestAdd{0}{1}{1}% + \TestAdd{1}{2}{3}% + \TestAdd{-1}{-1}{-2}% + \TestAdd{2147483646}{1}{2147483647}% + \TestAdd{-2147483647}{2147483647}{0}% + \TestAdd{20}{-5}{15}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{-4}{1}{-3}% + \TestAdd{-1}{4}{3}% + \TestAdd{4}{-1}{3}% + \TestAdd{1}{-4}{-3}% + \TestAdd{-4}{-1}{-5}% + \TestAdd{-1}{-4}{-5}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{ -4 }{ 1 }{-3}% + \TestAdd{ -1 }{ 4 }{3}% + \TestAdd{ 4 }{ -1 }{3}% + \TestAdd{ 1 }{ -4 }{-3}% + \TestAdd{ -4 }{ -1 }{-5}% + \TestAdd{ -1 }{ -4 }{-5}% + \TestAdd{876543210}{111111111}{987654321}% + \TestAdd{999999999}{2}{1000000001}% +\end{qstest} + +\begin{qstest}{sub}{sub} + \TestSub{0}{0}{0}% + \TestSub{1}{0}{1}% + \TestSub{1}{2}{-1}% + \TestSub{-1}{-1}{0}% + \TestSub{2147483646}{-1}{2147483647}% + \TestSub{-2147483647}{-2147483647}{0}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{-4}{1}{-5}% + \TestSub{-1}{4}{-5}% + \TestSub{4}{-1}{5}% + \TestSub{1}{-4}{5}% + \TestSub{-4}{-1}{-3}% + \TestSub{-1}{-4}{3}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{ -4 }{ 1 }{-5}% + \TestSub{ -1 }{ 4 }{-5}% + \TestSub{ 4 }{ -1 }{5}% + \TestSub{ 1 }{ -4 }{5}% + \TestSub{ -4 }{ -1 }{-3}% + \TestSub{ -1 }{ -4 }{3}% + \TestSub{1000000000}{2}{999999998}% + \TestSub{987654321}{111111111}{876543210}% +\end{qstest} + +\begin{qstest}{shl}{shl} + \TestShl{0}{0}% + \TestShl{1}{2}% + \TestShl{2}{4}% + \TestShl{5621}{11242}% + \TestShl{1073741823}{2147483646}% +\end{qstest} + +\begin{qstest}{shr}{shr} + \TestShr{0}{0}% + \TestShr{1}{0}% + \TestShr{2}{1}% + \TestShr{3}{1}% + \TestShr{4}{2}% + \TestShr{5}{2}% + \TestShr{6}{3}% + \TestShr{7}{3}% + \TestShr{8}{4}% + \TestShr{9}{4}% + \TestShr{10}{5}% + \TestShr{11}{5}% + \TestShr{12}{6}% + \TestShr{13}{6}% + \TestShr{14}{7}% + \TestShr{15}{7}% + \TestShr{16}{8}% + \TestShr{17}{8}% + \TestShr{18}{9}% + \TestShr{19}{9}% + \TestShr{20}{10}% + \TestShr{21}{10}% + \TestShr{22}{11}% + \TestShr{11241}{5620}% + \TestShr{73054202}{36527101}% + \TestShr{2147483646}{1073741823}% +\end{qstest} + +\begin{qstest}{mul}{mul} + \TestMul{0}{0}{0}% + \TestMul{1}{0}{0}% + \TestMul{0}{1}{0}% + \TestMul{1}{1}{1}% + \TestMul{3}{1}{3}% + \TestMul{1}{-3}{-3}% + \TestMul{-4}{-5}{20}% + \TestMul{3}{7}{21}% + \TestMul{7}{3}{21}% + \TestMul{3}{-7}{-21}% + \TestMul{7}{-3}{-21}% + \TestMul{-3}{7}{-21}% + \TestMul{-7}{3}{-21}% + \TestMul{-3}{-7}{21}% + \TestMul{-7}{-3}{21}% + \TestMul{12}{11}{132}% + \TestMul{999}{333}{332667}% + \TestMul{1000}{4321}{4321000}% + \TestMul{12345}{173955}{2147474475}% + \TestMul{1073741823}{2}{2147483646}% + \TestMul{2}{1073741823}{2147483646}% + \TestMul{-1073741823}{2}{-2147483646}% + \TestMul{2}{-1073741823}{-2147483646}% + \TestMul{6706022400}{13}{87178291200}% +\end{qstest} + +\begin{qstest}{sqr}{sqr} + \TestSqr{0}{0}% + \TestSqr{1}{1}% + \TestSqr{2}{4}% + \TestSqr{3}{9}% + \TestSqr{4}{16}% + \TestSqr{9}{81}% + \TestSqr{10}{100}% + \TestSqr{46340}{2147395600}% + \TestSqr{-1}{1}% + \TestSqr{-2}{4}% + \TestSqr{-46340}{2147395600}% +\end{qstest} + +\begin{qstest}{fac}{fac} + \TestFac{0}{1}% + \TestFac{1}{1}% + \TestFac{2}{2}% + \TestFac{3}{2*3}% + \TestFac{4}{2*3*4}% + \TestFac{5}{2*3*4*5}% + \TestFac{6}{2*3*4*5*6}% + \TestFac{7}{2*3*4*5*6*7}% + \TestFac{8}{2*3*4*5*6*7*8}% + \TestFac{9}{2*3*4*5*6*7*8*9}% + \TestFac{10}{2*3*4*5*6*7*8*9*10}% + \TestFac{11}{2*3*4*5*6*7*8*9*10*11}% + \TestFac{12}{2*3*4*5*6*7*8*9*10*11*12}% + \TestFacBig{13}{6227020800}% + \TestFacBig{14}{87178291200}% + \TestFacBig{15}{1307674368000}% + \TestFacBig{16}{20922789888000}% + \TestFacBig{17}{355687428096000}% + \TestFacBig{18}{6402373705728000}% + \TestFacBig{19}{121645100408832000}% + \TestFacBig{20}{2432902008176640000}% + \TestFacBig{21}{51090942171709440000}% + \TestFacBig{22}{1124000727777607680000}% +\end{qstest} + +\begin{qstest}{pow}{pow} + \TestPow{-2}{0}{1}% + \TestPow{-1}{0}{1}% + \TestPow{0}{0}{1}% + \TestPow{1}{0}{1}% + \TestPow{2}{0}{1}% + \TestPow{3}{0}{1}% + \TestPow{-2}{1}{-2}% + \TestPow{-1}{1}{-1}% + \TestPow{1}{1}{1}% + \TestPow{2}{1}{2}% + \TestPow{3}{1}{3}% + \TestPow{-2}{2}{4}% + \TestPow{-1}{2}{1}% + \TestPow{0}{2}{0}% + \TestPow{1}{2}{1}% + \TestPow{2}{2}{4}% + \TestPow{3}{2}{9}% + \TestPow{0}{1}{0}% + \TestPow{1}{-2}{1}% + \TestPow{1}{-1}{1}% + \TestPow{-1}{-2}{1}% + \TestPow{-1}{-1}{-1}% + \TestPow{-1}{3}{-1}% + \TestPow{-1}{4}{1}% + \TestPow{-2}{-1}{0}% + \TestPow{-2}{-2}{0}% + \TestPow{2}{3}{8}% + \TestPow{2}{4}{16}% + \TestPow{2}{5}{32}% + \TestPow{2}{6}{64}% + \TestPow{2}{7}{128}% + \TestPow{2}{8}{256}% + \TestPow{2}{9}{512}% + \TestPow{2}{10}{1024}% + \TestPow{-2}{3}{-8}% + \TestPow{-2}{4}{16}% + \TestPow{-2}{5}{-32}% + \TestPow{-2}{6}{64}% + \TestPow{-2}{7}{-128}% + \TestPow{-2}{8}{256}% + \TestPow{-2}{9}{-512}% + \TestPow{-2}{10}{1024}% + \TestPow{3}{3}{27}% + \TestPow{3}{4}{81}% + \TestPow{3}{5}{243}% + \TestPow{-3}{3}{-27}% + \TestPow{-3}{4}{81}% + \TestPow{-3}{5}{-243}% + \TestPow{2}{30}{1073741824}% + \TestPow{-3}{19}{-1162261467}% + \TestPow{5}{13}{1220703125}% + \TestPow{-7}{11}{-1977326743}% +\end{qstest} + +\begin{qstest}{div}{div} + \TestDiv{1}{1}{1}% + \TestDiv{2}{1}{2}% + \TestDiv{-2}{1}{-2}% + \TestDiv{2}{-1}{-2}% + \TestDiv{-2}{-1}{2}% + \TestDiv{15}{2}{7}% + \TestDiv{-16}{2}{-8}% + \TestDiv{1}{2}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{-2}{3}{0}% + \TestDiv{2}{-3}{0}% + \TestDiv{-2}{-3}{0}% + \TestDiv{13}{3}{4}% + \TestDiv{-13}{-3}{4}% + \TestDiv{-13}{3}{-4}% + \TestDiv{-6}{5}{-1}% + \TestDiv{-5}{5}{-1}% + \TestDiv{-4}{5}{0}% + \TestDiv{-3}{5}{0}% + \TestDiv{-2}{5}{0}% + \TestDiv{-1}{5}{0}% + \TestDiv{0}{5}{0}% + \TestDiv{1}{5}{0}% + \TestDiv{2}{5}{0}% + \TestDiv{3}{5}{0}% + \TestDiv{4}{5}{0}% + \TestDiv{5}{5}{1}% + \TestDiv{6}{5}{1}% + \TestDiv{-5}{4}{-1}% + \TestDiv{-4}{4}{-1}% + \TestDiv{-3}{4}{0}% + \TestDiv{-2}{4}{0}% + \TestDiv{-1}{4}{0}% + \TestDiv{0}{4}{0}% + \TestDiv{1}{4}{0}% + \TestDiv{2}{4}{0}% + \TestDiv{3}{4}{0}% + \TestDiv{4}{4}{1}% + \TestDiv{5}{4}{1}% + \TestDiv{12345}{678}{18}% + \TestDiv{32372}{5952}{5}% + \TestDiv{284271294}{18162}{15651}% + \TestDiv{217652429}{12561}{17327}% + \TestDiv{462028434}{5439}{84947}% + \TestDiv{2147483647}{1000}{2147483}% + \TestDiv{2147483647}{-1000}{-2147483}% + \TestDiv{-2147483647}{1000}{-2147483}% + \TestDiv{-2147483647}{-1000}{2147483}% + \TestDiv{0}{3}{0}% + \TestDiv{1}{3}{0}% + \TestDiv{2}{3}{0}% + \TestDiv{3}{3}{1}% + \TestDiv{4}{3}{1}% + \TestDiv{5}{3}{1}% + \TestDiv{6}{3}{2}% + \TestDiv{7}{3}{2}% + \TestDiv{8}{3}{2}% + \TestDiv{9}{3}{3}% + \TestDiv{10}{3}{3}% + \TestDiv{11}{3}{3}% + \TestDiv{12}{3}{4}% + \TestDiv{13}{3}{4}% + \TestDiv{14}{3}{4}% + \TestDiv{15}{3}{5}% + \TestDiv{16}{3}{5}% + \TestDiv{17}{3}{5}% + \TestDiv{18}{3}{6}% + \TestDiv{19}{3}{6}% + \TestDiv{20}{3}{6}% + \TestDiv{21}{3}{7}% + \TestDiv{22}{3}{7}% + \TestDiv{23}{3}{7}% + \TestDiv{24}{3}{8}% + \TestDiv{25}{3}{8}% + \TestDiv{26}{3}{8}% + \TestDiv{27}{3}{9}% + \TestDiv{28}{3}{9}% + \TestDiv{29}{3}{9}% + \TestDiv{30}{3}{10}% + \TestDiv{31}{3}{10}% + \TestDivBig{17363436332507}{24702}{702916214}% +\end{qstest} + +\begin{qstest}{mod}{mod} + \TestMod{-6}{5}{4}% + \TestMod{-5}{5}{0}% + \TestMod{-4}{5}{1}% + \TestMod{-3}{5}{2}% + \TestMod{-2}{5}{3}% + \TestMod{-1}{5}{4}% + \TestMod{0}{5}{0}% + \TestMod{1}{5}{1}% + \TestMod{2}{5}{2}% + \TestMod{3}{5}{3}% + \TestMod{4}{5}{4}% + \TestMod{5}{5}{0}% + \TestMod{6}{5}{1}% + \TestMod{-5}{4}{3}% + \TestMod{-4}{4}{0}% + \TestMod{-3}{4}{1}% + \TestMod{-2}{4}{2}% + \TestMod{-1}{4}{3}% + \TestMod{0}{4}{0}% + \TestMod{1}{4}{1}% + \TestMod{2}{4}{2}% + \TestMod{3}{4}{3}% + \TestMod{4}{4}{0}% + \TestMod{5}{4}{1}% + \TestMod{-6}{-5}{-1}% + \TestMod{-5}{-5}{0}% + \TestMod{-4}{-5}{-4}% + \TestMod{-3}{-5}{-3}% + \TestMod{-2}{-5}{-2}% + \TestMod{-1}{-5}{-1}% + \TestMod{0}{-5}{0}% + \TestMod{1}{-5}{-4}% + \TestMod{2}{-5}{-3}% + \TestMod{3}{-5}{-2}% + \TestMod{4}{-5}{-1}% + \TestMod{5}{-5}{0}% + \TestMod{6}{-5}{-4}% + \TestMod{-5}{-4}{-1}% + \TestMod{-4}{-4}{0}% + \TestMod{-3}{-4}{-3}% + \TestMod{-2}{-4}{-2}% + \TestMod{-1}{-4}{-1}% + \TestMod{0}{-4}{0}% + \TestMod{1}{-4}{-3}% + \TestMod{2}{-4}{-2}% + \TestMod{3}{-4}{-1}% + \TestMod{4}{-4}{0}% + \TestMod{5}{-4}{-3}% + \TestMod{2147483647}{1000}{647}% + \TestMod{2147483647}{-1000}{-353}% + \TestMod{-2147483647}{1000}{353}% + \TestMod{-2147483647}{-1000}{-647}% + \TestMod{ 0 }{ 4 }{0}% + \TestMod{ 1 }{ 4 }{1}% + \TestMod{ -1 }{ 4 }{3}% + \TestMod{ 0 }{ -4 }{0}% + \TestMod{ 1 }{ -4 }{-3}% + \TestMod{ -1 }{ -4 }{-1}% + \TestMod{18362}{25}{12}% +\end{qstest} + +\newcommand*{\TestError}[2]{% + \begingroup + \expandafter\def\csname BigIntCalcError:#1\endcsname{}% + \Expect*{#2}{0}% + \expandafter\def\csname BigIntCalcError:#1\endcsname{ERROR}% + \Expect*{#2}{0ERROR}% + \endgroup +} +\begin{qstest}{error}{error} + \TestError{FacNegative}{\bigintcalcFac{-1}}% + \TestError{FacNegative}{\bigintcalcFac{-2147483647}}% + \TestError{DivisionByZero}{\bigintcalcPow{0}{-1}}% + \TestError{DivisionByZero}{\bigintcalcDiv{1}{0}}% + \TestError{DivisionByZero}{\bigintcalcMod{1}{0}}% +\end{qstest} + +\begin{document} +\end{document} +%</test2> +% \end{macrocode} +% +% \section{Installation} +% +% \subsection{Download} +% +% \paragraph{Package.} This package is available on +% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}: +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/bigintcalc.dtx}] The source file. +% \item[\CTAN{macros/latex/contrib/oberdiek/bigintcalc.pdf}] Documentation. +% \end{description} +% +% +% \paragraph{Bundle.} All the packages of the bundle `oberdiek' +% are also available in a TDS compliant ZIP archive. There +% the packages are already unpacked and the documentation files +% are generated. The files and directories obey the TDS standard. +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/oberdiek-tds.zip}] +% \end{description} +% \emph{TDS} refers to the standard ``A Directory Structure +% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories +% with \xfile{texmf} in their name are usually organized this way. +% +% \subsection{Bundle installation} +% +% \paragraph{Unpacking.} Unpack the \xfile{oberdiek-tds.zip} in the +% TDS tree (also known as \xfile{texmf} tree) of your choice. +% Example (linux): +% \begin{quote} +% |unzip oberdiek-tds.zip -d ~/texmf| +% \end{quote} +% +% \paragraph{Script installation.} +% Check the directory \xfile{TDS:scripts/oberdiek/} for +% scripts that need further installation steps. +% Package \xpackage{attachfile2} comes with the Perl script +% \xfile{pdfatfi.pl} that should be installed in such a way +% that it can be called as \texttt{pdfatfi}. +% Example (linux): +% \begin{quote} +% |chmod +x scripts/oberdiek/pdfatfi.pl|\\ +% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/| +% \end{quote} +% +% \subsection{Package installation} +% +% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting +% \docstrip\ archive. The files are extracted by running the +% \xfile{.dtx} through \plainTeX: +% \begin{quote} +% \verb|tex bigintcalc.dtx| +% \end{quote} +% +% \paragraph{TDS.} Now the different files must be moved into +% the different directories in your installation TDS tree +% (also known as \xfile{texmf} tree): +% \begin{quote} +% \def\t{^^A +% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} +% bigintcalc.sty & tex/generic/oberdiek/bigintcalc.sty\\ +% bigintcalc.pdf & doc/latex/oberdiek/bigintcalc.pdf\\ +% bigintcalc-test1.tex & doc/latex/oberdiek/bigintcalc-test1.tex\\ +% bigintcalc-test2.tex & doc/latex/oberdiek/bigintcalc-test2.tex\\ +% bigintcalc-test3.tex & doc/latex/oberdiek/bigintcalc-test3.tex\\ +% bigintcalc.dtx & source/latex/oberdiek/bigintcalc.dtx\\ +% \end{tabular}^^A +% }^^A +% \sbox0{\t}^^A +% \ifdim\wd0>\linewidth +% \begingroup +% \advance\linewidth by\leftmargin +% \advance\linewidth by\rightmargin +% \edef\x{\endgroup +% \def\noexpand\lw{\the\linewidth}^^A +% }\x +% \def\lwbox{^^A +% \leavevmode +% \hbox to \linewidth{^^A +% \kern-\leftmargin\relax +% \hss +% \usebox0 +% \hss +% \kern-\rightmargin\relax +% }^^A +% }^^A +% \ifdim\wd0>\lw +% \sbox0{\small\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\footnotesize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\scriptsize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\tiny\t}^^A +% \ifdim\wd0>\linewidth +% \lwbox +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \end{quote} +% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's +% TDS installing feature, then some files can already be in the right +% place, see the documentation of \docstrip. +% +% \subsection{Refresh file name databases} +% +% If your \TeX~distribution +% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh +% these. For example, \teTeX\ users run \verb|texhash| or +% \verb|mktexlsr|. +% +% \subsection{Some details for the interested} +% +% \paragraph{Attached source.} +% +% The PDF documentation on CTAN also includes the +% \xfile{.dtx} source file. It can be extracted by +% AcrobatReader 6 or higher. Another option is \textsf{pdftk}, +% e.g. unpack the file into the current directory: +% \begin{quote} +% \verb|pdftk bigintcalc.pdf unpack_files output .| +% \end{quote} +% +% \paragraph{Unpacking with \LaTeX.} +% The \xfile{.dtx} chooses its action depending on the format: +% \begin{description} +% \item[\plainTeX:] Run \docstrip\ and extract the files. +% \item[\LaTeX:] Generate the documentation. +% \end{description} +% If you insist on using \LaTeX\ for \docstrip\ (really, +% \docstrip\ does not need \LaTeX), then inform the autodetect routine +% about your intention: +% \begin{quote} +% \verb|latex \let\install=y\input{bigintcalc.dtx}| +% \end{quote} +% Do not forget to quote the argument according to the demands +% of your shell. +% +% \paragraph{Generating the documentation.} +% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate +% the documentation. The process can be configured by the +% configuration file \xfile{ltxdoc.cfg}. For instance, put this +% line into this file, if you want to have A4 as paper format: +% \begin{quote} +% \verb|\PassOptionsToClass{a4paper}{article}| +% \end{quote} +% An example follows how to generate the +% documentation with pdf\LaTeX: +% \begin{quote} +%\begin{verbatim} +%pdflatex bigintcalc.dtx +%makeindex -s gind.ist bigintcalc.idx +%pdflatex bigintcalc.dtx +%makeindex -s gind.ist bigintcalc.idx +%pdflatex bigintcalc.dtx +%\end{verbatim} +% \end{quote} +% +% \begin{History} +% \begin{Version}{2007/09/27 v1.0} +% \item +% First version. +% \end{Version} +% \end{History} +% +% \PrintIndex +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/oberdiek/bitset.dtx b/Master/texmf-dist/source/latex/oberdiek/bitset.dtx new file mode 100644 index 00000000000..d9fc8439905 --- /dev/null +++ b/Master/texmf-dist/source/latex/oberdiek/bitset.dtx @@ -0,0 +1,4073 @@ +% \iffalse meta-comment +% +% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 of this license or (at your option) any later +% version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status "maintained". +% +% This Current Maintainer of this work is Heiko Oberdiek. +% +% This work consists of the main source file bitset.dtx +% and the derived files +% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, +% bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. +% +% Distribution: +% CTAN:macros/latex/contrib/oberdiek/bitset.dtx +% CTAN:macros/latex/contrib/oberdiek/bitset.pdf +% +% Unpacking: +% (a) If bitset.ins is present: +% tex bitset.ins +% (b) Without bitset.ins: +% tex bitset.dtx +% (c) If you insist on using LaTeX +% latex \let\install=y\input{bitset.dtx} +% (quote the arguments according to the demands of your shell) +% +% Documentation: +% (a) If bitset.drv is present: +% latex bitset.drv +% (b) Without bitset.drv: +% latex bitset.dtx; ... +% The class ltxdoc loads the configuration file ltxdoc.cfg +% if available. Here you can specify further options, e.g. +% use A4 as paper format: +% \PassOptionsToClass{a4paper}{article} +% +% Programm calls to get the documentation (example): +% pdflatex bitset.dtx +% makeindex -s gind.ist bitset.idx +% pdflatex bitset.dtx +% makeindex -s gind.ist bitset.idx +% pdflatex bitset.dtx +% +% Installation: +% TDS:tex/generic/oberdiek/bitset.sty +% TDS:doc/latex/oberdiek/bitset.pdf +% TDS:doc/latex/oberdiek/bitset-test1.tex +% TDS:doc/latex/oberdiek/bitset-test2.tex +% TDS:doc/latex/oberdiek/bitset-test3.tex +% TDS:source/latex/oberdiek/bitset.dtx +% +%<*ignore> +\begingroup + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase 0\ifx\install y1\fi\expandafter + \ifx\csname processbatchFile\endcsname\relax\else1\fi + \ifx\fmtname\x\else 1\fi\relax +\else\csname fi\endcsname +%</ignore> +%<*install> +\input docstrip.tex +\Msg{************************************************************************} +\Msg{* Installation} +\Msg{* Package: bitset 2007/09/28 v1.0 Data type bit set (HO)} +\Msg{************************************************************************} + +\keepsilent +\askforoverwritefalse + +\preamble + +This is a generated file. + +Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in + http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. + +This work has the LPPL maintenance status "maintained". + +This Current Maintainer of this work is Heiko Oberdiek. + +This work consists of the main source file bitset.dtx +and the derived files + bitset.sty, bitset.pdf, bitset.ins, bitset.drv, + bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. + +\endpreamble + +\generate{% + \file{bitset.ins}{\from{bitset.dtx}{install}}% + \file{bitset.drv}{\from{bitset.dtx}{driver}}% + \usedir{tex/generic/oberdiek}% + \file{bitset.sty}{\from{bitset.dtx}{package}}% + \usedir{doc/latex/oberdiek}% + \file{bitset-test1.tex}{\from{bitset.dtx}{test1}}% + \file{bitset-test2.tex}{\from{bitset.dtx}{test2,etex}}% + \file{bitset-test3.tex}{\from{bitset.dtx}{test2,noetex}}% +} + +\obeyspaces +\Msg{************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file into a directory searched by TeX:} +\Msg{*} +\Msg{* bitset.sty} +\Msg{*} +\Msg{* To produce the documentation run the file `bitset.drv'} +\Msg{* through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{************************************************************************} + +\endbatchfile +%</install> +%<*ignore> +\fi +%</ignore> +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{bitset.drv}% + [2007/09/28 v1.0 Data type bit set (HO)]% +\documentclass{ltxdoc} +\usepackage{holtxdoc} +\usepackage{amstext} +\usepackage[T1]{fontenc} +\usepackage{lmodern} +\begin{document} + \DocInput{bitset.dtx}% +\end{document} +%</driver> +% \fi +% +% \CheckSum{3319} +% +% \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 +% Lower-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 +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \GetFileInfo{bitset.drv} +% +% \title{The \xpackage{bitset} package} +% \date{2007/09/28 v1.0} +% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} +% +% \maketitle +% +% \begin{abstract} +% This package defines and implements the data type bit set, +% a vector of bits. The size of the vector may grow dynamically. +% Individual bits can be manipulated. +% \end{abstract} +% +% \tableofcontents +% +% \clearpage +% \section{Documentation} +% +% \subsection{Introduction} +% +% Annotations in the PDF format know entries whose values are +% integers. This numbers are interpreted as set of flags +% specifying properties. For example, annotation dictionaries +% can have a key |/F|. The bits of its integer value +% are interpreted the following way: +% \begin{quote} +% \begin{tabular}{@{}l|l@{}} +% Bit position & Property name\\ +% \hline +% 1 & Invisible\\ +% 2 & Hidden\\ +% 3 & Print\\ +% 4 & NoZoom\\ +% 5 & NoRotate\\ +% 6 & NoView\\ +% 7 & ReadOnly\\ +% \dots & \dots +% \end{tabular} +% \end{quote} +% Now, let's see how these values are set in package \xpackage{hyperref} +% before it uses this package (before v6.77a): +%\begin{quote} +%\begin{verbatim} +%\ifFld@hidden /F 6\else /F 4\fi +%\end{verbatim} +%\end{quote} +% Where are the other flags? The following example for key |/Ff| +% in a widget annotation +% supports at least three properties: +%\begin{quote} +%\begin{verbatim} +%\ifFld@multiline +% \ifFld@readonly /Ff 4097\else /Ff 4096\fi +%\else +% \ifFld@password +% \ifFld@readonly /Ff 8193\else /Ff 8192\fi +% \else +% \ifFld@readonly /Ff 1\fi +% \fi +%\fi +%\end{verbatim} +%\end{quote} +% But you see the point. It would be a nightmare to continue +% this way in supporting the missing flag settings. This kind +% of integers may have up to 32 bits. +% +% Therefore I wanted a data structure for setting and +% clearing individual bits. Also it should provide +% an export as decimal number. The snipsets above are +% executed in expansion contexts without \TeX's stomach +% commands. It would be convenient to have an expandable +% conversion from the data structure to the integer that +% gets written to the PDF file. +% +% This package \xpackage{bitset} implements such a data +% structure. The interface is quite close to Java's +% class |BitSet| in order not to learn to many interfaces +% for the same kind of data structure. +% +% \subsection{Glossary} +% +% \begin{description} +% \item[Bit set:] +% A bit set is a vector of bits or flags. +% The vector size is unlimited and +% grows dynamically. An undefined bit set is treated as bit +% set where all bits are cleared. +% +% Bit sets are addressed by name. A name should consists of +% letters or digits. Technically it must survive \cs{csname}, +% see \LaTeX's environment names for other names with such +% a constraint. Package \xpackage{babel}'s shorthands are +% not supported due to technical reasons. Shorthand support +% would break expandable operations. +% \item[Size:] +% A size of a bit set is the number of bits in use. +% It's the number of the highest index, incremented by one. +% Sizes are in the range |0| up to |2147483647|, the highest +% number supported by \TeX. +% \item[Index:] +% Bit positions in a bit set are addressed by an index number. +% The bit vector is zero based. The first and least significant +% bit is addressed by index |0| and the highest possible bit +% by |2147483646|. +% \item[Bit:] +% A bit is enoded as |0| for cleared/disabled or |1| for set/enabled. +% \end{description} +% +% \subsection{Design principles} +% +% \begin{description} +% \item[Name conventions:] +% To avoid conflicts with existing macro names, the operations +% are prefixed by the package name. +% \item[Zero based indexes:] The first bit is addressed by zero. +% (Convention of array indexing in C, Java, \dots) +% \item[Unlimited size:] +% There is no restriction on the size of a bit set other than +% usual memory limitations. \cs{bitsetSetDec} and \cs{bitsetGetDec} +% transparently switch to package \xpackage{bigintcalc} if the numbers +% get too large for \TeX's number limit. +% \item[Expandibility:] +% Any operation that does not change the bit set is expandable. +% And all operations that extract or calculate some result +% do this in exact two expansion steps. For example, +% a macro \cs{Macro} wants a bit set as decimal number. +% But the argument must be a plain number without macros. +% Thus you could prefix \cs{bitsetGetDec} with \cs{number}. +% However this won't work for bit sets with 31 or more bits +% because of \TeX's number limit of $2^{31}-1$. +% then just hit the operator with two \cs{expandafter}: +% \begin{quote} +% |\expandafter\expandafter\expandafter|\\ +% |\Macro\bitsetGetDec{foo}| +% \end{quote} +% |\bitsetGetDec| is hit first by the third \cs{expandafter} +% and then by the second one. +% \item[Format independence:] This package is written as \LaTeX\ package, +% but it does not depend on \LaTeX. It will also work for other formats +% such as \plainTeX. +% \item[Independence from \TeX\ engines:] +% Vanilla \TeX\ is all you need. Calculations are delegated to +% packages \xpackage{intcalc} and \xpackage{bigintcalc}. +% They don't need any special features, but they will switch +% to a little more efficient implementation if features such +% as \cs{numexpr} are available. +% \item[Numeric arguments:] Anything that is accepted by +% \cs{number}. If \eTeX\ is detected, also expressions +% for \cs{numexpr} are supported. The only exception so far +% is the number for \cs{bitsetSetDec}. The number might be too +% large for \cs{number} or \cs{numexpr}. +% \item[Error messages:] +% In expandable contexts, only a limited set of \TeX\ primitive +% commands work as expected. So called stomach commands behave +% like \cs{relax} and don't get expanded or executed. +% Unhappily also the error commands belong to this category. +% The expandable operations will throw an unknown control +% sequence instead to get \TeX's and user's attention. +% The name of these control sequences starts with +% \cs{BitSetError:} with the type of error after the colon. +% \end{description} +% +% \subsection{Operator overview} +% +% \begin{minipage}{\linewidth} +% \begin{description} +% \def\It#1#2{^^A +% \item[^^A +% {#1} ^^A +% \textmd{(\hyperref[{sec:#2}]{section \ref*{sec:#2}})}^^A +% ]^^A +% \mbox{}\\^^A +% } +% \def\op#1{^^A +% \cs{bitset}\texttt{\bfseries#1}^^A +% } +% \def\M#1{\meta{#1}} +% \def\Q{\hspace*{\fill}} +% \It{Miscellaneous}{misc} +% \op{Reset}\Q \M{BitSet}\\ +% \op{Let}\Q \M{BitSet A} \M{BitSet B} +% \It{Import}{import} +% \op{SetBin}, \op{SetOct}, \op{SetHex}\Q \M{BitSet} \M{Value}\\ +% \op{SetDec}\Q \M{BitSet} \M{Value} +% \It{Export\textsuperscript{a}}{export} +% \op{GetBin}, \op{GetOct}, \op{GetHex}\Q \M{BitSet} \M{MinSize}\\ +% \op{GetDec}\Q \M{BitSet} +% \It{Logical operators}{log} +% \op{And}, \op{AndNot}\Q \M{BitSet A} \M{BitSet B}\\ +% \op{Or}, \op{Xor}\Q \M{BitSet A} \M{BitSet B} +% \It{Shifting}{shift} +% \op{ShiftLeft}, \op{ShiftRight}\Q \M{BitSet} \M{ShiftAmount}\\ +% \It{Bit manipulation}{bitman} +% \op{Clear}, \op{Set}, \op{Flip}\Q \M{BitSet} \M{Index}\\ +% \op{SetValue}\Q \M{BitSet} \M{Index} \M{Value}\\ +% \op{ClearRange}, \op{SetRange}, \op{FlipRange}\\ +% \Q \M{BitSet} \M{IndexFrom} \M{IndexTo}\\ +% \op{SetValueRange}\Q \M{BitSet} \M{IndexFrom} \M{IndexTo} +% \It{Bit retrieval\textsuperscript{a}}{bitret} +% \op{Get}\Q \M{BitSet} \M{Index}\\ +% \op{NextClearBit}, \op{NextSetBit}\Q \M{BitSet} \M{Index}\\ +% \op{GetSetBitList}\Q \M{BitSet} +% \It{Bit set properties}{prop} +% \op{Size}, \op{Cardinality}\Q \M{BitSet} +% \It{Queries\textsuperscript{b}}{query} +% \op{IsDefined}, \op{IsEmpty}\Q \M{BitSet} \M{Then} \M{Else}\\ +% \op{Equals}, \op{Intersects}\Q \M{BitSet A} \M{BitSet B} \M{Then} \M{Else}\\ +% \op{Query}\Q \M{BitSet} \M{Index} \M{Then} \M{Else} +% \end{description} +% \footnotetext[1]{Macros are expandable, full expansion by two steps.} +% \footnotetext[2]{Macros are expandable.} +% \end{minipage} +% +% \subsection{Package loading} +% +% The package can be used as normal \LaTeX\ package: +%\begin{quote} +%|\usepackage{bitset}| +%\end{quote} +% Also \plainTeX\ is supported: +%\begin{quote} +%|\input bitset.sty\relax| +%\end{quote} +% +% \subsection{Operators} +% +% The following macros work on and with bit sets. +% A bit set \meta{BitSet} is represented by a name. +% The should consist of letters and digits. Technically +% it must survive \cs{csname}. It is the same constraint +% that must be satisfied by label or environment names +% in \LaTeX. +% +% However active characters that are shorthands +% of package \xpackage{babel} are not supported. +% Support for shorthands works by an assignment. +% But many operators +% such as \cs{bitsetGetDec} must be usable in expandable +% contexts. There assignments will not be executed in the +% best case or they will cause errors. +% +% The bits in a bit set are addressed by non-negative +% integers starting from zero. Thus negative index +% numbers cause an error message. Because index numbers +% are \TeX\ numbers. The largest index is 2147483647. +% But in practice memory limits and patience limits +% will be very likely reached much before. +% +% \subsubsection{Miscellaneous}\label{sec:misc} +% +% There isn't a separate operation for bit set creation. +% For simplicity an undefined bit set is treated as bit set +% with all bits cleared. +% +% \begin{declcs}{bitsetReset} \M{BitSet} +% \end{declcs} +% Macro \cs{bitsetReset} clears all bits. The result is an +% empty bit set. It may also be used as replacement for +% an operation ``new'', because an undefined bit set is defined +% afterwards. +% +% \begin{declcs}{bitsetLet} \M{BitSet A} \M{BitSet B} +% \end{declcs} +% Macro \cs{bitsetLet} performs a simple assignment similar +% to \TeX's \cs{let}. After the operation \meta{BitSet A} has +% the same value as \meta{BitSet B}. If \meta{BitSet B} is +% undefined, then \meta{BitSet A} will be the empty bit set. +% +% Note: If \meta{BitSet A} exists, it will be overwritten. +% +% \subsubsection{Import}\label{sec:import} +% +% \begin{declcs}{bitsetSetBin} \M{BitSet} \M{BinaryNumber}\\ +% \cs{bitsetSetOct} \M{BitSet} \M{OctalNumber}\\ +% \cs{bitsetSetHex} \M{BitSet} \M{HexadecimalNumber} +% \end{declcs} +% The numbers are interpreted as bit vectors and the flags in +% the bit \meta{BitSet} set are set accordingly. +% These numeric arguments are the only arguments where +% spaces are allowed. Then the numbers are easier to read. +% +% \begin{declcs}{bitsetSetDec} \M{BitSet} \M{DecimalNumber} +% \end{declcs} +% Macro \cs{bitsetSetDec} uses \meta{DecimalNumber} to +% set the bit set \meta{BitSet}. +% The numeric argument must expand +% to a plain number consisting of decimal digits without +% command tokens or spaces. Internally this argument is +% expanded only. It cannot be passed to \cs{number} or +% \cs{numexpr}, because the number may be too large for them. +% However \cs{number} or |\the\numexpr| may be used +% explicitely. This also helps for unexpandable number +% command tokens or registers (\cs{z@}, \cs{@ne}, \cs{count@}, \dots). +% Also \LaTeX'\ \cs{value} needs prefixing: +% \begin{quote} +% |\bitsetSetDec{foo}{\number\value{bar}}| +% \end{quote} +% +% \subsubsection{Export}\label{sec:export} +% +% \begin{declcs}{bitsetGetBin} \M{BitSet} \M{MinSize}\\ +% \cs{bitsetGetOct} \M{BitSet} \M{MinSize}\\ +% \cs{bitsetGetHex} \M{BitSet} \M{MinSize} +% \end{declcs} +% These macros returns the bit set as binary, octal or hexadecimal +% number. If the bit size is smaller than \meta{MinSize} the gap is +% filled with leading zeros. +% Example: +% \begin{quote} +% |\bitsetReset{abc}|\\ +% |\bitsetSet{abc}{2}|\\ +% |\bitsetGetBin{abc}{8}| $\rightarrow$ |00000100|\\ +% |\bitsetSet{abc}{5}\bitsetSet{abc}{7}|\\ +% |\bitsetGetHex{abc}{16}| $\rightarrow$ |00A2| +% \end{quote} +% Macro \cs{bitsetGetHex} uses the uppercase letters |A| to |F|. +% The catcode of the letters is one of 11 (letter) or 12 (other). +% +% \begin{declcs}{bitsetGetDec} \M{BitSet} +% \end{declcs} +% Macro \cs{bitsetGetDec} returns the bit set \meta{BitSet} as +% decimal number. The returned number can be larger than +% \TeX's number limit of $2^{31}-1$. +% +% \subsubsection{Logical operators}\label{sec:log} +% +% \begin{declcs}{bitsetAnd} \M{BitSet A} \M{BitSet B} +% \end{declcs} +% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} +% \mathbin{\text{and}} B \qquad (\forall\, \text{bits})$ +% +% \begin{declcs}{bitsetAndNot} \M{BitSet A} \M{BitSet B} +% \end{declcs} +% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} +% \mathbin{\text{and}} (\text{not}\,B) \qquad (\forall\, \text{bits})$ +% +% \begin{declcs}{bitsetOr} \M{BitSet A} \M{BitSet B} +% \end{declcs} +% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} +% \mathbin{\text{or}} B \qquad (\forall\, \text{bits})$ +% +% \begin{declcs}{bitsetXor} \M{BitSet A} \M{BitSet B} +% \end{declcs} +% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} +% \mathbin{\text{xor}} B \qquad (\forall\, \text{bits})$ +% +% \subsubsection{Shifting}\label{sec:shift} +% +% \begin{declcs}{bitsetShiftLeft} \M{BitSet} \M{ShiftAmount}\\ +% \cs{bitsetShiftRight} \M{BitSet} \M{ShiftAmount} +% \end{declcs} +% A left shift by one is a multiplication by two, thus left shifting +% moves the flags to higher positions. The new created low positions +% are filled by zeros. +% +% A right shift is the opposite, dividing by two, movint the bits +% to lower positions. The number will become smaller, the lowest +% bits are lost. +% +% If the \meta{ShiftAmount} is negative, it reverts the meaning of +% the shift operation. A left shift becomes a right shift. +% A \meta{ShiftAmount} of zero is ignored. +% +% \subsubsection{Bit manipulation}\label{sec:bitman} +% +% \begin{declcs}{bitsetClear} \M{BitSet} \M{Index}\\ +% \cs{bitsetSet} \M{BitSet} \M{Index}\\ +% \cs{bitsetFlip} \M{BitSet} \M{Index} +% \end{declcs} +% This macros manipulate a single bit in \meta{BitSet} addressed +% by \cs{Index}. Macro \cs{bitsetClear} disables the bit, +% \cs{bitsetSet} enables it and \cs{bitsetFlip} reverts the current +% setting of the bit. +% +% \begin{declcs}{bitsetSetValue} \M{BitSet} \M{Index} \M{Bit} +% \end{declcs} +% Macro \cs{bitsetSetValue} puts bit \meta{Bit} at position \meta{Index} +% in bit set \meta{BitSet}. \meta{Bit} must be a valid \TeX\ number +% equals to zero (disabled/cleared) or one (enabled/set). +% +% \subsubsection{Bit retrieval}\label{sec:bitret} +% +% \begin{declcs}{bitsetGet} \M{BitSet} \M{Index} +% \end{declcs} +% Macro \cs{bitsetGet} extracts the status of the bit at +% position \meta{Index} in bit set \meta{BitSet}. +% Digit |1| is returned if the bit is set/enabled. If the +% bit is cleared/disabled and in cases of an undefined bitset or +% an index number out of range the return value is |0|. +% +% \begin{declcs}{bitsetNextClearBit} \M{BitSet} \M{Index} +% \end{declcs} +% Starting at position \meta{Index} (inclusive) the bits +% are inspected. The first position without a set bit is returned. +% Possible results are decimal numbers: \meta{Index}, \meta{Index} + 1, +% \dots, ($\infty$) +% +% \begin{declcs}{bitsetNextSetBit} \M{BitSet} \M{Index} +% \end{declcs} +% Starting at position \meta{Index} (inclusive) the bits are +% inspected and the index position of the first found set bit +% is returned. If there isn't such a bit, then the result is +% |-1|. In summary possible results are decimal numbers: +% |-1|, \meta{Index}, \meta{Index} + 1, \dots, ($\infty$) +% +% \begin{declcs}{bitsetGetSetBitList} \M{BitSet} +% \end{declcs} +% Macro \cs{bitsetGetSetBitList} is an application for +% \cs{bitsetNextSetBit}. The set bits are iterated and +% returned as comma separated list of index positions +% in increasing order. The list is empty in case of +% an empty bit set. +% +% \subsubsection{Bit set properties}\label{sec:prop} +% +% \begin{declcs}{bitsetSize} \M{BitSet} +% \end{declcs} +% Macro \cs{bitsetSize} returns number of bits in use. +% It is the same as the index number of the highest set/enabled bit +% incremented by one. +% +% \begin{declcs}{bitsetCardinality} \M{BitSet} +% \end{declcs} +% Macro \cs{bitsetCardinality} counts the number of set/enabled bits. +% +% \subsubsection{Queries}\label{sec:query} +% +% Also the query procedures are expandable. They ask for a piece +% of information about a bit set and execute code depending +% on the answer. +% +% \begin{declcs}{bitsetIsDefined} \M{BitSet} \M{Then} \M{Else} +% \end{declcs} +% If the bit set with the name \meta{BitSet} exists the code +% given in \meta{Then} is executed, otherwise \meta{Else} is used. +% +% \begin{declcs}{bitsetIsEmpty} \M{BitSet} \M{Then} \M{Else} +% \end{declcs} +% If the bit set \meta{BitSet} exists and at least one bit +% is set/enabled, the code in \meta{Then} is executed, +% \meta{Else} otherwise. +% +% \begin{declcs}{bitsetEquals} \M{BitSet A} \M{BitSet B} \M{Then} \M{Else} +% \end{declcs} +% Both bit sets are equal if and only if either both are undefined +% or both are defined and represents the same bit values at the +% same positions. Thus this definition is reflexive, symmeric, +% and transitive, enough for an equivalent relation. +% +% \begin{declcs}{bitsetIntersects} \M{BitSet A} \M{BitSet B} \M{Then} \M{Else} +% \end{declcs} +% If and only if \meta{BitSet A} and \meta{BitSet B} have +% at least one bit at the same position that is set, then +% code part \meta{Then} is executed. +% +% \begin{declcs}{bitsetQuery} \M{BitSet} \M{Index} \M{Then} \M{Else} +% \end{declcs} +% It's just a wrapper for \cs{bitsetGet}. If the bit at position +% \meta{Index} is enabled, code \meta{Then} is called. +% +% \StopEventually{ +% } +% +% \section{Implementation} +% +% The internal format of a bit set is quite simple, a sequence +% of digits |0| and |1|. The least significant bit is left. +% A bit set without any flag set is encoded by |0|. Also +% undefined bit sets are treated that way. After the +% highest bit that is set there are no further zeroes. +% A regular expression of valid bit sets values: +% \begin{quote} +% |0|\string||[01]*1| +% \end{quote} +% +% \begin{macrocode} +%<*package> +% \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@bitset.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{bitset}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +% \end{macrocode} +% Package identification: +% \begin{macrocode} +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@bitset.sty\endcsname +\ProvidesPackage{bitset}% + [2007/09/28 v1.0 Data type bit set (HO)] +% \end{macrocode} +% +% \subsection{Catcodes} +% +% \begin{macrocode} +\expandafter\edef\csname BitSet@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\BitSet@AtEnd{% + \BitSet@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{11}% : (letter!) +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{63}{14}% ? (comment!) +\TMP@EnsureCode{96}{12}% ` +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname BitSet@TestMode\endcsname\relax +\else + \catcode63=9 % ? (ignore) +\fi +? \let\BitSet@@TestMode\BitSet@TestMode +% \end{macrocode} +% +% \subsection{Package loading} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input infwarerr.sty\relax + \input intcalc.sty\relax + \input bigintcalc.sty\relax +\else + \RequirePackage{infwarerr}[2007/09/09]% + \RequirePackage{intcalc}[2007/09/27]% + \RequirePackage{bigintcalc}[2007/09/27]% +\fi +% \end{macrocode} +% +% \subsection{Help macros} +% +% \subsubsection{Number constant} +% +% \begin{macro}{\BitSet@MaxSize} +% \begin{macrocode} +\def\BitSet@MaxSize{2147483647}% +% \end{macrocode} +% \end{macro} +% +% \subsubsection{General basic macros} +% +% \begin{macro}{\BitSet@Empty} +% \begin{macrocode} +\def\BitSet@Empty{} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@FirstOfOne} +% \begin{macrocode} +\def\BitSet@FirstOfOne#1{#1} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Gobble} +% \begin{macrocode} +\def\BitSet@Gobble#1{} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@FirstOfTwo} +% \begin{macrocode} +\def\BitSet@FirstOfTwo#1#2{#1} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SecondOfTwo} +% \begin{macrocode} +\def\BitSet@SecondOfTwo#1#2{#2} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@Space} +% \begin{macrocode} +\def\BitSet@Space{ } +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@ZapSpace} +% \begin{macrocode} +\def\BitSet@ZapSpace#1 #2{% + #1% + \ifx\BitSet@Empty#2% + \else + \expandafter\BitSet@ZapSpace + \fi + #2% +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Tail recursion} +% +% \begin{macro}{\BitSet@Fi} +% \begin{macrocode} +\let\BitSet@Fi\fi +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@AfterFi} +% \begin{macrocode} +\def\BitSet@AfterFi#1#2\BitSet@Fi{\fi#1} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@AfterFiFi} +% \begin{macrocode} +\def\BitSet@AfterFiFi#1#2\BitSet@Fi{\fi\fi#1}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@AfterFiFiFi} +% \begin{macrocode} +\def\BitSet@AfterFiFiFi#1#2\BitSet@Fi{\fi\fi\fi#1}% +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Check macros} +% +% \begin{macro}{\BitSet@IfUndefined} +% \begin{macrocode} +\def\BitSet@IfUndefined#1{% + \expandafter\ifx\csname BS@#1\endcsname\relax + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@CheckIndex} +% |#1|: continuation code\\ +% |#2|: BitSet\\ +% |#3|: Index +% \begin{macrocode} +\def\BitSet@CheckIndex#1#2#3{% + \BitSet@IfUndefined{#2}{\bitsetReset{#2}}{}% + \expandafter\expandafter\expandafter\BitSet@@CheckIndex + \intcalcNum{#3}!% + {#2}{#1}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@CheckIndex} +% |#1|: plain Index\\ +% |#2|: BitSet\\ +% |#3|: continuation code +% \begin{macrocode} +\def\BitSet@@CheckIndex#1!#2#3{% + \ifnum#1<0 % + \BitSet@AfterFi{% + \@PackageError{bitset}{% + Invalid negative index (#1)% + }\@ehc + }% + \else + \BitSet@AfterFi{% + #3{#2}{#1}% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Miscellaneous}\label{src:misc} +% +% \begin{macro}{\bitsetReset} +% \begin{macrocode} +\def\bitsetReset#1{% + \expandafter\def\csname BS@#1\endcsname{0}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetLet} +% \begin{macrocode} +\def\bitsetLet#1#2{% + \BitSet@IfUndefined{#2}{% + \bitsetReset{#1}% + }{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Import}\label{src:import} +% +% \subsubsection{From binary number} +% +% \begin{macro}{\bitsetSetBin} +% \begin{macrocode} +\def\bitsetSetBin#1#2{% + \edef\BitSet@Temp{#2}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \else + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@Reverse\BitSet@Temp!% + }% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@KillZeros} +% \begin{macrocode} +\def\BitSet@KillZeros#1{% + \ifx#10% + \expandafter\BitSet@KillZeros + \else + #1% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Reverse} +% \begin{macrocode} +\def\BitSet@Reverse#1#2!{% + \ifx\\#2\\% + #1% + \else + \BitSet@AfterFi{% + \BitSet@Reverse#2!#1% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{From octal/hex number} +% +% \begin{macro}{\bitsetSetOct} +% \begin{macrocode} +\def\bitsetSetOct{% + \BitSet@SetOctHex\BitSet@FromFirstOct +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetSetHex} +% \begin{macrocode} +\def\bitsetSetHex{% + \BitSet@SetOctHex\BitSet@FromFirstHex +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SetOctHex} +% \begin{macrocode} +\def\BitSet@SetOctHex#1#2#3{% + \edef\BitSet@Temp{#3}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#2\endcsname\BitSet@Zero + \else + \edef\BitSet@Temp{% + \expandafter#1\BitSet@Temp!% + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#2\endcsname\BitSet@Zero + \else + \expandafter\edef\csname BS@#2\endcsname{% + \expandafter\BitSet@Reverse\BitSet@Temp!% + }% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@FromFirstOct} +% \begin{macrocode} +\def\BitSet@FromFirstOct#1{% + \ifx#1!% + \else + \ifcase#1 \BitSet@AfterFiFi\BitSet@FromFirstOct + \or 1% + \or 10% + \or 11% + \or 100% + \or 101% + \or 110% + \or 111% + \else \BitSetError:WrongOctalDigit% + \fi + \expandafter\BitSet@FromOct + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@FromOct} +% \begin{macrocode} +\def\BitSet@FromOct#1{% + \ifx#1!% + \else + \ifcase#1 000% + \or 001% + \or 010% + \or 011% + \or 100% + \or 101% + \or 110% + \or 111% + \else \BitSetError:WrongOctalDigit% + \fi + \expandafter\BitSet@FromOct + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@FromFirstHex} +% \begin{macrocode} +\def\BitSet@FromFirstHex#1{% + \ifx#1!% + \else + \ifx#10% + \BitSet@AfterFiFi\BitSet@FromFirstHex + \fi + \expandafter\ifx\csname BitSet@Hex#1\endcsname\relax + \BitSetError:InvalidHexDigit% + \else + \expandafter\expandafter\expandafter\BitSet@KillZeros + \csname BitSet@Hex#1\endcsname + \fi + \expandafter\BitSet@FromHex + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@FromHex} +% \begin{macrocode} +\def\BitSet@FromHex#1{% + \ifx#1!% + \else + \expandafter\ifx\csname BitSet@Hex#1\endcsname\relax + \BitSetError:InvalidHexDigit% + \else + \csname BitSet@Hex#1\endcsname + \fi + \expandafter\BitSet@FromHex + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Hex[0..F]} +% \begin{macrocode} +\def\BitSet@Temp#1{% + \expandafter\def\csname BitSet@Hex#1\endcsname +} +\BitSet@Temp 0{0000}% +\BitSet@Temp 1{0001}% +\BitSet@Temp 2{0010}% +\BitSet@Temp 3{0011}% +\BitSet@Temp 4{0100}% +\BitSet@Temp 5{0101}% +\BitSet@Temp 6{0110}% +\BitSet@Temp 7{0111}% +\BitSet@Temp 8{1000}% +\BitSet@Temp 9{1001}% +\BitSet@Temp A{1010}% +\BitSet@Temp B{1011}% +\BitSet@Temp C{1100}% +\BitSet@Temp D{1101}% +\BitSet@Temp E{1110}% +\BitSet@Temp F{1111}% +\BitSet@Temp a{1010}% +\BitSet@Temp b{1011}% +\BitSet@Temp c{1100}% +\BitSet@Temp d{1101}% +\BitSet@Temp e{1110}% +\BitSet@Temp f{1111}% +% \end{macrocode} +% \end{macro} +% +% \subsubsection{From decimal number} +% +% \begin{macro}{\bitsetSetDec} +% \begin{macrocode} +\def\bitsetSetDec#1#2{% + \edef\BitSet@Temp{#2}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \else + \ifcase\bigintcalcSgn{\BitSet@Temp} % + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \or + \ifnum\bigintcalcCmp\BitSet@Temp\BitSet@MaxSize>0 % + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@SetDecBig\BitSet@Temp!% + }% + \else + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@SetDec\BitSet@Temp!% + }% + \fi + \else + \@PackageError{bitset}{% + Bit sets cannot be negative% + }\@ehc + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SetDecBig} +% \begin{macrocode} +\def\BitSet@SetDecBig#1#2#3#4#5#6#7#8#9!{% + \ifx\\#9\\% + \BitSet@SetDec#1#2#3#4#5#6#7#8!% + \else + \ifcase\BigIntCalcOdd#1#2#4#5#6#7#8#9! % + 0% + \or + 1% +? \else\BitSetError:ThisCannotHappen% + \fi + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@SetDecBig + \BigIntCalcShr#1#2#3#4#5#6#7#8#9!!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SetDec} +% \begin{macrocode} +\def\BitSet@SetDec#1!{% + \ifcase#1 % + \or 1% + \else + \ifodd#1 % + 1% + \else + 0% + \fi + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@SetDec + \IntCalcShr#1!!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Export}\label{src:export} +% +% \subsubsection{To binary number} +% +% \begin{macro}{\bitsetGetBin} +% \begin{macrocode} +\def\bitsetGetBin#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BitSet@@GetBin + \intcalcNum{#2}!{#1}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetBin} +% \begin{macrocode} +\def\BitSet@@GetBin#1!#2{% + \BitSet@IfUndefined{#2}{% + \ifnum#1>1 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcDec#1!!0% + }% + \else + \BitSet@AfterFi{ 0}% + \BitSet@Fi + }{% + \expandafter\expandafter\expandafter\BitSet@NumBinRev + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!#1!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Fill} +% |#1|: number of leading digits |0|\\ +% |#2|: result +% \begin{macrocode} +\def\BitSet@Fill#1!{% + \ifnum#1>0 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcDec#1!!0% + }% + \else + \BitSet@AfterFi{ }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@NumBinRev} +% |#1|: bit counter (including |#2|)\\ +% |#2#3|: reverted number\\ +% |#4|: result\\ +% |#5|: min size +% \begin{macrocode} +\def\BitSet@NumBinRev#1!#2#3!{% + \ifx\\#3\\% + \BitSet@AfterFi{% + \BitSet@NumBinFill#1!#2% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@NumBinRev + \IntCalcInc#1!!#3!#2% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@NumBinFill} +% \begin{macrocode} +\def\BitSet@NumBinFill#1!#2!#3!{% + \ifnum#3>#1 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcSub#3!#1!!#2% + }% + \else + \BitSet@AfterFi{ #2}% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{To octal/hexadecimal number} +% +% \begin{macro}{\bitsetGetOct} +% \begin{macrocode} +\def\bitsetGetOct#1#2{% + \romannumeral0% + \bitsetIsEmpty{#1}{% + \expandafter\expandafter\expandafter\BitSet@@GetOctHex + \intcalcNum{#2}!3!230% + }{% + \expandafter\expandafter\expandafter\BitSet@@GetOct + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname00% + \BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetGetHex} +% \begin{macrocode} +\def\bitsetGetHex#1#2{% + \romannumeral0% + \bitsetIsEmpty{#1}{% + \expandafter\expandafter\expandafter\BitSet@@GetOctHex + \intcalcNum{#2}!4!340% + }{% + \expandafter\expandafter\expandafter\BitSet@@GetHex + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname000% + \BitSet@Empty\BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetOct} +% |#1|: number of digits\\ +% |#2|: result\\ +% |#3#4#5|: bits +% \begin{macrocode} +\def\BitSet@@GetOct#1!#2!#3#4#5{% + \ifx#5\BitSet@Empty + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@GetOctHex + \IntCalcDec#1!!#2!23% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@GetOct + \number\IntCalcInc#1!\expandafter\expandafter\expandafter!% + \csname BitSet@Oct#5#4#3\endcsname#2!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Oct[000..111]} +% \begin{macrocode} +\def\BitSet@Temp#1#2#3#4{% + \expandafter\def\csname BitSet@Oct#1#2#3\endcsname{#4}% +} +\BitSet@Temp0000% +\BitSet@Temp0011% +\BitSet@Temp0102% +\BitSet@Temp0113% +\BitSet@Temp1004% +\BitSet@Temp1015% +\BitSet@Temp1106% +\BitSet@Temp1117% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetHex} +% |#1|: number of digits\\ +% |#2|: result\\ +% |#3#4#5#6|: bits +% \begin{macrocode} +\def\BitSet@@GetHex#1!#2!#3#4#5#6{% + \ifx#6\BitSet@Empty + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@GetOctHex + \IntCalcDec#1!!#2!34% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@GetHex + \number\IntCalcInc#1!\expandafter\expandafter\expandafter!% + \csname BitSet@Hex#6#5#4#3\endcsname#2!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Hex[0000..1111]} +% \begin{macrocode} +\def\BitSet@Temp#1#2#3#4#5{% + \expandafter\def\csname BitSet@Hex#1#2#3#4\endcsname{#5}% +} +\BitSet@Temp00000% +\BitSet@Temp00011% +\BitSet@Temp00102% +\BitSet@Temp00113% +\BitSet@Temp01004% +\BitSet@Temp01015% +\BitSet@Temp01106% +\BitSet@Temp01117% +\BitSet@Temp10008% +\BitSet@Temp10019% +\BitSet@Temp1010A% +\BitSet@Temp1011B% +\BitSet@Temp1100C% +\BitSet@Temp1101D% +\BitSet@Temp1110E% +\BitSet@Temp1111F% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@GetOctHex} +% Leading zeros $ (|#4| - |#1| * 3 + 2)/3 $ if $ |#4| > |#1| * 3$\\ +% |#1|: digit size\\ +% |#2|: result\\ +% |#3|: bits per digit - 1\\ +% |#4|: bits per digit +% |#5|: garbage\\ +% |#6|: min size +% \begin{macrocode} +\def\BitSet@GetOctHex#1!#2!#3#4#5!#6{% + \expandafter\BitSet@@GetOctHex + \number\intcalcNum{#6}\expandafter\expandafter\expandafter!% + \IntCalcMul#1!#4!!#3#4#2% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetOctHex} +% |#1|: plain min size\\ +% |#2|: digits * (bits per digit)\\ +% |#3|: bits per digit - 1\\ +% |#4|: bits per digit +% \begin{macrocode} +\def\BitSet@@GetOctHex#1!#2!#3#4{% + \ifnum#1>#2 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\BitSet@Fill + \expandafter\IntCalcDiv\number + \expandafter\expandafter\expandafter\IntCalcAdd + \IntCalcSub#1!#2!!#3!!#4!!% + }% + \else + \BitSet@AfterFi{ }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{To decimal number} +% +% \begin{macro}{\bitsetGetDec} +% \begin{macrocode} +\def\bitsetGetDec#1{% + \romannumeral0% + \BitSet@IfUndefined{#1}{ 0}{% + \expandafter\expandafter\expandafter\BitSet@GetDec + \csname BS@#1\endcsname!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@GetDec} +% \begin{macrocode} +\def\BitSet@GetDec#1#2!{% + \ifx\\#2\\% + \BitSet@AfterFi{ #1}% + \else + \BitSet@AfterFi{% + \BitSet@@GetDec2!#1!#2!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetDec} +% |#1|: power of two\\ +% |#2|: result\\ +% |#3#4|: number +% \begin{macrocode} +\def\BitSet@@GetDec#1!#2!#3#4!{% + \ifx\\#4\\% + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Space + \IntCalcAdd#1!#2!% + }% + \else + \BitSet@AfterFiFi{ #2}% + \fi + \else + \ifx#31% + \BitSet@AfterFiFi{% + \csname BitSet@N#1% + \expandafter\expandafter\expandafter\endcsname + \IntCalcAdd#1!#2!!#4!% + }% + \else + \BitSet@AfterFiFi{% + \csname BitSet@N#1\endcsname#2!#4!% + }% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@N[1,2,4,...]} +% \begin{macrocode} +\def\BitSet@Temp#1#2{% + \expandafter\def\csname BitSet@N#1\endcsname{% + \BitSet@@GetDec#2!% + }% +} +\BitSet@Temp{1}{2} +\BitSet@Temp{2}{4} +\BitSet@Temp{4}{8} +\BitSet@Temp{8}{16} +\BitSet@Temp{16}{32} +\BitSet@Temp{32}{64} +\BitSet@Temp{64}{128} +\BitSet@Temp{128}{256} +\BitSet@Temp{256}{512} +\BitSet@Temp{512}{1024} +\BitSet@Temp{1024}{2048} +\BitSet@Temp{2048}{4096} +\BitSet@Temp{4096}{8192} +\BitSet@Temp{8192}{16384} +\BitSet@Temp{16384}{32768} +\BitSet@Temp{32768}{65536} +\BitSet@Temp{65536}{131072} +\BitSet@Temp{131072}{262144} +\BitSet@Temp{262144}{524288} +\BitSet@Temp{524288}{1048576} +\BitSet@Temp{1048576}{2097152} +\BitSet@Temp{2097152}{4194304} +\BitSet@Temp{4194304}{8388608} +\BitSet@Temp{8388608}{16777216} +\BitSet@Temp{16777216}{33554432} +\BitSet@Temp{33554432}{67108864} +\BitSet@Temp{67108864}{134217728} +\BitSet@Temp{134217728}{268435456} +\BitSet@Temp{268435456}{536870912} +\BitSet@Temp{536870912}{1073741824} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@N1073741824} +% \begin{macrocode} +\expandafter\def\csname BitSet@N1073741824\endcsname{% + \BitSet@GetDecBig2147483648!% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@GetDecBig} +% |#1|: current power of two\\ +% |#2|: result\\ +% |#3#4|: number +% \begin{macrocode} +\def\BitSet@GetDecBig#1!#2!#3#4!{% + \ifx\\#4\\% + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Space + \BigIntCalcAdd#1!#2!% + }% + \else + \BitSet@AfterFiFi{ #2}% + \fi + \else + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@GetDecBig + \BigIntCalcAdd#1!#2!!#1!#4!% + }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@GetDecBig + \BigIntCalcShl#1!!#2!#4!% + }% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@GetDecBig} +% |#1|: result\\ +% |#2|: power of two\\ +% |#3#4|: number +% \begin{macrocode} +\def\BitSet@@GetDecBig#1!#2!{% + \expandafter\expandafter\expandafter\BitSet@GetDecBig + \BigIntCalcShl#2!!#1!% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Logical operators}\label{src:log} +% +% \subsubsection{\cs{bitsetAnd}} +% +% \begin{macro}{\bitsetAnd} +% Decision table for \cs{bitsetAnd}: +% \begin{quote} +% \begin{tabular}{l|l|l|l|} +% & undef(B) & empty(B) & cardinality(B)$>$0\\ +% \hline +% undef(A) & A := empty & A := empty & A := empty\\ +% \hline +% empty(A) & & &\\ +% \hline +% cardinality(A)$>$0 & A := empty & A := empty & A \&= B\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\bitsetAnd#1#2{% + \bitsetIsEmpty{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#2}{% + \bitsetReset{#1}% + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@And + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@And} +% \begin{macrocode} +\def\BitSet@And#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifnum#1#3=11 #51\fi + \else + \ifx\\#4\\% + \ifnum#1#3=11 #51\fi + \else + \ifnum#1#3=11 % + #51% + \BitSet@AfterFiFiFi{% + \BitSet@And#2!#4!!% + }% + \else + \BitSet@AfterFiFiFi{% + \BitSet@And#2!#4!#50!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetAndNot}} +% +% \begin{macro}{\bitsetAndNot} +% Decision table for \cs{bitsetAndNot}: +% \begin{quote} +% \begin{tabular}{l|l|l|l|} +% & undef(B) & empty(B) & cardinality(B)$>$0\\ +% \hline +% undef(A) & A := empty & A := empty & A := empty\\ +% \hline +% empty(A) & & &\\ +% \hline +% cardinality(A)$>$0 & & & A \&= !B\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\bitsetAndNot#1#2{% + \bitsetIsEmpty{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#2}{% + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@AndNot + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@AndNot} +% \begin{macrocode} +\def\BitSet@AndNot#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifnum#1#3=10 #51\fi + \else + \ifx\\#4\\% + #5% + \ifnum#1#3=10 1\else 0\fi + #2% + \else + \ifnum#1#3=10 % + #51% + \BitSet@AfterFiFiFi{% + \BitSet@AndNot#2!#4!!% + }% + \else + \BitSet@AfterFiFiFi{% + \BitSet@AndNot#2!#4!#50!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetOr}} +% +% \begin{macro}{\bitsetOr} +% Decision table for \cs{bitsetOr}: +% \begin{quote} +% \begin{tabular}{l|l|l|l|} +% & undef(B) & empty(B) & cardinality(B)$>$0\\ +% \hline +% undef(A) & A := empty & A := empty & A := B\\ +% \hline +% empty(A) & & & A := B\\ +% \hline +% cardinality(A)$>$0 & & & A \string|= B\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\bitsetOr#1#2{% + \bitsetIsEmpty{#2}{% + \BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% + }{% + \bitsetIsEmpty{#1}{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Or + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!% + }% + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Or} +% \begin{macrocode} +\def\BitSet@Or#1#2!#3#4!{% + \ifnum#1#3>0 1\else 0\fi + \ifx\\#2\\% + #4% + \else + \ifx\\#4\\% + #2% + \else + \BitSet@AfterFiFi{% + \BitSet@Or#2!#4!% + }% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetXor}} +% +% \begin{macro}{\bitsetXor} +% Decision table for \cs{bitsetXor}: +% \begin{quote} +% \begin{tabular}{l|l|l|l|} +% & undef(B) & empty(B) & cardinality(B)$>$0\\ +% \hline +% undef(A) & A := empty & A := empty & A := B\\ +% \hline +% empty(A) & & & A := B\\ +% \hline +% cardinality(A)$>$0 & & & A \string^= B\\ +% \hline +% \end{tabular} +% \end{quote} +% \begin{macrocode} +\def\bitsetXor#1#2{% + \bitsetIsEmpty{#2}{% + \BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% + }{% + \bitsetIsEmpty{#1}{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Xor + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Xor} +% \begin{macrocode} +\def\BitSet@Xor#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifx#1#3% + \ifx\\#4\\% + \else + #50#4% + \fi + \else + #51#4% + \fi + \else + \ifx\\#4\\% + #5% + \ifx#1#30\else 1\fi + #2% + \else + \ifx#1#3% + \BitSet@AfterFiFiFi{% + \BitSet@Xor#2!#4!#50!% + }% + \else + #51% + \BitSet@AfterFiFiFi{% + \BitSet@Xor#2!#4!!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Shifting}\label{src:shift} +% +% \subsubsection{\cs{bitsetShiftLeft}} +% +% \begin{macro}{\bitsetShiftLeft} +% \begin{macrocode} +\def\bitsetShiftLeft#1#2{% + \BitSet@IfUndefined{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#1}{% + }{% + \expandafter\expandafter\expandafter\BitSet@ShiftLeft + \intcalcNum{#2}!{#1}% + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@ShiftLeft} +% \begin{macrocode} +\def\BitSet@ShiftLeft#1!#2{% + \ifcase\intcalcSgn{#1} % + \or + \begingroup + \uccode`m=`0 % + \uppercase\expandafter{\expandafter\endgroup + \expandafter\edef\csname BS@#2\expandafter\endcsname + \expandafter{% + \romannumeral#1000\expandafter\BitSet@Space + \csname BS@#2\endcsname + }% + }% + \else + \expandafter\BitSet@ShiftRight\BitSet@Gobble#1!{#2}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetShiftRight}} +% +% \begin{macro}{\bitsetShiftRight} +% \begin{macrocode} +\def\bitsetShiftRight#1#2{% + \BitSet@IfUndefined{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#1}{% + }{% + \expandafter\expandafter\expandafter\BitSet@ShiftRight + \intcalcNum{#2}!{#1}% + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@ShiftRight} +% \begin{macrocode} +\def\BitSet@ShiftRight#1!#2{% + \ifcase\intcalcSgn{#1} % + \or + \expandafter\edef\csname BS@#2\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Kill + \csname BS@#2\expandafter\endcsname\expandafter\BitSet@Empty + \expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral#1000!% + }% + \else + \expandafter\BitSet@ShiftLeft\BitSet@Gobble#1!{#2}% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Kill} +% \begin{macrocode} +\def\BitSet@Kill#1#2=#3#4#5{% + #3#4% + \ifx#5!% + \ifx#1\BitSet@Empty + 0% + \else + #1#2% + \fi + \else + \ifx#1\BitSet@Empty + 0% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@Kill#2=% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Bit manipulation}\label{src:bitman} +% +% \begin{macro}{\bitsetClear} +% \begin{macrocode} +\def\bitsetClear{% + \BitSet@CheckIndex\BitSet@Clear +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetSet} +% \begin{macrocode} +\def\bitsetSet{% + \BitSet@CheckIndex\BitSet@Set +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetFlip} +% \begin{macrocode} +\def\bitsetFlip{% + \BitSet@CheckIndex\BitSet@Flip +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetSetValue} +% \begin{macrocode} +\def\bitsetSetValue#1#2#3{% + \expandafter\expandafter\expandafter\BitSet@SetValue + \intcalcNum{#3}!{#1}{#2}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SetValue} +% |#1|: plain value\\ +% |#2|: BitSet\\ +% |#3|: Index +% \begin{macrocode} +\def\BitSet@SetValue#1!{% + \BitSet@CheckIndex{% + \ifcase#1 % + \expandafter\BitSet@Clear + \or + \expandafter\BitSet@Set + \else + \BitSet@ErrorInvalidBitValue{#1}% + \expandafter\expandafter\expandafter\BitSet@Gobble + \expandafter\BitSet@Gobble + \fi + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@ErrorInvalidBitValue} +% |#1|: Wrong bit value +% \begin{macrocode} +\def\BitSet@ErrorInvalidBitValue#1{% + \@PackageError{bitset}{% + Invalid bit value (#1) not in range 0..1% + }\@ehc +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Clear operation} +% +% \begin{macro}{\BitSet@Clear} +% |#1|: BitSet\\ +% |#2|: plain and checked index +% \begin{macrocode} +\def\BitSet@Clear#1#2{% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@@Clear + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=\expandafter!% + \romannumeral#2000!% + }% + \expandafter\let\csname BS@#1\expandafter\endcsname + \ifx\BitSet@Temp\BitSet@Empty + \BitSet@Zero + \else + \BitSet@Temp + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Clear} +% \begin{macrocode} +\def\BitSet@@Clear#1#2=#3!#4{% + \ifx#4!% + \ifx#1\BitSet@Empty + \else + \ifx\BitSet@Empty#2% + \else + #30#2% + \fi + \fi + \else + \ifx#1\BitSet@Empty + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \ifx#10% + \BitSet@AfterFiFiFi{% + \BitSet@@Clear#2=#30!% + }% + \else + #31% + \BitSet@AfterFiFiFi{% + \BitSet@@Clear#2=!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Set operation} +% +% \begin{macro}{\BitSet@Set} +% |#1|: BitSet\\ +% |#2|: plain and checked Index +% \begin{macrocode} +\def\BitSet@Set#1#2{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@@Set + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral#2000!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Set} +% \begin{macrocode} +\def\BitSet@@Set#1#2=#3#4#5{% + #3#4% + \ifx#5!% + 1#2% + \else + \ifx#1\BitSet@Empty + 0% + \BitSet@AfterFiFi\BitSet@@@Set + \else + #1% + \BitSet@@Set#2=% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@@Set} +% \begin{macrocode} +\def\BitSet@@@Set#1{% + \ifx#1!% + 1% + \else + 0% + \expandafter\BitSet@@@Set + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Flip operation} +% +% \begin{macro}{\BitSet@Flip} +% |#1|: BitSet\\ +% |#2|: plain and checked Index +% \begin{macrocode} +\def\BitSet@Flip#1#2{% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@@Flip + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=\expandafter!% + \romannumeral#2000!% + }% + \expandafter\let\csname BS@#1\expandafter\endcsname + \ifx\BitSet@Temp\BitSet@Empty + \BitSet@Zero + \else + \BitSet@Temp + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Flip} +% \begin{macrocode} +\def\BitSet@@Flip#1#2=#3!#4{% + \ifx#4!% + \ifx#11% + \ifx\BitSet@Empty#2% + \else + #30#2% + \fi + \else + #31#2% + \fi + \else + \ifx#1\BitSet@Empty + #30% + \BitSet@AfterFiFi\BitSet@@@Set + \else + \ifx#10% + \BitSet@AfterFiFiFi{% + \BitSet@@Flip#2=#30!% + }% + \else + #31% + \BitSet@AfterFiFiFi{% + \BitSet@@Flip#2=!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Range operators} +% +% \begin{macro}{\bitsetClearRange} +% \begin{macrocode} +\def\bitsetClearRange{% + \BitSet@Range\BitSet@Clear +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetSetRange} +% \begin{macrocode} +\def\bitsetSetRange{% + \BitSet@Range\BitSet@Set +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetFlipRange} +% \begin{macrocode} +\def\bitsetFlipRange{% + \BitSet@Range\BitSet@Flip +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetSetValueRange} +% \begin{macrocode} +\def\bitsetSetValueRange#1#2#3#4{% + \expandafter\expandafter\expandafter\BitSet@SetValueRange + \intcalcNum{#4}!{#1}{#2}{#3}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SetValueRange} +% \begin{macrocode} +\def\BitSet@SetValueRange#1!#2#3#4{% + \ifcase#1 % + \BitSet@Range\BitSet@Clear{#2}{#3}{#4}% + \or + \BitSet@Range\BitSet@Set{#2}{#3}{#4}% + \else + \BitSet@ErrorInvalidBitValue{#1}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@Range} +% |#1|: clear/set/flip macro\\ +% |#2|: BitSet\\ +% |#3|: Index from\\ +% |#4|: Index to +% \begin{macrocode} +\def\BitSet@Range#1#2#3#4{% + \edef\BitSet@Temp{% + \noexpand\BitSet@@Range\noexpand#1{#2}% + \intcalcNum{#3}!\intcalcNum{#4}!% + }% + \BitSet@Temp +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Range} +% |#1|: clear/set/flip macro\\ +% |#2|: BitSet\\ +% |#3|: Index from\\ +% |#4|: Index to +% \begin{macrocode} +\def\BitSet@@Range#1#2#3!#4!{% + \ifnum#3<0 % + \BitSet@NegativeIndex#1{#2}#3!#4!0!#4!% + \else + \ifnum#4<0 % + \BitSet@NegativeIndex#1{#2}#3!#4!#3!0!% + \else + \ifcase\intcalcCmp{#3}{#4} % + \or + \@PackageError{bitset}{% + Wrong index numbers in range [#3..#4]\MessageBreak% hash-ok + for clear/set/flip on bit set `#2'.\MessageBreak + The lower index exceeds the upper index.\MessageBreak + Canceling the operation as error recovery% + }\@ehc + \else + \BitSet@@@Range#3!#4!#1{#2}% + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@NegativeIndex} +% \begin{macrocode} +\def\BitSet@NegativeIndex#1#2#3!#4!#5!#6!{% + \@PackageError{bitset}{% + Negative index in range [#3..#4]\MessageBreak % hash-ok + for \string\bitset + \ifx#1\BitSet@Clear + Clear% + \else + \ifx#1\BitSet@Set + Set% + \else + Flip% + \fi + \fi + Range on bit set `#2'.\MessageBreak + Using [#5..#6] as error recovery% hash-ok + }\@ehc + \BitSet@@Range#1{#2}#5!#6!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Range} +% \begin{macrocode} +\def\BitSet@@@Range#1!#2!#3#4{% + \ifnum#1<#2 % + #3{#4}{#1}% + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@@Range + \IntCalcInc#1!!#2!#3{#4}% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Bit retrieval}\label{src:bitret} +% +% \subsubsection{\cs{bitsetGet}} +% +% \begin{macro}{\bitsetGet} +% \begin{macrocode} +\def\bitsetGet#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@Get + \intcalcNum{#2}!{#1}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Get} +% |#1|: plain index\\ +% |#2|: BitSet +% \begin{macrocode} +\def\BitSet@Get#1!#2{% + \ifnum#1<0 % + \BitSet@AfterFi{% + 0 \BitSetError:NegativeIndex% + }% + \else + \BitSet@IfUndefined{#2}{0}{% + \expandafter\expandafter\expandafter\BitSet@@Get + \csname BS@#2\expandafter\endcsname + \expandafter!\expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral\intcalcNum{#1}000!% + }% + \expandafter\BitSet@Space + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@Get} +% \begin{macrocode} +\def\BitSet@@Get#1#2=#3#4#5{% + #3#4% + \ifx#5!% + \ifx#1!% + 0% + \else + #1% + \fi + \else + \ifx#1!% + 0% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@@Get#2=% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetNextClearBit}, \cs{bitsetNextSetBit}} +% +% \begin{macro}{\bitsetNextClearBit} +% \begin{macrocode} +\def\bitsetNextClearBit#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@NextClearBit + \intcalcNum{#2}!{#1} % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@NextClearBit} +% |#1|: Index\\ +% |#2|: BitSet +% \begin{macrocode} +\def\BitSet@NextClearBit#1!#2{% + \ifnum#1<0 % + \BitSet@NextClearBit0!{#2}% + \BitSet@AfterFi{% + \expandafter\BitSet@Space + \expandafter\BitSetError:NegativeIndex\romannumeral0% + }% + \else + \bitsetIsEmpty{#2}{#1}{% + \expandafter\BitSet@Skip + \number#1\expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!!!!!!!!=% + {\BitSet@@NextClearBit#1!}% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@NextClearBit} +% |#1|: index for next bit in |#2|\\ +% |#2|: next bit +% \begin{macrocode} +\def\BitSet@@NextClearBit#1!#2{% + \ifx#2!% + #1% + \else + \ifx#20% + #1% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@NextClearBit + \IntCalcInc#1!!% + }% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetNextSetBit} +% \begin{macrocode} +\def\bitsetNextSetBit#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@NextSetBit + \intcalcNum{#2}!{#1} % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@NextSetBit} +% |#1|: Index\\ +% |#2|: BitSet +% \begin{macrocode} +\def\BitSet@NextSetBit#1!#2{% + \ifnum#1<0 % + \BitSet@NextSetBit0!{#2}% + \BitSet@AfterFi{% + \expandafter\BitSet@Space + \expandafter\BitSetError:NegativeIndex\romannumeral0% + }% + \else + \bitsetIsEmpty{#2}{-1}{% + \expandafter\BitSet@Skip + \number#1\expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!!!!!!!!=% + {\BitSet@@NextSetBit#1!}% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@@NextSetBit} +% |#1|: index for next bit in |#2|\\ +% |#2|: next bit +% \begin{macrocode} +\def\BitSet@@NextSetBit#1!#2{% + \ifx#2!% + -1% + \else + \ifx#21% + #1% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@NextSetBit + \IntCalcInc#1!!% + }% + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Cleanup} +% \begin{macrocode} +\def\BitSet@Cleanup#1!{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\BitSet@Skip} +% |#1|: number of bits to skip\\ +% |#2|: bits\\ +% |#3|: continuation code +% \begin{macrocode} +\def\BitSet@Skip#1!#2{% + \ifx#2!% + \BitSet@AfterFi{% + \BitSet@SkipContinue% + }% + \else + \ifcase#1 % + \BitSet@AfterFiFi{% + \BitSet@SkipContinue#2% + }% + \or + \BitSet@AfterFiFi\BitSet@SkipContinue + \or + \BitSet@AfterFiFi{% + \expandafter\BitSet@SkipContinue\BitSet@Gobble + }% + \else + \ifnum#1>8 % + \BitSet@AfterFiFiFi{% + \expandafter\BitSet@Skip + \number\IntCalcSub#1!8!\expandafter!% + \BitSet@GobbleSeven + }% + \else + \BitSet@AfterFiFiFi{% + \expandafter\expandafter\expandafter\BitSet@Skip + \IntCalcDec#1!!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@SkipContinue} +% |#1|: remaining bits\\ +% |#2|: continuation code +% \begin{macrocode} +\def\BitSet@SkipContinue#1!#2=#3{% + #3#1!% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@GobbleSeven} +% \begin{macrocode} +\def\BitSet@GobbleSeven#1#2#3#4#5#6#7{} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{\cs{bitsetGetSetBitList}} +% +% \begin{macro}{\bitsetGetSetBitList} +% It's just a wrapper for \cs{bitsetNextSetBit}. +% \begin{macrocode} +\def\bitsetGetSetBitList#1{% + \romannumeral0% + \bitsetIsEmpty{#1}{ }{% + \expandafter\BitSet@GetSetBitList + \number\BitSet@NextSetBit0!{#1}!{#1}{}!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@GetSetBitList} +% |#1|: found index\\ +% |#2|: BitSet\\ +% |#3|: comma +% |#4|: result +% \begin{macrocode} +\def\BitSet@GetSetBitList#1!#2#3#4!{% + \ifnum#1<0 % + \BitSet@AfterFi{ #4}% + \else + \BitSet@AfterFi{% + \expandafter\BitSet@GetSetBitList\number + \expandafter\expandafter\expandafter\BitSet@NextSetBit + \IntCalcInc#1!!{#2}!{#2},#4#3#1!% + }% + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Bit set properties}\label{src:prop} +% +% \begin{macro}{\bitsetSize} +% \begin{macrocode} +\def\bitsetSize#1{% + \number + \BitSet@IfUndefined{#1}{0 }{% + \expandafter\expandafter\expandafter\BitSet@Size + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname!0!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Size} +% |#1|: counter\\ +% |#2#3|: bits\\ +% |#4|: result +% \begin{macrocode} +\def\BitSet@Size#1!#2#3!#4!{% + \ifx#21% + \ifx\\#3\\% + \BitSet@AfterFiFi{#1 }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Size + \IntCalcInc#1!!#3!#1!% + }% + \fi + \else + \ifx\\#3\\% + \BitSet@AfterFiFi{#4 }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Size + \IntCalcInc#1!!#3!#4!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetCardinality} +% \begin{macrocode} +\def\bitsetCardinality#1{% + \number + \BitSet@IfUndefined{#1}{0 }{% + \expandafter\expandafter\expandafter\BitSet@Cardinality + \expandafter\expandafter\expandafter0% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname!% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Cardinality} +% |#1|: result\\ +% |#2#3|: bits +% \begin{macrocode} +\def\BitSet@Cardinality#1!#2#3!{% + \ifx#21% + \ifx\\#3\\% + \BitSet@AfterFiFi{\IntCalcInc#1! }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Cardinality + \IntCalcInc#1!!#3!% + }% + \fi + \else + \ifx\\#3\\% + \BitSet@AfterFiFi{#1 }% + \else + \BitSet@AfterFiFi{% + \BitSet@Cardinality#1!#3!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Queries}\label{src:query} +% +% \begin{macro}{\bitsetIsDefined} +% \begin{macrocode} +\def\bitsetIsDefined#1{% + \BitSet@IfUndefined{#1}% + \BitSet@SecondOfTwo + \BitSet@FirstOfTwo +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\bitsetIsEmpty} +% \begin{macrocode} +\def\bitsetIsEmpty#1{% + \BitSet@IfUndefined{#1}\BitSet@FirstOfTwo{% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Zero + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Zero} +% \begin{macrocode} +\def\BitSet@Zero{0} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetQuery} +% \begin{macrocode} +\def\bitsetQuery#1#2{% + \ifnum\bitsetGet{#1}{#2}=1 % + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetEquals} +% \begin{macrocode} +\def\bitsetEquals#1#2{% + \BitSet@IfUndefined{#1}{% + \BitSet@IfUndefined{#2}\BitSet@FirstOfTwo\BitSet@SecondOfTwo + }{% + \BitSet@IfUndefined{#2}\BitSet@SecondOfTwo{% + \expandafter\ifx\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi + }% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bitsetIntersects} +% \begin{macrocode} +\def\bitsetIntersects#1#2{% + \bitsetIsEmpty{#1}\BitSet@SecondOfTwo{% + \bitsetIsEmpty{#2}\BitSet@SecondOfTwo{% + \expandafter\expandafter\expandafter\BitSet@Intersects + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!% + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BitSet@Intersects} +% \begin{macrocode} +\def\BitSet@Intersects#1#2!#3#4!{% + \ifnum#1#3=11 % + \BitSet@AfterFi\BitSet@FirstOfTwo + \else + \ifx\\#2\\% + \BitSet@AfterFiFi\BitSet@SecondOfTwo + \else + \ifx\\#4\\% + \BitSet@AfterFiFiFi\BitSet@SecondOfTwo + \else + \BitSet@AfterFiFiFi{% + \BitSet@Intersects#2!#4!% + }% + \fi + \fi + \BitSet@Fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\BitSet@AtEnd +%</package> +% \end{macrocode} +% +% \section{Test} +% +% \subsection{Catcode checks for loading} +% +% \begin{macrocode} +%<*test1> +% \end{macrocode} +% \begin{macrocode} +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input bitset.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +% \end{macrocode} +% \begin{macrocode} +%</test1> +% \end{macrocode} +% +% \subsection{Macro tests} +% +% \subsubsection{Preamble} +% +% \begin{macrocode} +%<*test2> +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\makeatletter +%<*noetex> +\let\SavedNumexpr\numexpr +\let\SavedIfcsname\ifcsname +\let\SavedCurrentgrouplevel\currentgrouplevel +\def\ETeXDisable{% + \let\ifcsname\@undefined + \let\numexpr\@undefined + \let\currentgrouplevel\@undefined +} +\ETeXDisable +%</noetex> +\makeatletter +\chardef\BitSet@TestMode=1 % +\makeatother +\usepackage{bitset}[2007/09/28] +%<*noetex> +\def\ETeXEnable{% + \let\numexpr\SavedNumexpr + \let\ifcsname\SavedIfcsname + \let\currentgrouplevel\SavedCurrentgrouplevel +} +\ETeXEnable +%</noetex> +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\makeatletter +% \end{macrocode} +% +% \subsubsection{Time} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% +\fi +% \end{macrocode} +% +% \subsubsection{Detection of unwanted space} +% +% \begin{macrocode} +\let\orig@qstest\qstest +\let\orig@endqstest\endqstest +\def\qstest#1#2{% + \orig@qstest{#1}{#2}% + \setbox0\hbox\bgroup\begingroup\ignorespaces +} +\def\endqstest{% + \endgroup\egroup + \Expect*{\the\wd0}{0.0pt}% + \orig@endqstest +} +% \end{macrocode} +% +% \subsubsection{Test macros} +% +% \begin{macrocode} +\newcounter{Test} + +\def\TestError#1#2{% + \begingroup + \setcounter{Test}{0}% + \sbox0{% + \def\@PackageError##1##2##3{% + \stepcounter{Test}% + \begingroup + \let\MessageBreak\relax +%<*noetex> + \ETeXEnable +%</noetex> + \Expect{##1}{bitset}% + \Expect*{##2}*{#1}% + \endgroup + }% +%<*noetex> + \ETeXDisable +%</noetex> + #2% + }% + \Expect*{\theTest}{1}% + \Expect*{\the\wd0}{0.0pt}% + \endgroup +} + +\def\TestErrorNegativeIndex#1#2{% + \TestError{Invalid negative index (#1)}{#2}% +} + +\def\TestGetterUndefined#1{% + \CheckUndef{dummy}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{#1{dummy}}{0}% +} + +\def\ExpectBitSet#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\csname BS@#1\endcsname}*{#2}% +} +\def\Check#1#2{% + \ExpectBitSet{#1}{#2}% +} +\def\CheckUndef#1{% + \begingroup + \Expect*{% + \expandafter + \ifx\csname BS@#1\endcsname\relax true\else false\fi + }{true}% + \endgroup +} +\def\RevCheck#1#2{% + \ExpectBitSet{#1}{\Reverse#2!!}% +} +\def\Set#1#2{% + \expandafter\def\csname BS@#1\endcsname{#2}% +} +\def\RevSet#1#2{% + \expandafter\edef\csname BS@#1\endcsname{% + \Reverse#2!!% + }% +} +\def\Reverse#1#2!#3!{% + \ifx\\#2\\% + #1#3% + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\Reverse#2!#1#3!}% +} +% \end{macrocode} +% +% \subsubsection{Test sets} +% +% \begin{macrocode} +\begin{qstest}{Let}{Let} + \CheckUndef{abc}% + \CheckUndef{xyz}% + \bitsetLet{xyz}{abc}% + \CheckUndef{abc}% + \Check{xyz}{0}% + \Set{abc}{1}% + \Check{abc}{1}% + \Check{xyz}{0}% + \bitsetLet{xyz}{abc}% + \Check{abc}{1}% + \Check{xyz}{1}% + \Set{xyz}{11}% + \Check{abc}{1}% + \Check{xyz}{11}% +\end{qstest} + +\begin{qstest}{Reset}{Reset} + \bitsetReset{xyz}% + \Check{xyz}{0}% + \bitsetReset{abc}% + \Check{abc}{0}% + \Set{abc}{10101}% + \bitsetReset{abc}% + \Check{abc}{0}% +\end{qstest} + +\begin{qstest}{Get/Query}{Get/Query} + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGet{dummy}{0}% + }{0}% + \begingroup + \expandafter\def\csname BitSetError:NegativeIndex\endcsname{}% + \Set{abc}{1}% + \Expect*{\bitsetQuery{abc}{-1}{true}{false}}{false}% + \endgroup + \def\Test#1#2#3{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetGet{abc}{#2}}{#3}% + \Expect*{\bitsetQuery{abc}{#2}{true}{false}}% + *{\ifcase#3 false\or true\else error\fi}% + }% + \Test{1}{100}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{11}{1}{1}% + \Test{111}{1}{1}% + \Test{101}{1}{0}% + \Test{101}{2}{1}% + \Test{10100110011}{10}{1}% +\end{qstest} + +\begin{qstest}{Size}{Size} + \TestGetterUndefined\bitsetSize + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{\bitsetSize{abc}}{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{2}% + \Test{11}{2}% + \Test{010}{2}% + \Test{011}{3}% + \Test{100110011}{9}% + \Test{0000011111000001111100000}{20}% + \Test{000000000000000000000000011111111111111111111}{45}% +\end{qstest} + +\begin{qstest}{Cardinality}{Cardinality} + \TestGetterUndefined\bitsetCardinality + \def\Test#1#2{% + \Set{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetCardinality{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{00}{0}% + \Test{0000000}{0}% + \Test{10}{1}% + \Test{01}{1}% + \Test{11}{2}% + \Test{010}{1}% + \Test{011}{2}% + \Test{100110011}{5}% + \Test{0000011111000001111100000}{10}% + \Test{000000000000000000000000011111111111111111111}{20}% +\end{qstest} + +\begin{qstest}{NextClearBit/NextSetBit}{NextClearBit/NextSetBit} + \def\Test#1#2{% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \TestOp{abc}{#1}% + }{#2}% + }% + \def\Clear{\let\TestOp\bitsetNextClearBit}% + \def\Set{\let\TestOp\bitsetNextSetBit}% + \begingroup + \catcode`\:=11 % + \bitsetSetBin{abc}{1}% + \Clear + \Test{-1}{1\BitSetError:NegativeIndex}% + \Set + \Test{-1}{0\BitSetError:NegativeIndex}% + \endgroup + \let\BS@abc\@undefined + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetReset{abc}% + \Clear + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{-1}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1}% + \Clear + \Test{0}{1}% + \Test{1}{1}% + \Test{2}{2}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111000111000111000111}% + \Clear + \Test{0}{3}% + \Test{1}{3}% + \Test{2}{3}% + \Test{3}{3}% + \Test{4}{4}% + \Test{5}{5}% + \Test{6}{9}% + \Test{7}{9}% + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{11}{11}% + \Test{12}{15}% + \Test{13}{15}% + \Test{14}{15}% + \Test{15}{15}% + \Test{16}{16}% + \Test{17}{17}% + \Test{18}{21}% + \Test{19}{21}% + \Test{20}{21}% + \Test{21}{21}% + \Test{22}{22}% + \Test{100}{100}% + \Set + \Test{0}{0}% + \Test{1}{1}% + \Test{2}{2}% + \Test{3}{6}% + \Test{4}{6}% + \Test{5}{6}% + \Test{6}{6}% + \Test{7}{7}% + \Test{8}{8}% + \Test{9}{12}% + \Test{10}{12}% + \Test{11}{12}% + \Test{12}{12}% + \Test{13}{13}% + \Test{14}{14}% + \Test{15}{18}% + \Test{16}{18}% + \Test{17}{18}% + \Test{18}{18}% + \Test{19}{19}% + \Test{20}{20}% + \Test{21}{-1}% + \Test{22}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111}% + \Clear + \Test{6}{7}% + \Test{7}{7}% + \Test{8}{8}% + \Test{100}{100}% + \Set + \Test{6}{6}% + \Test{7}{-1}% + \Test{8}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{11111111}% + \Clear + \Test{7}{8}% + \Test{8}{8}% + \Test{9}{9}% + \Test{100}{100}% + \Set + \Test{7}{7}% + \Test{8}{-1}% + \Test{9}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{111111111}% + \Clear + \Test{8}{9}% + \Test{9}{9}% + \Test{10}{10}% + \Test{100}{100}% + \Set + \Test{8}{8}% + \Test{9}{-1}% + \Test{10}{-1}% + \Test{100}{-1}% + \bitsetSetBin{abc}{1111111111}% + \Clear + \Test{9}{10}% + \Test{10}{10}% + \Test{11}{11}% + \Test{100}{100}% + \Set + \Test{9}{9}% + \Test{10}{-1}% + \Test{11}{-1}% + \Test{100}{-1}% +\end{qstest} + +\begin{qstest}{GetSetBitList}{GetSetBitList} + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetSetBitList{abc}% + }{#2}% + }% + \Test{0}{}% + \Test{1}{0}% + \Test{10}{1}% + \Test{11}{0,1}% + \Test{10110100}{2,4,5,7}% + \Test{101101001010011}{0,1,4,6,9,11,12,14}% +\end{qstest} + +\begin{qstest}{GetDec}{GetDec} + \TestGetterUndefined\bitsetGetDec + \def\Test#1#2{% + \RevSet{abc}{#1}% +%<*noetex> + \begingroup\expandafter\expandafter\expandafter\endgroup +%</noetex> + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetDec{abc}% + }{#2}% + }% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{2}% + \Test{11}{3}% + \Test{100}{4}% + \Test{101}{5}% + \Test{110}{6}% + \Test{111}{7}% + \Test{1000}{8}% + \Test{000111}{7}% + \Test{1111111111111111% + 111111111111111}{2147483647}% + \Test{0001111111111111111% + 111111111111111}{2147483647}% + \Test{1000000000000000% + 0000000000000000}{2147483648}% + \Test{1000000000000000% + 00000000000000000}{4294967296}% + \Test{0001000000000000000% + 00000000000000000}{4294967296}% + \Test{1100000000000000% + 00000000000000011}{6442450947}% +\end{qstest} + +\begin{qstest}{Clear}{Clear} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetClear{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetClear{abc}{2}% + \RevCheck{abc}{0}% + \TestErrorNegativeIndex{-1}{\bitsetClear{abc}{-1}}% + \RevCheck{abc}{0}% + \Test{0}{0}{0}% + \Test{1}{0}{0}% + \Test{111}{1}{101}% + \Test{111}{30}{111}% + \Test{0000111}{5}{0000111}% 111 would also be ok + \Test{10000111}{5}{10000111}% + \Test{1001001}{3}{1000001}% +\end{qstest} + +\begin{qstest}{Set}{Set} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetSet{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetSet{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetSet{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{1}% + \Test{100}{1}{110}% + \Test{111}{1}{111}% + \Test{11}{1}{11}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1001001}% +\end{qstest} + +\begin{qstest}{Flip}{Flip} + \def\Test#1#2#3{% + \RevSet{abc}{#1}% + \bitsetFlip{abc}{#2}% + \Expect*{\BS@abc}*{\Reverse#3!!}% + }% + \bitsetFlip{abc}{2}% + \RevCheck{abc}{100}% + \TestErrorNegativeIndex{-1}{\bitsetFlip{abc}{-1}}% + \RevCheck{abc}{100}% + \Test{0}{0}{1}% + \Test{1}{0}{0}% + \Test{0}{2}{100}% + \Test{100}{1}{110}% + \Test{111}{1}{101}% + \Test{11}{1}{1}% + \Test{11}{2}{111}% + \Test{11}{3}{1011}% + \Test{111}{10}{10000000111}% + \Test{0000111}{5}{0100111}% 100111 would also be ok + \Test{10000111}{5}{10100111}% + \Test{1000001}{3}{1001001}% + \Test{1001001}{3}{1000001}% + \Test{11111}{2}{11011}% +\end{qstest} + +\begin{qstest}{SetValue}{SetValue} + \def\Test#1#2{% + \TestError{Invalid bit value (#2) not in range 0..1}{% + \bitsetSetValue{abc}{#1}{#2}% + }% + }% + \Test{0}{-1}% + \Test{0}{2}% + \Test{0}{10}% + \def\Test#1#2#3{% + \let\BS@abc\@undefined + \bitsetSetValue{abc}{#1}{#2}% + \bitsetSetBin{result}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}% + \Test{0}{1}{1}% + \Test{1}{0}{0}% + \Test{1}{1}{10}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#4}% + \bitsetSetValue{abc}{#2}{#3}% + \Expect*{\BS@abc}*{\BS@result}% + }% + \Test{0}{0}{0}{0}% + \Test{0}{0}{0}{0}% + \Test{0}{0}{1}{1}% + \Test{0}{1}{0}{0}% + \Test{0}{1}{1}{10}% + \Test{1010}{2}{1}{1110}% + \Test{1010}{4}{1}{11010}% + \Test{1010}{6}{1}{1001010}% + \Test{1010}{1}{0}{1000}% + \Test{1010}{2}{0}{1010}% + \Test{1010}{3}{0}{10}% + \Test{1010}{4}{0}{1010}% + \Test{1010}{6}{0}{1010}% + \Test{1010}{2}{\csname iffalse\endcsname 0\else 1\fi}{1110}% + \Test{1010}{1}{\csname iffalse\endcsname 1\else 0\fi}{1000}% +\end{qstest} + +\begin{qstest}{IsDefined}{IsDefined} + \let\BS@abc\@undefined + \Expect*{\bitsetIsDefined{abc}{true}{false}}{false}% + \bitsetReset{abc}% + \Expect*{\bitsetIsDefined{abc}{true}{false}}{true}% +\end{qstest} + +\begin{qstest}{IsEmpty}{IsEmpty} + \let\BS@abc\@undefined + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetReset{abc}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{true}% + \bitsetSet{abc}{1}% + \Expect*{\bitsetIsEmpty{abc}{true}{false}}{false}% +\end{qstest} + +\begin{qstest}{Equals}{Equals} + \def\Test#1#2#3{% + \Expect*{\bitsetEquals{#1}{#2}{true}{false}}{#3}% + }% + \let\BS@abc\@undefined + \Test{abc}{abc}{true}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetReset{abc}% + \Test{abc}{abc}{true}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetReset{foo}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% + \bitsetSet{abc}{4}% + \Test{abc}{foo}{false}% + \Test{foo}{abc}{false}% + \bitsetFlip{foo}{4}% + \Test{abc}{foo}{true}% + \Test{foo}{abc}{true}% +\end{qstest} + +\begin{qstest}{Intersects}{Intersects} + \def\Test#1{% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#1}% + }% + \let\BS@abc\@undefined + \let\BS@foo\@undefined + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \let\BS@abc\@undefined + \Test{false}% + \Set{foo}{1}% + \Test{false}% + \Set{abc}{0}% + \Test{false}% + \Set{abc}{1}% + \Test{true}% + \let\BS@foo\@undefined + \Test{false}% + \Set{foo}{0}% + \Test{false}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \Expect*{\bitsetIntersects{abc}{foo}{true}{false}}{#3}% + }% + \Test{1010}{0101}{false}% + \Test{0}{10}{false}% + \Test{1}{11}{true}% + \Test{11}{1}{true}% + \Test{10}{1}{false}% +\end{qstest} + +\begin{qstest}{And/AndNot/Or/Xor}{And/AndNot/Or/Xor} + \def\@Test#1#2#3#4#5{% + \begingroup + #5% + \begingroup + \let\BS@foo\@undefined + \csname bitset#1\endcsname{abc}{foo}% + \CheckUndef{foo}% + \Check{abc}{#2}% + \endgroup + \begingroup + \bitsetReset{foo}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0}% + \Check{abc}{#3}% + \endgroup + \begingroup + \def\BS@foo{0101}% + \csname bitset#1\endcsname{abc}{foo}% + \Check{foo}{0101}% + \Check{abc}{#4}% + \endgroup + \endgroup + }% + \def\Test#1{% + \def\Op{#1}% + \Test@ + }% + \def\Test@#1#2#3#4#5#6#7#8#9{% + \@Test\Op{#1}{#2}{#3}{% + \let\BS@abc\@undefined + }% + \@Test\Op{#4}{#5}{#6}{% + \bitsetReset{abc}% + }% + \@Test\Op{#7}{#8}{#9}{% + \def\BS@abc{1001}% + }% + }% + \Test{And}% + {0}{0}{0}% + {0}{0}{0}% + {0}{0}{0001}% + \Test{AndNot}% + {0}{0}{0}% + {0}{0}{0}% + {1001}{1001}{1}% + \Test{Or}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{1101}% + \Test{Xor}% + {0}{0}{0101}% + {0}{0}{0101}% + {1001}{1001}{11}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{foo}{#2}% + \csname bitset\Op\endcsname{abc}{foo}% + \RevCheck{foo}{#2}% + \RevCheck{abc}{#3}% + }% + \def\Op{And}% + \Test{1}{111}{1}% + \Test{111}{1}{1}% + \Test{10}{111}{10}% + \Test{111}{10}{10}% + \Test{111}{1000}{0}% + \Test{1000}{111}{0}% + \def\Op{AndNot}% + \Test{1010}{11}{1000}% + \Test{100}{100}{0}% + \Test{111}{1111}{0}% + \Test{100}{111}{0}% + \def\Op{Or}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{1}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \def\Op{Xor}% + \Test{0}{0}{0}% + \Test{1}{0}{1}% + \Test{0}{1}{1}% + \Test{1}{1}{0}% + \Test{1000}{10}{1010}% + \Test{10}{1000}{1010}% + \Test {110011001100}% + {111000111000111}% + {111110100001011}% + \Test{111000111000111}% + {110011001100}% + {111110100001011}% +\end{qstest} + +\begin{qstest}{GetUndef}{GetUndef, GetBin, GetOct, GetHex} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \x{abc}{#1}% + }{#2}% + }% + \let\x\bitsetGetBin + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \let\x\bitsetGetOct + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{00}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{000}% + \TestUndef{8}{000}% + \TestUndef{9}{000}% + \TestUndef{10}{0000}% + \let\x\bitsetGetHex + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{0}% + \TestUndef{3}{0}% + \TestUndef{4}{0}% + \TestUndef{5}{00}% + \TestUndef{6}{00}% + \TestUndef{7}{00}% + \TestUndef{8}{00}% + \TestUndef{9}{000}% + \TestUndef{10}{000}% + \TestUndef{12}{000}% + \TestUndef{13}{0000}% + \TestUndef{16}{0000}% + \TestUndef{17}{00000}% +\end{qstest} + +\begin{qstest}{SetBin}{SetBin} + \def\Test#1#2{% + \let\BS@abc\@undefined + \bitsetSetBin{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{1}{1}% + \Test{10}{01}% + \Test{11}{11}% + \Test{010}{01}% + \Test{011}{11}% + \Test{0010}{01}% + \Test{1010}{0101}% +\end{qstest} + +\begin{qstest}{SetOct}{SetOct} + \def\Test#1#2{% + \bitsetSetOct{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{0001}% + \Test{020}{00001}% + \Test{42}{010001}% + \Test{377}{11111111}% + \Test{0377}{11111111}% + \Test{76543210}{000100010110001101011111}% + \Test{ 0 7 0 7 1 }{100111000111}% +\end{qstest} + +\begin{qstest}{SetHex}{SetHex} + \def\Test#1#2{% + \bitsetSetHex{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{001}{1}% + \Test{010}{00001}% + \Test{020}{000001}% + \Test{42}{0100001}% + \Test{3F}{111111}% + \Test{03F}{111111}% + \Test{43210}{0000100001001100001}% + \Test{98765}{10100110111000011001}% + \Test{FEDCBA}{010111010011101101111111}% + \Test{ 0 F 0 F 1 }{1000111100001111}% +\end{qstest} + +\begin{qstest}{SetDec}{SetDec} + \def\Test#1#2{% + \bitsetSetDec{abc}{#1}% + \expandafter\Expect\expandafter{\BS@abc}{#2}% + }% + \Test{}{0}% + \Test{0}{0}% + \Test{000}{0}% + \Test{1}{1}% + \Test{7}{111}% + \Test{8}{0001}% + \Test{001}{1}% + \Test{010}{0101}% + \Test{020}{00101}% + \Test{53}{101011}% + \Test{255}{11111111}% + \Test{256}{000000001}% + \Test{999999999}{111111111001001101011001110111}% + \Test{1000000000}{000000000101001101011001110111}% + \Test{4210987654}{01100001010010010111111101011111}% + \Test{2147483647}{1111111111111111111111111111111}% + \Test{2147483648}{00000000000000000000000000000001}% +\end{qstest} + +\begin{qstest}{GetBin}{GetBin} + \def\TestUndef#1#2{% + \let\BS@abc\@undefined + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \TestUndef{-1}{0}% + \TestUndef{0}{0}% + \TestUndef{1}{0}% + \TestUndef{2}{00}% + \TestUndef{8}{00000000}% + \def\Test#1#2{% + \bitsetSetBin{abc}{#2}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetBin{abc}{#1}% + }{#2}% + }% + \Test{-1}{0}% + \Test{0}{0}% + \Test{1}{0}% + \Test{1}{1}% + \Test{2}{01}% + \Test{2}{10}% + \Test{3}{010}% + \Test{2}{00}% + \Test{2}{01}% + \Test{8}{00101100}% + \Test{2}{10101}% + \Test{-100}{11011}% +\end{qstest} + +\begin{qstest}{GetOct}{GetOct} + \def\Test#1#2#3{% + \edef\x{\zap@space#1 \@empty}% + \edef\x{\noexpand\bitsetSetBin{abc}{\x}}% + \x + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetOct{abc}{#2}% + }{#3}% + }% + \Test{111 110 101 100 011 010 001 000}{0}{76543210}% + \Test{000 111}{0}{7}% + \Test{101 000}{-1}{50}% + \Test{111}{-1}{7}% + \Test{111}{0}{7}% + \Test{111}{1}{7}% + \Test{111}{3}{7}% + \Test{111}{4}{07}% + \Test{111}{6}{07}% + \Test{111}{7}{007}% + \Test{111 010}{6}{72}% + \Test{111 010}{7}{072}% + \Test{011 111}{0}{37}% + \Test{011 111}{6}{37}% + \Test{011 111}{7}{037}% + \Test{001 111}{0}{17}% + \Test{001 111}{6}{17}% + \Test{001 111}{7}{017}% +\end{qstest} + +\begin{qstest}{GetHex}{GetHex} + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter{% + \bitsetGetHex{abc}{#2}% + }{#3}% + }% + \Test{1111 1110 1101 1100 1011 1010 1001 1000}{0}{FEDCBA98}% + \Test{0111 0110 0101 0100 0011 0010 0001 0000}{0}{76543210}% + \Test{0000 1111}{0}{F}% + \Test{0101 0000}{-1}{50}% + \Test{1111}{-1}{F}% + \Test{1111}{0}{F}% + \Test{1111}{1}{F}% + \Test{1111}{4}{F}% + \Test{1111}{5}{0F}% + \Test{1111}{8}{0F}% + \Test{1111}{9}{00F}% + \Test{1111 0010}{8}{F2}% + \Test{1111 0010}{9}{0F2}% + \Test{0111 1111}{0}{7F}% + \Test{0111 1111}{8}{7F}% + \Test{0111 1111}{9}{07F}% + \Test{0011 1111}{0}{3F}% + \Test{0011 1111}{8}{3F}% + \Test{0011 1111}{9}{03F}% + \Test{0001 1111}{0}{1F}% + \Test{0001 1111}{8}{1F}% + \Test{0001 1111}{9}{01F}% +\end{qstest} + +\begin{qstest}{Range}{Range} + \TestError{% + Wrong index numbers in range [9..8]\MessageBreak% hash-ok + for clear/set/flip on bit set `abc'.\MessageBreak + The lower index exceeds the upper index.\MessageBreak + Canceling the operation as error recovery% + }{% + \bitsetSetRange{abc}{9}{8}% + }% + \def\TestErrorNegInd#1#2#3#4#5#6{% + \TestError{% + Negative index in range [#2..#3]\MessageBreak % hash-ok + for \string\bitset #1Range on bit set `abc'.\MessageBreak + Using [#4..#5] as error recovery% hash-ok + }{% + \csname bitset#1Range\endcsname{abc}{#2}{#3}% + \global\let\BS@global\BS@abc + }% + \Check{global}{#6}% + }% + \Set{abc}{111}% + \TestErrorNegInd{Clear}{-1}{0}{0}{0}{111}% + \TestErrorNegInd{Clear}{0}{-1}{0}{0}{111}% + \TestErrorNegInd{Clear}{-2}{2}{0}{2}{001}% + \bitsetReset{abc}% + \TestErrorNegInd{Set}{-1}{0}{0}{0}{0}% + \TestErrorNegInd{Set}{0}{-1}{0}{0}{0}% + \TestErrorNegInd{Set}{-2}{2}{0}{2}{11}% + \Set{abc}{101}% + \TestErrorNegInd{Flip}{-1}{0}{0}{0}{101}% + \TestErrorNegInd{Flip}{0}{-1}{0}{0}{101}% + \TestErrorNegInd{Flip}{-2}{2}{0}{2}{011}% + \def\Test#1#2#3#4{% + \bitsetSetBin{abc}{#1}% + \csname bitset\TestOp Range\endcsname{abc}{#2}{#3}% + \Expect*{\bitsetGetBin{abc}{0}}{#4}% + }% + \def\TestOp{Clear}% + \Test{0}{0}{1}{0}% + \Test{1111}{1}{2}{1101}% + \Test{1111}{1}{3}{1001}% + \Test{1111111100000000}{12}{14}{1100111100000000}% + \def\TestOp{Set}% + \Test{0}{0}{1}{1}% + \Test{1000}{1}{2}{1010}% + \Test{0}{1}{2}{10}% + \Test{1}{12}{15}{111000000000001}% + \Test{1111}{1}{3}{1111}% + \Test{1000000000000000}{12}{14}{1011000000000000}% + \def\TestOp{Flip}% + \Test{0}{0}{1}{1}% + \Test{1}{0}{1}{0}% + \Test{10101010}{1}{5}{10110100}% + \def\Test#1#2#3#4#5{% + \bitsetSetBin{abc}{#1}% + \bitsetSetValueRange{abc}{#2}{#3}{#4}% + \Expect*{\bitsetGetBin{abc}{0}}{#5}% + }% + \Test{0}{0}{1}{0}{0}% + \Test{0}{0}{1}{1}{1}% + \Test{1010}{1}{3}{0}{1000}% + \Test{1010}{1}{3}{1}{1110}% +\end{qstest} + +\begin{qstest}{ShiftLeft/ShiftRight}{ShiftLeft/ShiftRight} + \def\@Test#1#2{% + \let\BS@abc\@undefined + \csname bitsetShift#1\endcsname{abc}{#2}% + \Expect*{\BS@abc}{0}% + }% + \def\Test#1{% + \@Test{Left}{#1}% + \@Test{Right}{#1}% + }% + \Test{-16}% + \Test{-1}% + \Test{0}% + \Test{1}% + \Test{16}% + \def\Test#1#2#3{% + \bitsetSetBin{abc}{#1}% + \bitsetSetBin{result}{#3}% + \csname bitsetShift\Op\endcsname{abc}{#2}% + \Expect*{\bitsetGetBin{abc}{0}}*{\bitsetGetBin{result}{0}}% + }% + \def\Op{Left}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{10}% + \Test{1}{-1}{0}% + \Test{10}{1}{100}% + \Test{10}{-1}{1}% + \Test{1}{32}{100000000000000000000000000000000}% + \Test{1}{-100}{0}% + \def\Op{Right}% + \Test{0}{0}{0}% + \Test{0}{1}{0}% + \Test{0}{-1}{0}% + \Test{1}{0}{1}% + \Test{1}{1}{0}% + \Test{1}{-1}{10}% + \Test{10}{1}{1}% + \Test{10}{-1}{100}% + \Test{1}{-32}{100000000000000000000000000000000}% + \Test{1}{100}{0}% + \Test{110110110110110}{10}{11011}% + \Test{110110110110110}{100}{0}% + \Test{1}{100000}{0}% +\end{qstest} + +\begin{qstest}{Profile: Set}{Profile: Set} + \bitsetSet{abc}{4095}% + \global\let\BS@global\BS@abc +\end{qstest} + +\begin{qstest}{Profile: Get}{Profile: Get} + \edef\x{\bitsetGet{global}{4095}}% +\end{qstest} + +\begin{document} +\end{document} +%</test2> +% \end{macrocode} +% +% \section{Installation} +% +% \subsection{Download} +% +% \paragraph{Package.} This package is available on +% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}: +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/bitset.dtx}] The source file. +% \item[\CTAN{macros/latex/contrib/oberdiek/bitset.pdf}] Documentation. +% \end{description} +% +% +% \paragraph{Bundle.} All the packages of the bundle `oberdiek' +% are also available in a TDS compliant ZIP archive. There +% the packages are already unpacked and the documentation files +% are generated. The files and directories obey the TDS standard. +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/oberdiek-tds.zip}] +% \end{description} +% \emph{TDS} refers to the standard ``A Directory Structure +% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories +% with \xfile{texmf} in their name are usually organized this way. +% +% \subsection{Bundle installation} +% +% \paragraph{Unpacking.} Unpack the \xfile{oberdiek-tds.zip} in the +% TDS tree (also known as \xfile{texmf} tree) of your choice. +% Example (linux): +% \begin{quote} +% |unzip oberdiek-tds.zip -d ~/texmf| +% \end{quote} +% +% \paragraph{Script installation.} +% Check the directory \xfile{TDS:scripts/oberdiek/} for +% scripts that need further installation steps. +% Package \xpackage{attachfile2} comes with the Perl script +% \xfile{pdfatfi.pl} that should be installed in such a way +% that it can be called as \texttt{pdfatfi}. +% Example (linux): +% \begin{quote} +% |chmod +x scripts/oberdiek/pdfatfi.pl|\\ +% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/| +% \end{quote} +% +% \subsection{Package installation} +% +% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting +% \docstrip\ archive. The files are extracted by running the +% \xfile{.dtx} through \plainTeX: +% \begin{quote} +% \verb|tex bitset.dtx| +% \end{quote} +% +% \paragraph{TDS.} Now the different files must be moved into +% the different directories in your installation TDS tree +% (also known as \xfile{texmf} tree): +% \begin{quote} +% \def\t{^^A +% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} +% bitset.sty & tex/generic/oberdiek/bitset.sty\\ +% bitset.pdf & doc/latex/oberdiek/bitset.pdf\\ +% bitset-test1.tex & doc/latex/oberdiek/bitset-test1.tex\\ +% bitset-test2.tex & doc/latex/oberdiek/bitset-test2.tex\\ +% bitset-test3.tex & doc/latex/oberdiek/bitset-test3.tex\\ +% bitset.dtx & source/latex/oberdiek/bitset.dtx\\ +% \end{tabular}^^A +% }^^A +% \sbox0{\t}^^A +% \ifdim\wd0>\linewidth +% \begingroup +% \advance\linewidth by\leftmargin +% \advance\linewidth by\rightmargin +% \edef\x{\endgroup +% \def\noexpand\lw{\the\linewidth}^^A +% }\x +% \def\lwbox{^^A +% \leavevmode +% \hbox to \linewidth{^^A +% \kern-\leftmargin\relax +% \hss +% \usebox0 +% \hss +% \kern-\rightmargin\relax +% }^^A +% }^^A +% \ifdim\wd0>\lw +% \sbox0{\small\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\footnotesize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\scriptsize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\tiny\t}^^A +% \ifdim\wd0>\linewidth +% \lwbox +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \end{quote} +% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's +% TDS installing feature, then some files can already be in the right +% place, see the documentation of \docstrip. +% +% \subsection{Refresh file name databases} +% +% If your \TeX~distribution +% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh +% these. For example, \teTeX\ users run \verb|texhash| or +% \verb|mktexlsr|. +% +% \subsection{Some details for the interested} +% +% \paragraph{Attached source.} +% +% The PDF documentation on CTAN also includes the +% \xfile{.dtx} source file. It can be extracted by +% AcrobatReader 6 or higher. Another option is \textsf{pdftk}, +% e.g. unpack the file into the current directory: +% \begin{quote} +% \verb|pdftk bitset.pdf unpack_files output .| +% \end{quote} +% +% \paragraph{Unpacking with \LaTeX.} +% The \xfile{.dtx} chooses its action depending on the format: +% \begin{description} +% \item[\plainTeX:] Run \docstrip\ and extract the files. +% \item[\LaTeX:] Generate the documentation. +% \end{description} +% If you insist on using \LaTeX\ for \docstrip\ (really, +% \docstrip\ does not need \LaTeX), then inform the autodetect routine +% about your intention: +% \begin{quote} +% \verb|latex \let\install=y\input{bitset.dtx}| +% \end{quote} +% Do not forget to quote the argument according to the demands +% of your shell. +% +% \paragraph{Generating the documentation.} +% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate +% the documentation. The process can be configured by the +% configuration file \xfile{ltxdoc.cfg}. For instance, put this +% line into this file, if you want to have A4 as paper format: +% \begin{quote} +% \verb|\PassOptionsToClass{a4paper}{article}| +% \end{quote} +% An example follows how to generate the +% documentation with pdf\LaTeX: +% \begin{quote} +%\begin{verbatim} +%pdflatex bitset.dtx +%makeindex -s gind.ist bitset.idx +%pdflatex bitset.dtx +%makeindex -s gind.ist bitset.idx +%pdflatex bitset.dtx +%\end{verbatim} +% \end{quote} +% +% \begin{History} +% \begin{Version}{2007/09/28 v1.0} +% \item +% First version. +% \end{Version} +% \end{History} +% +% \PrintIndex +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/oberdiek/bookmark.dtx b/Master/texmf-dist/source/latex/oberdiek/bookmark.dtx index 6fd099d53a5..e19f342e983 100644 --- a/Master/texmf-dist/source/latex/oberdiek/bookmark.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/bookmark.dtx @@ -76,7 +76,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: bookmark 2007/07/13 v1.1 PDF bookmarks (HO)} +\Msg{* Package: bookmark 2007/09/25 v1.2 PDF bookmarks (HO)} \Msg{************************************************************************} \keepsilent @@ -149,7 +149,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bookmark.drv}% - [2007/07/13 v1.1 PDF bookmarks (HO)]% + [2007/09/25 v1.2 PDF bookmarks (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -158,7 +158,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{1953} +% \CheckSum{1962} % % \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 @@ -179,7 +179,7 @@ and the derived files % \GetFileInfo{bookmark.drv} % % \title{The \xpackage{bookmark} package} -% \date{2007/07/13 v1.1} +% \date{2007/09/25 v1.2} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -496,7 +496,7 @@ and the derived files open, openlevel=2, atend -]{bookmark}[2007/07/13] +]{bookmark}[2007/09/25] \bookmarksetup{color=blue} @@ -599,7 +599,7 @@ and the derived files %<*package> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{bookmark}% - [2007/07/13 v1.1 PDF bookmarks (HO)]% + [2007/09/25 v1.2 PDF bookmarks (HO)]% % \end{macrocode} % % \subsubsection{Requirements} @@ -1213,7 +1213,7 @@ and the derived files %<*dvipdfm> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvipdfm.def}% - [2007/07/13 v1.1 bookmark driver for dvipdfm (HO)]% + [2007/09/25 v1.2 bookmark driver for dvipdfm (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -1378,7 +1378,7 @@ and the derived files %<*vtex> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-vtex.def}% - [2007/07/13 v1.1 bookmark driver for VTeX (HO)]% + [2007/09/25 v1.2 bookmark driver for VTeX (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -1663,7 +1663,7 @@ and the derived files %<*pdftex> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-pdftex.def}% - [2007/07/13 v1.1 bookmark driver for pdfTeX (HO)]% + [2007/09/25 v1.2 bookmark driver for pdfTeX (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -1775,7 +1775,7 @@ and the derived files %<*dvips> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvips.def}% - [2007/07/13 v1.1 bookmark driver for dvips (HO)]% + [2007/09/25 v1.2 bookmark driver for dvips (HO)]% % \end{macrocode} % \begin{macrocode} \def\BKM@PSHeaderFile#1{% @@ -1790,7 +1790,7 @@ and the derived files %<*dvipsone> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvipsone.def}% - [2007/07/13 v1.1 bookmark driver for dvipsone (HO)]% + [2007/09/25 v1.2 bookmark driver for dvipsone (HO)]% % \end{macrocode} % \begin{macrocode} \def\BKM@PSHeaderFile#1{% @@ -1805,7 +1805,7 @@ and the derived files %<*textures> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-textures.def}% - [2007/07/13 v1.1 bookmark driver for textures (HO)]% + [2007/09/25 v1.2 bookmark driver for textures (HO)]% % \end{macrocode} % \begin{macrocode} \def\BKM@PSHeaderFile#1{% @@ -1828,17 +1828,22 @@ and the derived files % % \begin{macrocode} \def\BKM@pdfmark@out{% - \newwrite\BKM@file - \immediate\openout\BKM@file=\BKM@filename\relax - \BKM@write{\@percentchar!}% - \BKM@write{/pdfmark where{pop}}% - \BKM@write{% - {% - /globaldict where{pop globaldict}{userdict}ifelse% - /pdfmark/cleartomark load put% + \if@filesw + \newwrite\BKM@file + \immediate\openout\BKM@file=\BKM@filename\relax + \BKM@write{\@percentchar!}% + \BKM@write{/pdfmark where{pop}}% + \BKM@write{% + {% + /globaldict where{pop globaldict}{userdict}ifelse% + /pdfmark/cleartomark load put% + }% }% - }% - \BKM@write{ifelse}% + \BKM@write{ifelse}% + \else + \let\BKM@write\@gobble + \let\BKM@DO@entry\@gobbletwo + \fi } \def\BKM@write#{% \immediate\write\BKM@file @@ -2453,6 +2458,10 @@ and the derived files % \item % Fix for pdfmark with GoToR action. % \end{Version} +% \begin{Version}{2007/09/25 v1.2} +% \item +% pdfmark driver respects \cs{nofiles}. +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/engord.dtx b/Master/texmf-dist/source/latex/oberdiek/engord.dtx index a8ef4e5e11f..a5398f82a4a 100644 --- a/Master/texmf-dist/source/latex/oberdiek/engord.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/engord.dtx @@ -69,7 +69,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: engord 2007/09/09 v1.5 Provides the ifpdf switch (HO)} +\Msg{* Package: engord 2007/09/20 v1.6 Provides English ordinal numbers (HO)} \Msg{************************************************************************} \keepsilent @@ -133,7 +133,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{engord.drv}% - [2007/09/09 v1.5 Provides the ifpdf switch (HO)]% + [2007/09/20 v1.6 Provides English ordinal numbers (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -163,7 +163,7 @@ and the derived files % \GetFileInfo{engord.drv} % % \title{The \xpackage{engord} package} -% \date{2007/09/09 v1.5} +% \date{2007/09/20 v1.6} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -323,7 +323,7 @@ and the derived files \fi \expandafter\x\csname ver@engord.sty\endcsname \ProvidesPackage{engord}% - [2007/09/09 v1.5 Provides the ifpdf switch (HO)] + [2007/09/20 v1.6 Provides English ordinal numbers (HO)] % \end{macrocode} % % \subsection{Help commands for plain compatibility} @@ -853,6 +853,10 @@ and the derived files % \item % Catcode section added. % \end{Version} +% \begin{Version}{2007/09/20 v1.6} +% \item +% Short description fixed (George White). +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/epstopdf.dtx b/Master/texmf-dist/source/latex/oberdiek/epstopdf.dtx index 3bc81e31388..05430f0de5a 100644 --- a/Master/texmf-dist/source/latex/oberdiek/epstopdf.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/epstopdf.dtx @@ -17,7 +17,8 @@ % % This work consists of the main source file epstopdf.dtx % and the derived files -% epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv. +% epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv, +% epstopdf-test1.tex. % % Distribution: % CTAN:macros/latex/contrib/oberdiek/epstopdf.dtx @@ -52,6 +53,7 @@ % Installation: % TDS:tex/latex/oberdiek/epstopdf.sty % TDS:doc/latex/oberdiek/epstopdf.pdf +% TDS:doc/latex/oberdiek/epstopdf-test1.tex % TDS:source/latex/oberdiek/epstopdf.dtx % %<*ignore> @@ -67,7 +69,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: epstopdf 2007/04/26 v1.4 Conversion with epstopdf on the fly (HO)} +\Msg{* Package: epstopdf 2007/10/02 v1.5 Conversion with epstopdf on the fly (HO)} \Msg{************************************************************************} \keepsilent @@ -94,7 +96,8 @@ This Current Maintainer of this work is Heiko Oberdiek. This work consists of the main source file epstopdf.dtx and the derived files - epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv. + epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv, + epstopdf-test1.tex. \endpreamble @@ -103,6 +106,8 @@ and the derived files \file{epstopdf.drv}{\from{epstopdf.dtx}{driver}}% \usedir{tex/latex/oberdiek}% \file{epstopdf.sty}{\from{epstopdf.dtx}{package}}% + \usedir{doc/latex/oberdiek}% + \file{epstopdf-test1.tex}{\from{epstopdf.dtx}{test1}}% } \obeyspaces @@ -128,7 +133,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{epstopdf.drv}% - [2007/04/26 v1.4 Conversion with epstopdf on the fly (HO)]% + [2007/10/02 v1.5 Conversion with epstopdf on the fly (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -137,7 +142,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{195} +% \CheckSum{513} % % \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 @@ -158,7 +163,7 @@ and the derived files % \GetFileInfo{epstopdf.drv} % % \title{The \xpackage{epstopdf} package} -% \date{2007/04/26 v1.4} +% \date{2007/10/02 v1.5} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -176,14 +181,40 @@ and the derived files % % \section{Documentation} % +% \subsection{Introduction} +% +% \LaTeX\ provides its graphics bundle to include graphics files. +% Both packages \xpackage{graphics} or \xpackage{graphicx} may +% be used. the latter one loads the first and adds options +% in key value style for \cs{includegraphics}. +% +% Usually the drivers do not support all kind of graphics files. +% Other image types must be converted, before they become +% usuable. In case of driver \xprogram{dvips}, the graphics +% rule may contain a conversion rule. Then all that package +% \xpackage{graphics} must know is the bounding box, the command +% is passed to \xprogram{dvips} that calls it and embeds the +% converted image. +% +% However, \pdfTeX\ has its driver for PDF output already +% build in. It's graphics inclusion commands (\cs{pdfximage}) +% does not allow the execution of external commands. +% Therefore commands in the last argument of +% \cs{DeclareGraphicsRule} were of no use. +% But external programs can be calles within \pdfTeX. +% This feature is called ``shell escape'' or ``write 18'' +% and must usually enabled explicitely because of security reasons. +% Now, this package \xpackage{epstopdf} hooks +% into package \xpackage{graphics}' code to catch +% that argument with the external command and executes it +% to convert the graphics file to a supported format and +% passes the control of graphics inclusion back to package +% \xpackage{graphics}. +% % \subsection{Requirements} % % \begin{itemize} % \item -% The program \xprogram{epstopdf} for the conversion from EPS -% to PDF. However, other programs can -% be used and configured by \cs{DeclareGraphicsRule}. -% \item % The feature \cs{write18} must be enabled. This allows the % running of external programs during \TeX's compile run. % Keep in mind that this is a security risk. The feature is an @@ -203,48 +234,139 @@ and the derived files % \begin{quote} % |pdflatex -shell-escape test.tex| % \end{quote} +% \item +% The program \xprogram{epstopdf} for the conversion from EPS +% to PDF. However, other programs can +% be used and configured by \cs{DeclareGraphicsRule}. +% Example: +% \begin{quote} +% |\DeclareGraphicsRule{.eps}{pdf}{.pdf}{%|\\ +% | `ps2pdf -dEPSCrop #1 \OutputFile|\\ +% |}| +% \end{quote} % \end{itemize} % -% \section{Usage} +% \subsection{Usage} % % The package is loaded after graphic\{s,x\}, e.g.: % \begin{quote} % |\usepackage[pdftex]{graphicx}|\\ % |\usepackage{epstopdf}| % \end{quote} -% Now images with extension `.eps' are detected -% and supported: -% \begin{itemize} -% \item -% Implicitly: |\includegraphics{bild}|\\ -% If \xfile{bild.eps} is present, but \xfile{bild.pdf} is missed, -% then \xfile{bild.eps} is converted to \xfile{bild.pdf} that -% is then included by \pdfTeX. -% On the next ocurrences or on the next \pdfTeX\ run, -% the PDF file is already available, so the -% conversion step is skipped. -% \item -% Explicitly: |\includegraphics{bild.eps}|\\ -% Each time the conversion program is called. -% \end{itemize} +% Now images with file name extension \xfile{.eps} are detected +% and supported using \cs{includegraphics}. +% +% If the graphics file name is explicitly specified with extension +% \xfile{.eps} the new rule for EPS files is called and +% the conversion performed. If option \xoption{update} is in force +% then the conversion step is dropped if the target file already +% exists and is not older then the EPS file. +% +% The situation is more complicate if the graphics file is +% given without file name extension. Then the \xpackage{graphics} +% package must search for a supported image file. +% The possible extensions are stored in the graphics extension +% list, that can be set by \cs{DeclareGraphicsExtensions}. +% The algorithm: +% \begin{quote} +% \def\>{\mbox{}\quad} +% function search( \meta{filebase} ) +% \>foreach \meta{ext} in \meta{graphics extensions}\\ +% \>\>foreach \meta{dir} in \meta{current directory}, \meta{\cs{graphicspath}}\\ +% \>\>\>\meta{file} := \meta{dir} + \meta{filebase} + \meta{ext}\\ +% \>\>\>if exist \meta{file} +% \>\>\>\>return found +% \>return not found +% \end{quote} +% Package \xpackage{epstopdf} puts \xfile{.eps} at the end of the +% graphics extension list. This is the behaviour of option +% \xoption{append} that is enabled by default. +% That means, the conversion is called last +% unless a supported file type cannot be found earlier. This avoids +% unnecessary conversion steps that slow down the \LaTeX\ run. +% If you want to use option \xoption{update} and your \pdfTeX\ supports +% it, then an outdated PDF file also would be found earlier. +% Therefore extension \xfile{.eps} should be put in front of the list. +% This is achieved by option \xoption{prepend}. Then the EPS file +% is found before the PDF file. Then option \xoption{update} +% have the control and can compare file dates. +% +% Note: Usually the conversion program needs the exact location +% of the image file. Usually the current directory works. +% Also if the image file is found using \cs{graphicspath}, the +% location is known. However, if the image is somewhere +% in a directory of environment variable |TEXINPUTS|, then +% the package does not know the exact location and the +% conversion program will not find the image file unless it +% implements a search using |TEXINPUTS| (program \xprogram{kpsewhich} +% may be of help in this task). +% +% \subsection{Options} +% +% Options can be given as package options or later using: +% \begin{declcs}{epstopdfsetup} \M{key value list} +% \end{declcs} +% +% \begin{description} +% \def\It#1{\item[\xoption{#1}:]}^^A +% \It{update} +% The conversion program is only called, if the target file +% does not exist or is older than the source image file. +% This option +% \It{append} +% Puts the extension \xfile{.eps} at the end of the graphics extension list +% (default). +% \It{prepend} +% Puts the extension \xfile{.eps} at the begin of the graphics extension list. +% \It{outdir} +% The converted file may put in an other output directory. +% The value of \xoption{outdir} must include the directory separator. +% Example for the current directory: +% \begin{quote} +% |\epstopdfsetup{outdir=./}| +% \end{quote} +% For other directories ensure, that they can be found. +% See \cs{graphicspath} or |TEXINPUTS|. +% \It{verbose} +% It prints some information about the image in the \xfile{.log} file. +% \end{description} % % \subsection{Configuration} % -% Package \xpackage{epstopdf} implements the forth argument -% of \cs{DeclareGraphicsRule} for \pdfTeX. There conversion programs -% can be configured and package \xpackage{epstopdf} declares: +% \subsubsection{Configuration file} +% +% A configuration file \xfile{epstopdf.cfg} is loaded at the end +% of the package if it exists. It can be used for changing +% the default option setting. My favourite setting is: % \begin{quote} -% |\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}| +% |\epstopdfsetup{update,prepend,verbose}| % \end{quote} -% Additionally the extension \xfile{.eps} is added to the -% list of extensions that are recognized by package \xpackage{graphics}, -% see \cs{GraphicsExtensions}. % -% Instead of \xprogram{epstopdf} other programs can be used, -% for example \xprogram{ghostscript}: +% \subsubsection{Conversion program} +% +% You can use \cs{DeclareGraphicsRule} the same way as the +% route via \xprogram{dvips} to specify the conversion +% command line, examples below. +% +% Additionally you can use the following macros: +% \begin{description} +% \def\It#1{\item[\cs{#1}:]} +% \It{OutputFile}: output file name (with known path and extension) +% \It{SourceFile}: source file name (with known path and extension), +% usually the same as |#1|. +% \end{description} +% +% \paragraph{Conversion from EPS to PDF.} +% Other programs than \xprogram{epstopdf} can be used to convert from +% EPS to PDF. Example that uses \xprogram{Ghostscript}: % \begin{quote} -% |\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`ps2pdf -dEPSCrop #1}| +% |\DeclareGraphicsRule{.eps}{pdf}{.pdf}{%|\\ +% | `ps2pdf -dEPSCrop #1 \noexpand\OutputFile|\\ +% |}| % \end{quote} +% \cs{DeclareGraphicsRule} expands the argument, therefore \cs{noexpand} +% is necessary. +% Also \cs{OutputFile} respects the setting of option \xoption{outdir}. % % \subsection{Other image formats} % @@ -255,33 +377,19 @@ and the derived files %\begin{quote} %\begin{verbatim} %\DeclareGraphicsRule{.gif}{png}{.png}{% -% `convert #1 `basename #1 .gif`.png% +% `convert #1 \noexpand\OutputFile %} %\end{verbatim} %\end{quote} -% Or without \xprogram{basename}: -%\begin{quote} -%\begin{verbatim} -%\makeatletter -%\DeclareGraphicsRule{.gif}{png}{.png}{% -% `convert #1 \noexpand\Gin@base.png% -%} -%\makeatother -%\end{verbatim} -%\end{quote} % The file extension \xfile{.gif} can be added to the extension list that % package \xpackage{graphics} searches if the file extension % is not given in \cs{includegraphics}. % The list can be set by \cs{GraphicsExtensions}. -% The following example shows another way by adding \xfile{.gif} to the -% list: -%\begin{quote} -%\begin{verbatim} -%\makeatletter -%\g@addto@macro\Gin@extensions{,.gif} -%\makeatother -%\end{verbatim} -%\end{quote} +% \begin{quote} +% |\AppendGraphicsExtensions{.gif}|\\ +% or\\ +% |\PrependGraphicsExtensions{.gif}| +% \end{quote} % % \StopEventually{ % } @@ -292,7 +400,9 @@ and the derived files %<*package> % \end{macrocode} % -% \subsection{Relead check and identification} +% \subsection{Preparations} +% +% \subsubsection{Relead check and identification} % Reload check, especially if the package is not used with \LaTeX. % \begin{macrocode} \begingroup @@ -350,34 +460,43 @@ and the derived files \fi \expandafter\x\csname ver@epstopdf.sty\endcsname \ProvidesPackage{epstopdf}% - [2007/04/26 v1.4 Conversion with epstopdf on the fly (HO)] + [2007/10/02 v1.5 Conversion with epstopdf on the fly (HO)] % \end{macrocode} % -% \subsection{Help macros for miniltx mode} +% \subsubsection{Catcodes} % % \begin{macrocode} -\@ifundefined{PackageWarning}{% - \def\PackageWarning#1#2{% - \begingroup - \newlinechar=10 % - \def\MessageBreak{% - ^^J(#1)\@spaces\@spaces\@spaces\@spaces - }% - \immediate\write16{^^JPackage #1 Warning: #2\on@line.^^J}% - \endgroup - }% -}{} -\@ifundefined{PackageWarningNoLine}{% - \def\PackageWarningNoLine#1#2{% - \PackageWarning{#1}{#2\@gobble}% +\expandafter\edef\csname ETE@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\ETE@AtEnd{% + \ETE@AtEnd + \catcode#1 \the\catcode#1\relax }% -}{} -\@ifundefined{on@line}{% - \def\on@line{ on input line \the\inputlineno}% -}{} -\@ifundefined{@spaces}{% - \def\@spaces{\space\space\space\space}% -}{} + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{12}% : +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{96}{12}% ` +% \end{macrocode} +% +% \subsubsection{Load packages} +% +% \begin{macrocode} +\RequirePackage{infwarerr}[2007/09/09] +\RequirePackage{grfext}\relax +\RequirePackage{kvoptions}[2006/10/02] % \end{macrocode} % % \subsection{Checks} @@ -389,9 +508,11 @@ and the derived files % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname Gin@setfile\endcsname\relax - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% No graphics package \string`graphic{s,x}\string' found% }% + \newcommand*{\epstopdfsetup}[1]{}% + \ETE@AtEnd \expandafter\endinput \fi % \end{macrocode} @@ -403,10 +524,13 @@ and the derived files \def\x{pdftex.def}% \ifx\Gin@driver\x \else - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% Graphics driver file \string`pdftex.def\string' not found% }% - \expandafter\endgroup\expandafter\endinput + \endgroup + \newcommand*{\epstopdfsetup}[1]{}% + \ETE@AtEnd + \expandafter\endinput \fi \endgroup % \end{macrocode} @@ -419,7 +543,7 @@ and the derived files \else \ifnum\pdfshellescape>0 % \else - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% Shell escape feature is not enabled% }% \fi @@ -427,47 +551,277 @@ and the derived files \endgroup % \end{macrocode} % +% \subsection{Package loading} +% +% \begin{macrocode} +% \end{macrocode} +% +% \subsection{Options} +% +% \begin{macrocode} +\SetupKeyvalOptions{family=ETE,prefix=ETE@} +\DeclareBoolOption{update} +\DeclareBoolOption{verbose} +\newif\ifETE@prepend +\DeclareVoidOption{prepend}{\ETE@prependtrue} +\DeclareVoidOption{append}{\ETE@prependfalse} +\DeclareStringOption{outdir} +\ProcessKeyvalOptions* +\newcommand*{\epstopdfsetup}{\setkeys{ETE}} +% \end{macrocode} +% +% \subsection{Make and verbose} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdffilemoddate\endcsname\relax + \def\ETE@Make#1#2{% + \ifETE@update + \ETE@WarnModDate + \fi + \@firstofone + }% + \def\ETE@WarnModDate{% + \@PackageWarningNoLine{epstopdf}{% + \string\pdffilemoddate\space is not available,\MessageBreak + option `update' will be ignored% + }% + \global\let\ETE@WarnModDate\relax + }% + \def\ETE@FileInfo#1#2{#1 file: <#2>}% +\else + \def\ETE@Make#1#2{% + \ifETE@update + \ifnum\pdfstrcmp{\pdffilemoddate{#1}}{\pdffilemoddate{#2}}>0 % + \expandafter\expandafter\expandafter\@firstofone + \else + \@PackageInfoNoLine{epstopdf}{% + Output file is already uptodate% + }% + \expandafter\expandafter\expandafter\@gobble + \fi + \else + \expandafter\@firstofone + \fi + }% + \def\ETE@FileInfo#1#2{% + #1 file: <#2>% + \expandafter\ETE@Date\pdffilemoddate{#2}\@nil + \expandafter\ETE@Size\pdffilesize{#2}\@nil + }% + \def\ETE@Date#1\@nil{% + \ifx\\#1\\% + \else + \ETE@@Date#1\@nil + \fi + }% + \def\ETE@@Date#1:#2#3#4#5#6#7#8#9{% + \MessageBreak + \@spaces\space\space\space date: #2#3#4#5-#6#7-#8#9 % + \ETE@@Time + }% + \def\ETE@@Time#1#2#3#4#5#6#7\@nil{% + #1#2:#3#4:#5#6% + }% + \def\ETE@Size#1\@nil{% + \ifx\\#1\\% + \else + \MessageBreak + \@spaces\space\space\space size: #1 bytes% + \fi + }% +\fi +% \end{macrocode} +% % \subsection{Adding conversion support} % % Patch \cs{Gin@setfile} to execute |#3|, if it contains % a command. % \begin{macrocode} -\let\ETEorg@Gin@setfile\Gin@setfile +\expandafter\ifx\csname ETE@OrgGin@setfile\endcsname\relax + \let\ETE@OrgGin@setfile\Gin@setfile +\else + \@PackageError{epstopdf}{% + Command \string\ETE@OrgGin@setfile\space + already defined.\MessageBreak + }{% + Probably some package has included the code of this package% + \MessageBreak + instead of using \string\RequirePackage{epstopdf}.% + \MessageBreak + \@ehc + }% +\fi \def\Gin@setfile#1#2#3{% \if`\@car #3\relax\@nil - \immediate\write18{\@cdr #3\@empty\@nil}% - \ETEorg@Gin@setfile{#1}{#2}{\Gin@base #2}% + \begingroup + \def\GraphicsType{#1}% + \def\GraphicsRead{#2}% + \ifx\Gin@ext\relax + \def\SourceFile{\Gin@base\Gin@eext}% + \else + \def\SourceFile{\Gin@base\Gin@ext}% + \fi + \let\OutputDirectory\ETE@outdir + \ifx\OutputDirectory\@empty + \def\OutputFile{\Gin@base#2}% + \else + \begingroup + \filename@parse{\Gin@base#2}% + \edef\x{\endgroup + \def\noexpand\OutputFile{% + \OutputDirectory\filename@base#2% + }% + }% + \x + \fi + \edef\CommandLine{\@cdr#3\@empty\@nil}% + \ifETE@verbose + \@PackageInfo{epstopdf}{% + \ETE@FileInfo{Source}\SourceFile\MessageBreak + \ETE@FileInfo{Output}\OutputFile\MessageBreak + Command: <\CommandLine>\MessageBreak + \string\includegraphics + }% + \fi + \ETE@Make\SourceFile\OutputFile{% + \immediate\write18{\CommandLine}% + \ifETE@verbose + \@PackageInfoNoLine{epstopdf}{% + \ETE@FileInfo{Result}\OutputFile + }% + \fi + }% + \edef\x{\endgroup + \ifx\OutputDirectory\@empty + \else + \def\noexpand\Gin@base{% + \OutputDirectory\noexpand\filename@base + }% + \fi + \noexpand\ETE@OrgGin@setfile{% + \GraphicsType + }{% + \GraphicsRead + }{% + \OutputFile + }% + }% + \x \else - \ETEorg@Gin@setfile{#1}{#2}{#3}% + \ETE@OrgGin@setfile{#1}{#2}{#3}% \fi } % \end{macrocode} % -% Adding .eps at the end of the list of extensions, -% defined by \cs{GraphicsExtensions}. +% \cs{DeclareGraphicsRule} for .eps % \begin{macrocode} -\@ifundefined{Gin@extensions}{% - \def\Gin@extensions{.eps}% -}{% - \expandafter\ifx\expandafter\indent\Gin@extensions\indent - \def\Gin@extensions{.eps}% +\expandafter\ifx\csname Gin@rule@.eps\endcsname\relax +\else + \@PackageInfo{epstopdf}{Overwriting graphics rule for `.eps'}% +\fi +\@namedef{Gin@rule@.eps}#1{{pdf}{.pdf}{`\ETE@epstopdf{#1}}} +\def\ETE@epstopdf#1{% + epstopdf % + \ifx\OutputDirectory\@empty \else - \expandafter\def\expandafter\Gin@extensions\expandafter{% - \Gin@extensions,.eps% - }% + --outfile=\OutputFile\space \fi + #1% +} +% \end{macrocode} +% +% \begin{macrocode} +\ifETE@prepend + \expandafter\PrependGraphicsExtensions +\else + \expandafter\AppendGraphicsExtensions +\fi +{.eps} +\let\ETE@prepend\@undefined +\DeclareVoidOption{prepend}{% + \PrependGraphicsExtensions{.eps}% +} +\let\ETE@append\@undefined +\DeclareVoidOption{append}{% + \AppendGraphicsExtensions{.eps}% } % \end{macrocode} % -% \cs{DeclareGraphicsRule} for .eps % \begin{macrocode} -\@namedef{Gin@rule@.eps}#1{{pdf}{.pdf}{`epstopdf #1}} +\InputIfFileExists{epstopdf.cfg}{}{} % \end{macrocode} % % \begin{macrocode} +\ETE@AtEnd %</package> % \end{macrocode} % +% \section{Test} +% +% \subsection{Preface for standard catcode check} +% +% \begin{macrocode} +%<*test1> +\input miniltx.tex\relax +\def\Gin@driver{pdftex.def} +\input graphicx.sty\relax +\resetatcatcode +%</test1> +% \end{macrocode} +% +% \subsection{Catcode checks for loading} +% +% \begin{macrocode} +%<*test1> +% \end{macrocode} +% \begin{macrocode} +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input epstopdf.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +% \end{macrocode} +% \begin{macrocode} +%</test1> +% \end{macrocode} +% % \section{Installation} % % \subsection{Download} @@ -529,6 +883,7 @@ and the derived files % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} % epstopdf.sty & tex/latex/oberdiek/epstopdf.sty\\ % epstopdf.pdf & doc/latex/oberdiek/epstopdf.pdf\\ +% epstopdf-test1.tex & doc/latex/oberdiek/epstopdf-test1.tex\\ % epstopdf.dtx & source/latex/oberdiek/epstopdf.dtx\\ % \end{tabular}^^A % }^^A @@ -676,6 +1031,22 @@ and the derived files % \item % Documentation rewritten and extended. % \end{Version} +% \begin{Version}{2007/10/02 v1.5} +% \item +% New option \xoption{update}: If the converted file exists, it will be only +% converted if it is out of date. +% \item +% Updating the extension list is delegated to package \xpackage{grfext}. +% Fine tuning is done by the new options \xoption{append}, \xoption{prepend}. +% \item +% New option \xoption{outdir} for changing the output directory. +% \item +% New option \xoption{verbose}. +% \item +% \cs{SourceFile} and \cs{OutputFile} introduced. +% \item +% Configuration file support added. +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/flags.dtx b/Master/texmf-dist/source/latex/oberdiek/flags.dtx index 234d4ea98de..39631fb0ea9 100644 --- a/Master/texmf-dist/source/latex/oberdiek/flags.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/flags.dtx @@ -66,7 +66,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: flags 2007/03/07 v0.3 Flag setting in bit fields (HO)} +\Msg{* Package: flags 2007/09/30 v0.4 Flag setting in bit fields (HO)} \Msg{************************************************************************} \keepsilent @@ -126,7 +126,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{flags.drv}% - [2007/03/07 v0.3 Flag setting in bit fields (HO)]% + [2007/09/30 v0.4 Flag setting in bit fields (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -156,7 +156,7 @@ and the derived files % \GetFileInfo{flags.drv} % % \title{The \xpackage{flags} package} -% \date{2007/03/07 v0.3} +% \date{2007/09/30 v0.4} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -171,6 +171,17 @@ and the derived files % % \section{Documentation} % +% A new powerful package \xpackage{bitset} is written by me +% and supersedes this package: +% \begin{itemize} +% \item The bit range is not restricted to 31 bits, only index +% numbers are objected to \TeX's number limit. +% \item Many more operations are available. +% \item No dependency of \eTeX. +% \end{itemize} +% Therefore I consider this package as obsolete and +% have stopped the development of this package. +% % \subsection{User interface} % % Flag positions are one-based, thus the flag position must be @@ -238,7 +249,7 @@ and the derived files %<*package> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{flags}% - [2007/03/07 v0.3 Flag setting in bit fields (HO)]% + [2007/09/30 v0.4 Flag setting in bit fields (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -629,6 +640,11 @@ and the derived files % Raise an error if position is not positive in case of % \cs{setflag} and \cs{clearflag}. % \end{Version} +% \begin{Version}{2007/09/30 v0.4} +% \item +% Package is deprecated because of new more powerful +% package \xpackage{bitset}. +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/grfext.dtx b/Master/texmf-dist/source/latex/oberdiek/grfext.dtx new file mode 100644 index 00000000000..643ed026f97 --- /dev/null +++ b/Master/texmf-dist/source/latex/oberdiek/grfext.dtx @@ -0,0 +1,974 @@ +% \iffalse meta-comment +% +% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 of this license or (at your option) any later +% version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status "maintained". +% +% This Current Maintainer of this work is Heiko Oberdiek. +% +% This work consists of the main source file grfext.dtx +% and the derived files +% grfext.sty, grfext.pdf, grfext.ins, grfext.drv, +% grfext-test1.tex, grfext-test2.tex. +% +% Distribution: +% CTAN:macros/latex/contrib/oberdiek/grfext.dtx +% CTAN:macros/latex/contrib/oberdiek/grfext.pdf +% +% Unpacking: +% (a) If grfext.ins is present: +% tex grfext.ins +% (b) Without grfext.ins: +% tex grfext.dtx +% (c) If you insist on using LaTeX +% latex \let\install=y\input{grfext.dtx} +% (quote the arguments according to the demands of your shell) +% +% Documentation: +% (a) If grfext.drv is present: +% latex grfext.drv +% (b) Without grfext.drv: +% latex grfext.dtx; ... +% The class ltxdoc loads the configuration file ltxdoc.cfg +% if available. Here you can specify further options, e.g. +% use A4 as paper format: +% \PassOptionsToClass{a4paper}{article} +% +% Programm calls to get the documentation (example): +% pdflatex grfext.dtx +% makeindex -s gind.ist grfext.idx +% pdflatex grfext.dtx +% makeindex -s gind.ist grfext.idx +% pdflatex grfext.dtx +% +% Installation: +% TDS:tex/latex/oberdiek/grfext.sty +% TDS:doc/latex/oberdiek/grfext.pdf +% TDS:doc/latex/oberdiek/grfext-test1.tex +% TDS:doc/latex/oberdiek/grfext-test2.tex +% TDS:source/latex/oberdiek/grfext.dtx +% +%<*ignore> +\begingroup + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase 0\ifx\install y1\fi\expandafter + \ifx\csname processbatchFile\endcsname\relax\else1\fi + \ifx\fmtname\x\else 1\fi\relax +\else\csname fi\endcsname +%</ignore> +%<*install> +\input docstrip.tex +\Msg{************************************************************************} +\Msg{* Installation} +\Msg{* Package: grfext 2007/09/30 v1.0 Managing graphics extensions (HO)} +\Msg{************************************************************************} + +\keepsilent +\askforoverwritefalse + +\preamble + +This is a generated file. + +Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in + http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. + +This work has the LPPL maintenance status "maintained". + +This Current Maintainer of this work is Heiko Oberdiek. + +This work consists of the main source file grfext.dtx +and the derived files + grfext.sty, grfext.pdf, grfext.ins, grfext.drv, + grfext-test1.tex, grfext-test2.tex. + +\endpreamble + +\generate{% + \file{grfext.ins}{\from{grfext.dtx}{install}}% + \file{grfext.drv}{\from{grfext.dtx}{driver}}% + \usedir{tex/latex/oberdiek}% + \file{grfext.sty}{\from{grfext.dtx}{package}}% + \usedir{doc/latex/oberdiek}% + \file{grfext-test1.tex}{\from{grfext.dtx}{test1}}% + \file{grfext-test2.tex}{\from{grfext.dtx}{test2}}% +} + +\obeyspaces +\Msg{************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file into a directory searched by TeX:} +\Msg{*} +\Msg{* grfext.sty} +\Msg{*} +\Msg{* To produce the documentation run the file `grfext.drv'} +\Msg{* through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{************************************************************************} + +\endbatchfile +%</install> +%<*ignore> +\fi +%</ignore> +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{grfext.drv}% + [2007/09/30 v1.0 Managing graphics extensions (HO)]% +\documentclass{ltxdoc} +\usepackage{holtxdoc} +\begin{document} + \DocInput{grfext.dtx}% +\end{document} +%</driver> +% \fi +% +% \CheckSum{531} +% +% \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 +% Lower-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 +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \GetFileInfo{grfext.drv} +% +% \title{The \xpackage{grfext} package} +% \date{2007/09/30 v1.0} +% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} +% +% \maketitle +% +% \begin{abstract} +% This package provides macros for adding and reordering +% graphics extensions of package \xpackage{graphics}. +% \end{abstract} +% +% \tableofcontents +% +% \section{Documentation} +% +% \subsection{Introduction} +% +% If you are not familiar with \LaTeX's graphics bundle, please +% read its documentation \xfile{grffile} \cite{graphics}. +% The bundle contains two packages for graphics inclusion: +% \xpackage{graphics} and \xpackage{graphicx}. The first one +% is loaded by the second one that adds a key value interface. +% +% Graphics files are included in both cases by macro +% \cs{includegraphics}. The file name extension can be omitted. +% Then the graphics package goes through a list of known +% extensions until it finds the graphics file. This extension list +% is set by \cs{DeclareGraphicsExtensions}. The previous contents +% of the list is overwritten. +% +% \subsection{User interface} +% +% This package \xpackage{grfext} provides macros that adds entries +% to the list or remove them. The list may be empty or even +% undefined before. It is always defined afterwards, but can +% be empty (especially after removing entries). +% +% \begin{declcs}{AppendGraphicsExtensions} * \M{ext-list}\\ +% \cs{PrependGraphicsExtensions} * \M{ext-list} +% \end{declcs} +% The argument \meta{ext-list} is a comma separated list whose +% entries are file name extensions including the dot. +% But first the entries are removed from +% \xpackage{graphics}' extension list to avoid multiple +% occurences of the same extension. +% +% Then macro \cs{AppendGraphicsExtensions} adds the entries +% after the end of \xpackage{graphics}' list, whereas +% macro \cs{PrependGraphicsExtensions} puts them in front +% of the list. +% The order matters if a graphics file is available in +% different acceptable formats. Then the first extension +% wins. +% +% The star version of these commands only adds an extensions, +% if a specific graphics rule exists for that extension. +% +% \begin{declcs}{RemoveGraphicsExtensions} \M{ext-list} +% \end{declcs} +% All occurences of file extensions in \meta{ext-list} are +% removed from \xpackage{graphics}' extension list. +% +% \subsection{Package loading} +% +% The package does not define any options. It is loaded +% as usual in \LaTeX, e.g.: +% \begin{quote} +% |\usepackage{grfext}| +% \end{quote} +% +% \begin{declcs}{PrintGraphicsExtensions} +% \end{declcs} +% Macro \cs{PrintGraphicsExtensions} writes the current +% graphics extensions list in the \xfile{.log} file. +% The macros described before do this automatically +% after their operation. +% +% \subsection{\plainTeX} +% +% \LaTeX's graphics packages can also be used with \plainTeX. +% The necessary basic \LaTeX\ macros are defined in +% \xfile{miniltx.tex}. This package \xpackage{grfext} also +% relies on it. Example: +%\begin{quote} +%\begin{verbatim} +%\input miniltx.tex\relax +%\def\Gin@driver{pdftex.def} +%\input graphicx.sty\relax +%\input grfext.sty\relax +%\resetatcatcode +%\end{verbatim} +%\end{quote} +% +% \StopEventually{ +% } +% +% \section{Implementation} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% \subsection{Relead check and 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@grfext.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{grfext}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +% \end{macrocode} +% Package identification: +% \begin{macrocode} +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@grfext.sty\endcsname +\ProvidesPackage{grfext}% + [2007/09/30 v1.0 Managing graphics extensions (HO)] +% \end{macrocode} +% +% \subsection{Catcodes} +% +% \begin{macrocode} +\expandafter\edef\csname grfext@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\grfext@AtEnd{% + \grfext@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\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}% ] +% \end{macrocode} +% +% \subsection{\plainTeX} +% +% \begin{macro}{\@expandtwoargs} +% Requirement is \xfile{miniltx.tex}, but we need also +% \LaTeX's \cs{@expandtwoargs}. +% \begin{macrocode} +\@ifundefined{@expandtwoargs}{% + \def\@expandtwoargs#1#2#3{% + \edef\reserved@a{\noexpand#1{#2}{#3}}% + \reserved@a + }% +}{} +% \end{macrocode} +% \end{macro} +% +% \subsection{Add} +% +% \begin{macro}{\AppendGraphicsExtensions} +% \begin{macrocode} +\newcommand*{\AppendGraphicsExtensions}{% + \@ifundefined{Gin@extensions}{% + \let\Gin@extensions\@empty + }{}% + \@ifstar{\grfext@Append\grfext@Check}{\grfext@Append\grfext@@Add}% +}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\grfext@Append} +% \begin{macrocode} +\def\grfext@Append#1#2{% + \let\grfext@Print\@gobble + \edef\grfext@next{% + \noexpand\grfext@Add\noexpand#1{% + \zap@space#2 \@empty + }{\noexpand\Gin@extensions,}{}% + }% + \grfext@next + \let\grfext@Print\grfext@@Print + \grfext@Print\AppendGraphicsExtensions +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrependGraphicsExtensions} +% \begin{macrocode} +\newcommand*{\PrependGraphicsExtensions}{% + \@ifundefined{Gin@extensions}{% + \let\Gin@extensions\@empty + }{}% + \@ifstar{\grfext@Prepend\grfext@Check}{\grfext@Prepend\grfext@@Add}% +}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\grfext@Prepend} +% \begin{macrocode} +\def\grfext@Prepend#1#2{% + \let\grfext@Print\@gobble + \edef\grfext@next{% + \noexpand\grfext@Add\noexpand#1{% + \zap@space#2 \@empty + }{}{,\noexpand\Gin@extensions}% + }% + \grfext@next + \let\grfext@Print\grfext@@Print + \grfext@Print\PrependGraphicsExtensions +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\grfext@Add} +% \begin{macrocode} +\def\grfext@Add#1#2{% + #1{#2}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\grfext@@Add} +% \begin{macrocode} +\def\grfext@@Add#1#2#3{% + \RemoveGraphicsExtensions{#1}% + \ifx\Gin@extensions\@empty + \def\Gin@extensions{#1}% + \else + \edef\Gin@extensions{#2#1#3}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Check} +% +% \begin{macro}{\grfext@Check} +% \begin{macrocode} +\def\grfext@Check#1{% + \let\grfext@tmp\@empty + \@for\grfext@ext:=#1\do{% + \@ifundefined{Gin@rule@\grfext@ext}{% + }{% + \ifx\grfext@tmp\@empty + \let\grfext@tmp\grfext@ext + \else + \edef\grfext@tmp{\grfext@tmp,\grfext@ext}% + \fi + }% + }% + \ifx\grfext@tmp\@empty + \def\grfext@next##1##2{}% + \else + \edef\grfext@next{% + \noexpand\grfext@@Add{\grfext@tmp}% + }% + \fi + \grfext@next +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Remove} +% +% \begin{macro}{\RemoveGraphicsExtensions} +% \begin{macrocode} +\newcommand*{\RemoveGraphicsExtensions}[1]{% + \@ifundefined{Gin@extensions}{% + \def\Gin@extensions{}% + }{% + \edef\grfext@tmp{\zap@space#1 \@empty}% + \@for\grfext@ext:=\grfext@tmp\do{% + \def\grfext@next{% + \let\grfext@tmp\Gin@extensions + \@expandtwoargs + \@removeelement\grfext@ext\Gin@extensions\Gin@extensions + \ifx\grfext@tmp\Gin@extensions + \let\grfext@next\relax + \fi + \grfext@next + }% + \grfext@next + }% + }% + \grfext@Print\RemoveGraphicsExtensions +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Print} +% +% \begin{macrocode} +\RequirePackage{infwarerr}[2007/09/09] +% \end{macrocode} +% +% \begin{macro}{\PrintGraphicsExtensions} +% \begin{macrocode} +\def\PrintGraphicsExtensions{% + \grfext@Print\PrintGraphicsExtensions +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\grfext@Print} +% \begin{macrocode} +\def\grfext@Print#1{% + \@PackageInfo{grfext}{% + Graphics extension search list:\MessageBreak + \@ifundefined{Gin@extensions}{% + <unavailable>% + }{% + [\Gin@extensions]% + }\MessageBreak + \string#1% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\grfext@@Print} +% \begin{macrocode} +\let\grfext@@Print\grfext@Print +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\grfext@AtEnd +%</package> +% \end{macrocode} +% +% \section{Test} +% +% Load \xfile{miniltx} for standard catcode test. +% \begin{macrocode} +%<*test1> +\input miniltx.tex\relax +\resetatcatcode +%</test1> +% \end{macrocode} +% +% \subsection{Catcode checks for loading} +% +% \begin{macrocode} +%<*test1> +% \end{macrocode} +% \begin{macrocode} +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input grfext.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +% \end{macrocode} +% \begin{macrocode} +%</test1> +% \end{macrocode} +% +% \subsection{Macro tests} +% +% \subsubsection{Preamble} +% +% \begin{macrocode} +%<*test2> +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +\usepackage[pdftex]{graphics} +\usepackage{grfext}[2007/09/30] +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +\makeatletter +% \end{macrocode} +% +% \subsubsection{Detection of unwanted space} +% +% \begin{macrocode} +\let\orig@qstest\qstest +\let\orig@endqstest\endqstest +\def\qstest#1#2{% + \orig@qstest{#1}{#2}% + \setbox0\hbox\bgroup\begingroup\ignorespaces +} +\def\endqstest{% + \endgroup\egroup + \Expect*{\the\wd0}{0.0pt}% + \orig@endqstest +} +% \end{macrocode} +% +% \subsubsection{Generic test macros} +% +% \begin{macrocode} +\def\Test{\@ifnextchar\bgroup\TestInitList\TestInitCmd}% +\def\TestInitList#1{% + \def\Gin@extensions{#1}% + \@Test +} +\def\TestInitCmd#1{% + \let\Gin@extensions#1\relax + \@Test +} +\def\@Test#1#2{% + \TestCmd{#1}% + \expandafter\Expect\expandafter*{\Gin@extensions}{#2}% +} +% \end{macrocode} +% +% \subsubsection{Test for \cs{AppendGraphicsExtensions}} +% +% \begin{macrocode} +\begin{qstest}{AppendGraphicsExtensions}{AppendGraphicsExtensions} + \let\TestCmd\AppendGraphicsExtensions + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.foo,.test}% + \Test{.foo,.bar}{.test}{.foo,.bar,.test}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.foo,.test}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar,.test}% + \Test{.foo}{.test,.bar}{.foo,.test,.bar}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \Test{.foo}{ .test ,.bar , .x, .y }{.foo,.test,.bar,.x,.y}% + \def\TestCmd{\AppendGraphicsExtensions*}% + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.test}{.test}{.test}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.test,.bar}% + \Test{.foo}{.test,.bar}{.foo}% + \Test{.foo}{.test,.foo}{.foo}% + \DeclareGraphicsRule{.test}{test}{.test}{}% + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.foo,.test}% + \Test{.foo,.bar}{.test}{.foo,.bar,.test}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.foo,.test}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar,.test}% + \Test{.foo}{.test,.bar}{.foo,.test}% + \Test{.foo}{.test,.foo}{.foo,.test}% + \DeclareGraphicsRule{.bar}{bar}{.bar}{}% + \Test{.foo}{.test,.bar}{.foo,.test,.bar}% + \Test{.bar}{.test,.bar}{.test,.bar}% + \Test{.bar}{.bar,.test}{.bar,.test}% +\end{qstest} +% \end{macrocode} +% +% \subsubsection{Test for \cs{PrependGraphicsExtensions}} +% +% \begin{macrocode} +\begin{qstest}{PrependGraphicsExtensions}{PrependGraphicsExtensions} + \let\TestCmd\PrependGraphicsExtensions + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.test,.foo}% + \Test{.foo,.bar}{.test}{.test,.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.test,.foo}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.test,.foo,.bar}% + \Test{.foo}{.test,.bar}{.test,.bar,.foo}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \Test{.foo}{ .test ,.bar , .x, .y }{.test,.bar,.x,.y,.foo}% + \def\TestCmd{\PrependGraphicsExtensions*}% + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.test}{.test}{.test}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.foo,.test}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.test,.bar}% + \DeclareGraphicsRule{.test}{test}{.test}{}% + \Test\@undefined{.test}{.test}% + \Test\relax{.test}{.test}% + \Test{}{.test}{.test}% + \Test{.foo}{.test}{.test,.foo}% + \Test{.foo,.bar}{.test}{.test,.foo,.bar}% + \Test{.test}{.test}{.test}% + \Test{.foo,.test}{.test}{.test,.foo}% + \Test{.test,.foo}{.test}{.test,.foo}% + \Test{.foo,.test,.bar}{.test}{.test,.foo,.bar}% + \Test{.foo}{.test,.bar}{.test,.foo}% + \Test{.foo}{.test,.foo}{.test,.foo}% + \DeclareGraphicsRule{.bar}{bar}{.bar}{}% + \Test{.foo}{.test,.bar}{.test,.bar,.foo}% + \Test{.bar}{.test,.bar}{.test,.bar}% + \Test{.bar}{.bar,.test}{.bar,.test}% +\end{qstest} +% \end{macrocode} +% +% \subsubsection{Test for \cs{RemoveGraphicsExtensions}} +% +% \begin{macrocode} +\begin{qstest}{RemoveGraphicsExtensions}{RemoveGraphicsExtensions} + \let\TestCmd\RemoveGraphicsExtensions + \Test\@undefined{.test}{}% + \Test\relax{.test}{}% + \Test{}{.test}{}% + \Test{.foo}{.test}{.foo}% + \Test{.foo,.bar}{.test}{.foo,.bar}% + \Test{.test}{.test}{}% + \Test{.foo,.test}{.test}{.foo}% + \Test{.test,.foo}{.test}{.foo}% + \Test{.foo,.test,.bar}{.test}{.foo,.bar}% + \Test{.test,.test}{.test}{}% + \Test{.foo,.test,.bar,.test,.test,.bar}{.test}{.foo,.bar,.bar}% + \Test{.foo,.test,.bar,.foo,.test,.bar}{.test,.bar}{.foo,.foo}% + \Test{.foo,.test,.bar,.foo,.test,.bar}{ .test , .bar }{.foo,.foo}% +\end{qstest} +% \end{macrocode} +% +% \begin{macrocode} +\begin{document} +\end{document} +%</test2> +% \end{macrocode} +% +% \section{Installation} +% +% \subsection{Download} +% +% \paragraph{Package.} This package is available on +% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}: +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/grfext.dtx}] The source file. +% \item[\CTAN{macros/latex/contrib/oberdiek/grfext.pdf}] Documentation. +% \end{description} +% +% +% \paragraph{Bundle.} All the packages of the bundle `oberdiek' +% are also available in a TDS compliant ZIP archive. There +% the packages are already unpacked and the documentation files +% are generated. The files and directories obey the TDS standard. +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/oberdiek-tds.zip}] +% \end{description} +% \emph{TDS} refers to the standard ``A Directory Structure +% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories +% with \xfile{texmf} in their name are usually organized this way. +% +% \subsection{Bundle installation} +% +% \paragraph{Unpacking.} Unpack the \xfile{oberdiek-tds.zip} in the +% TDS tree (also known as \xfile{texmf} tree) of your choice. +% Example (linux): +% \begin{quote} +% |unzip oberdiek-tds.zip -d ~/texmf| +% \end{quote} +% +% \paragraph{Script installation.} +% Check the directory \xfile{TDS:scripts/oberdiek/} for +% scripts that need further installation steps. +% Package \xpackage{attachfile2} comes with the Perl script +% \xfile{pdfatfi.pl} that should be installed in such a way +% that it can be called as \texttt{pdfatfi}. +% Example (linux): +% \begin{quote} +% |chmod +x scripts/oberdiek/pdfatfi.pl|\\ +% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/| +% \end{quote} +% +% \subsection{Package installation} +% +% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting +% \docstrip\ archive. The files are extracted by running the +% \xfile{.dtx} through \plainTeX: +% \begin{quote} +% \verb|tex grfext.dtx| +% \end{quote} +% +% \paragraph{TDS.} Now the different files must be moved into +% the different directories in your installation TDS tree +% (also known as \xfile{texmf} tree): +% \begin{quote} +% \def\t{^^A +% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} +% grfext.sty & tex/latex/oberdiek/grfext.sty\\ +% grfext.pdf & doc/latex/oberdiek/grfext.pdf\\ +% grfext-test1.tex & doc/latex/oberdiek/grfext-test1.tex\\ +% grfext-test2.tex & doc/latex/oberdiek/grfext-test2.tex\\ +% grfext.dtx & source/latex/oberdiek/grfext.dtx\\ +% \end{tabular}^^A +% }^^A +% \sbox0{\t}^^A +% \ifdim\wd0>\linewidth +% \begingroup +% \advance\linewidth by\leftmargin +% \advance\linewidth by\rightmargin +% \edef\x{\endgroup +% \def\noexpand\lw{\the\linewidth}^^A +% }\x +% \def\lwbox{^^A +% \leavevmode +% \hbox to \linewidth{^^A +% \kern-\leftmargin\relax +% \hss +% \usebox0 +% \hss +% \kern-\rightmargin\relax +% }^^A +% }^^A +% \ifdim\wd0>\lw +% \sbox0{\small\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\footnotesize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\scriptsize\t}^^A +% \ifdim\wd0>\linewidth +% \ifdim\wd0>\lw +% \sbox0{\tiny\t}^^A +% \ifdim\wd0>\linewidth +% \lwbox +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \else +% \lwbox +% \fi +% \else +% \usebox0 +% \fi +% \end{quote} +% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's +% TDS installing feature, then some files can already be in the right +% place, see the documentation of \docstrip. +% +% \subsection{Refresh file name databases} +% +% If your \TeX~distribution +% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh +% these. For example, \teTeX\ users run \verb|texhash| or +% \verb|mktexlsr|. +% +% \subsection{Some details for the interested} +% +% \paragraph{Attached source.} +% +% The PDF documentation on CTAN also includes the +% \xfile{.dtx} source file. It can be extracted by +% AcrobatReader 6 or higher. Another option is \textsf{pdftk}, +% e.g. unpack the file into the current directory: +% \begin{quote} +% \verb|pdftk grfext.pdf unpack_files output .| +% \end{quote} +% +% \paragraph{Unpacking with \LaTeX.} +% The \xfile{.dtx} chooses its action depending on the format: +% \begin{description} +% \item[\plainTeX:] Run \docstrip\ and extract the files. +% \item[\LaTeX:] Generate the documentation. +% \end{description} +% If you insist on using \LaTeX\ for \docstrip\ (really, +% \docstrip\ does not need \LaTeX), then inform the autodetect routine +% about your intention: +% \begin{quote} +% \verb|latex \let\install=y\input{grfext.dtx}| +% \end{quote} +% Do not forget to quote the argument according to the demands +% of your shell. +% +% \paragraph{Generating the documentation.} +% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate +% the documentation. The process can be configured by the +% configuration file \xfile{ltxdoc.cfg}. For instance, put this +% line into this file, if you want to have A4 as paper format: +% \begin{quote} +% \verb|\PassOptionsToClass{a4paper}{article}| +% \end{quote} +% An example follows how to generate the +% documentation with pdf\LaTeX: +% \begin{quote} +%\begin{verbatim} +%pdflatex grfext.dtx +%makeindex -s gind.ist grfext.idx +%pdflatex grfext.dtx +%makeindex -s gind.ist grfext.idx +%pdflatex grfext.dtx +%\end{verbatim} +% \end{quote} +% +% \begin{thebibliography}{9} +% +% \bibitem{graphics} +% David Carlisle, Sebastian Rahtz: \textit{The \xpackage{graphics} package}; +% 2006/02/20 v1.0o; +% \CTAN{macros/latex/required/graphics/graphics.dtx}. +% +% \end{thebibliography} +% +% \begin{History} +% \begin{Version}{2007/09/30 v1.0} +% \item +% First public version, +% \end{Version} +% \end{History} +% +% \PrintIndex +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/oberdiek/intcalc.dtx b/Master/texmf-dist/source/latex/oberdiek/intcalc.dtx index 2cef807d937..30cee2ecbee 100644 --- a/Master/texmf-dist/source/latex/oberdiek/intcalc.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/intcalc.dtx @@ -72,7 +72,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: intcalc 2007/09/09 v1.0 Expandable integer calculations (HO)} +\Msg{* Package: intcalc 2007/09/27 v1.1 Expandable integer calculations (HO)} \Msg{************************************************************************} \keepsilent @@ -112,7 +112,7 @@ and the derived files \usedir{doc/latex/oberdiek}% \file{intcalc-test1.tex}{\from{intcalc.dtx}{test1}}% \file{intcalc-test2.tex}{\from{intcalc.dtx}{test2,etex}}% - \file{intcalc-test3.tex}{\from{intcalc.dtx}{test3,noetex}}% + \file{intcalc-test3.tex}{\from{intcalc.dtx}{test2,noetex}}% \file{intcalc-test4.tex}{\from{intcalc.dtx}{test4,etex}}% } @@ -139,7 +139,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{intcalc.drv}% - [2007/09/09 v1.0 Expandable integer calculations (HO)]% + [2007/09/27 v1.1 Expandable integer calculations (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \usepackage{wasysym} @@ -182,7 +182,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{2665} +% \CheckSum{3045} % % \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 @@ -203,7 +203,7 @@ and the derived files % \GetFileInfo{intcalc.drv} % % \title{The \xpackage{intcalc} package} -% \date{2007/09/09 v1.0} +% \date{2007/09/27 v1.1} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -227,7 +227,7 @@ and the derived files % The operations have the form of macros that take one or % two integers as parameter and return the integer result. % The macro name is a three letter operation name prefixed -% by the package name, e.g. \cs{intcalcAdd}{10}{43} returns +% by the package name, e.g. \cs{intcalcAdd}|{10}{43}| returns % |53|. % % The macros are fully expandable, exactly two expansion @@ -324,6 +324,19 @@ and the derived files % \end{cases} % \end{gather*} % +% \subsubsection{\op{Num}} +% +% \begin{declcs}{intcalcNum} \M{x} +% \end{declcs} +% Macro \cs{intcalcNum} converts its argument to a normalized integer +% number without unnecessary leading zeros or signs. +% The result matches the regular expression: +%\begin{quote} +%\begin{verbatim} +%0|-?[1-9][0-9]* +%\end{verbatim} +%\end{quote} +% % \subsubsection{\op{Inv}, \op{Abs}, \op{Sgn}} % % \begin{declcs}{intcalcInv} \M{x} @@ -449,18 +462,18 @@ and the derived files % \end{declcs} % Macro \cs{intcalcShl} implements shifting to the left that % means the number is multiplied by two. Overflow is possible. -% Negative values are not permitted. +% The sign is preserved. % \begin{gather*} -% \opShl(x) \Def x*2\qquad\text{for $x\geq0$} +% \opShl(x) \Def x*2 % \end{gather*} % % \begin{declcs}{intcalcShr} \M{x} % \end{declcs} % Macro \cs{intcalcShr} implements shifting to the right. % That is equivalent to an integer division by two. -% Negative values are not permitted. +% The sign is preserved. % \begin{gather*} -% \opShr(x) \Def \opInt(x/2)\qquad\text{for $x\geq0$} +% \opShr(x) \Def \opInt(x/2) % \end{gather*} % % \subsubsection{\op{Mul}, \op{Sqr}, \op{Fac}, \op{Pow}} @@ -525,6 +538,59 @@ and the derived files % 0 \leq \opMod(x,y) < y\qquad\text{for $y\geq0$} % \end{gather*} % +% \subsection{Interface for programmer} +% +% If the programmer can ensure some more properties about +% the arguments of the operations, then the following +% macros are a little more efficient. +% +% In general numbers must obey the following constraints: +% \begin{itemize} +% \item Plain number: digit tokens only, no command tokens. +% \item Non-negative. Signs are forbidden. +% \item Arguments and the result must fit in range |0..2147483647|. +% \item Delimited by exclamation mark. Curly braces +% around the number are not allowed and will +% break the code. +% \end{itemize} +% +% \begin{declcs}{IntCalcInc} \meta{number} |!| +% \end{declcs} +% Incrementation, range: |0..2147483646|. +% +% \begin{declcs}{IntCalcDec} \meta{number} |!| +% \end{declcs} +% Decrementation, range: |1..2147483647|. +% +% \begin{declcs}{IntCalcAdd} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Addition, $A\geq B$. +% +% \begin{declcs}{IntCalcSub} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Subtraction, $A\geq B$. +% +% \begin{declcs}{IntCalcShl} \meta{number} |!| +% \end{declcs} +% Left shift (multiplication with two), range: |0..1073741823|. +% +% \begin{declcs}{IntCalcShr} \meta{number} |!| +% \end{declcs} +% Right shift (integer division by two). +% +% \begin{declcs}{IntCalcMul} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Multiplication, $A\geq B$. +% +% \begin{declcs}{IntCalcDiv} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Division operation. +% +% \begin{declcs}{IntCalcMod} \meta{number A} |!| \meta{number B} |!| +% \end{declcs} +% Modulo operation. +% +% % \StopEventually{ % } % @@ -592,19 +658,19 @@ and the derived files \fi \expandafter\x\csname ver@intcalc.sty\endcsname \ProvidesPackage{intcalc}% - [2007/09/09 v1.0 Expandable integer calculations (HO)] + [2007/09/27 v1.1 Expandable integer calculations (HO)] % \end{macrocode} % % \subsection{Catcodes} % % \begin{macrocode} -\expandafter\edef\csname IntCalc@AtEnd\endcsname{% +\expandafter\edef\csname InCa@AtEnd\endcsname{% \catcode64 \the\catcode64\relax } \catcode64 11 % @ \def\TMP@EnsureCode#1#2{% - \edef\IntCalc@AtEnd{% - \IntCalc@AtEnd + \edef\InCa@AtEnd{% + \InCa@AtEnd \catcode#1 \the\catcode#1\relax }% \catcode#1 #2\relax @@ -622,26 +688,20 @@ and the derived files \TMP@EnsureCode{62}{12}% > \TMP@EnsureCode{63}{14}% ? (comment!) \begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname IntCalc@TestMode\endcsname\relax +\expandafter\ifx\csname InCa@TestMode\endcsname\relax \else \catcode63=9 % ? (ignore) \fi -? \let\IntCalc@@TestMode\IntCalc@TestMode +? \let\InCa@@TestMode\InCa@TestMode % \end{macrocode} % % \subsection{Macros independent of \eTeX} % -% \begin{macro}{\IntCalc@Space} -% \begin{macrocode} -\def\IntCalc@Space{ } -% \end{macrocode} -% \end{macro} -% % \subsubsection{\op{Abs}, \op{Sgn}} % -% \begin{macro}{\IntCalc@Abs} +% \begin{macro}{\InCa@Abs} % \begin{macrocode} -\def\IntCalc@Abs#1#2!{% +\def\InCa@Abs#1#2!{% \ifx#1-% #2% \else @@ -651,9 +711,9 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@Sgn} +% \begin{macro}{\InCa@Sgn} % \begin{macrocode} -\def\IntCalc@Sgn#1#2!{% +\def\InCa@Sgn#1#2!{% \ifx#1-% -1% \else @@ -669,9 +729,9 @@ and the derived files % % \subsubsection{\op{Min}, \op{Max}, \op{Cmp}} % -% \begin{macro}{\IntCalc@Min} +% \begin{macro}{\InCa@Min} % \begin{macrocode} -\def\IntCalc@Min#1!#2!{% +\def\InCa@Min#1!#2!{% \ifnum#1<#2 % #1% \else @@ -681,9 +741,9 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@Max} +% \begin{macro}{\InCa@Max} % \begin{macrocode} -\def\IntCalc@Max#1!#2!{% +\def\InCa@Max#1!#2!{% \ifnum#1>#2 % #1% \else @@ -693,9 +753,9 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@Cmp} +% \begin{macro}{\InCa@Cmp} % \begin{macrocode} -\def\IntCalc@Cmp#1!#2!{% +\def\InCa@Cmp#1!#2!{% \ifnum#1=#2 % 0% \else @@ -710,13 +770,13 @@ and the derived files % % \subsubsection{\op{Fac}} % -% \begin{macro}{\IntCalc@Fac} +% \begin{macro}{\InCa@Fac} % It does not make much sense to calculate the % faculty by an general algorithm. The allowed % range of arguments is too low because of the % limited integer domain. % \begin{macrocode} -\def\IntCalc@Fac#1!{% +\def\InCa@Fac#1!{% \ifcase#1 1% 0! \or 1% 1! \or 2% 2! @@ -750,12 +810,22 @@ and the derived files \else % \end{macrocode} % +% \subsubsection{\op{Num}} +% +% \begin{macro}{\intcalcNum} +% \begin{macrocode} + \def\intcalcNum#1{% + \the\numexpr#1\relax + }% +% \end{macrocode} +% \end{macro} +% % \subsubsection{\op{Inv}, \op{Abs}, \op{Sgn}} % % \begin{macro}{\intcalcInv} % \begin{macrocode} \def\intcalcInv#1{% - \number-\the\numexpr#1\relax\IntCalc@Space + \number-\intcalcNum{#1} % }% % \end{macrocode} % \end{macro} @@ -763,7 +833,7 @@ and the derived files % \begin{macro}{\intcalcAbs} % \begin{macrocode} \def\intcalcAbs#1{% - \number\expandafter\IntCalc@Abs\the\numexpr#1! % + \number\expandafter\InCa@Abs\the\numexpr#1! % }% % \end{macrocode} % \end{macro} @@ -771,7 +841,7 @@ and the derived files % \begin{macro}{\intcalcSgn} % \begin{macrocode} \def\intcalcSgn#1{% - \number\expandafter\IntCalc@Sgn\the\numexpr#1! % + \number\expandafter\InCa@Sgn\the\numexpr#1! % }% % \end{macrocode} % \end{macro} @@ -781,7 +851,7 @@ and the derived files % \begin{macro}{\intcalcMin} % \begin{macrocode} \def\intcalcMin#1#2{% - \number\expandafter\IntCalc@Min + \number\expandafter\InCa@Min \the\numexpr#1\expandafter!% \the\numexpr#2! % }% @@ -791,7 +861,7 @@ and the derived files % \begin{macro}{\intcalcMax} % \begin{macrocode} \def\intcalcMax#1#2{% - \number\expandafter\IntCalc@Max + \number\expandafter\InCa@Max \the\numexpr#1\expandafter!% \the\numexpr#2! % }% @@ -801,7 +871,7 @@ and the derived files % \begin{macro}{\intcalcCmp} % \begin{macrocode} \def\intcalcCmp#1#2{% - \number\expandafter\IntCalc@Cmp + \number\expandafter\InCa@Cmp \the\numexpr#1\expandafter!\the\numexpr#2! % }% % \end{macrocode} @@ -825,6 +895,21 @@ and the derived files % \end{macrocode} % \end{macro} % +% \begin{macro}{\IntCalcInc} +% \begin{macrocode} + \def\IntCalcInc#1!{% + \the\numexpr#1+1\relax + }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\IntCalcDec} +% \begin{macrocode} + \def\IntCalcDec#1!{% + \the\numexpr#1-1\relax + }% +% \end{macrocode} +% \end{macro} +% % \subsubsection{\op{Add}, \op{Sub}} % % \begin{macro}{\intcalcAdd} @@ -842,40 +927,60 @@ and the derived files }% % \end{macrocode} % \end{macro} + +% \begin{macro}{\IntCalcAdd} +% \begin{macrocode} + \def\IntCalcAdd#1!#2!{% + \the\numexpr#1+#2\relax + }% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\IntCalcSub} +% \begin{macrocode} + \def\IntCalcSub#1!#2!{% + \the\numexpr#1-#2\relax + }% +% \end{macrocode} +% \end{macro} % % \subsubsection{\op{Shl}, \op{Shr}} % % \begin{macro}{\intcalcShl} % \begin{macrocode} \def\intcalcShl#1{% - \number\expandafter\IntCalc@Shl\the\numexpr#1! % + \the\numexpr(#1)*2\relax + }% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\intcalcShr} +% \begin{macrocode} + \def\intcalcShr#1{% + \number\expandafter\InCa@Shr\the\numexpr#1! % }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Shl} +% \begin{macro}{\IntCalcShl} % \begin{macrocode} - \def\IntCalc@Shl#1#2!{% - \ifx#1-% - 0\IntCalcError:ShlNegativeNumber% - \else - \the\numexpr#1#2*2\relax - \fi + \def\IntCalcShl#1!{% + \the\numexpr#1*2\relax }% % \end{macrocode} % \end{macro} % -% \begin{macro}{\intcalcShr} +% \begin{macro}{\IntCalcShr} % \begin{macrocode} - \def\intcalcShr#1{% - \number\expandafter\IntCalc@Shr\the\numexpr#1! % + \def\IntCalcShr#1!{% + \the\numexpr\ifodd#1 (#1-1)\else#1\fi/2\relax }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Shr} +% \begin{macro}{\InCa@Shr} % \begin{macrocode} - \def\IntCalc@Shr#1#2!{% + \def\InCa@Shr#1#2!{% \ifx#1-% - 0\IntCalcError:ShrNegativeNumber% + -\InCa@Shr#2!% \else \ifodd#1#2 % \the\numexpr(#1#2-1)/2\relax @@ -896,17 +1001,24 @@ and the derived files }% % \end{macrocode} % \end{macro} +% \begin{macro}{\IntCalcMul} +% \begin{macrocode} + \def\IntCalcMul#1!#2!{% + \the\numexpr#1*#2\relax + }% +% \end{macrocode} +% \end{macro} % % \begin{macro}{\intcalcSqr} % \begin{macrocode} \def\intcalcSqr#1{% - \number\expandafter\IntCalc@Sqr\the\numexpr#1! % + \number\expandafter\InCa@Sqr\the\numexpr#1! % }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Sqr} +% \begin{macro}{\InCa@Sqr} % \begin{macrocode} - \def\IntCalc@Sqr#1!{% + \def\InCa@Sqr#1!{% \the\numexpr#1*#1\relax }% % \end{macrocode} @@ -915,7 +1027,7 @@ and the derived files % \begin{macro}{\intcalcFac} % \begin{macrocode} \def\intcalcFac#1{% - \number\expandafter\IntCalc@Fac\the\numexpr#1! % + \number\expandafter\InCa@Fac\the\numexpr#1! % }% % \end{macrocode} % \end{macro} @@ -925,15 +1037,15 @@ and the derived files % \begin{macro}{\intcalcPow} % \begin{macrocode} \def\intcalcPow#1#2{% - \number\expandafter\IntCalc@Pow + \number\expandafter\InCa@Pow \the\numexpr#1\expandafter!% \the\numexpr#2! % }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Pow} +% \begin{macro}{\InCa@Pow} % \begin{macrocode} - \def\IntCalc@Pow#1#2!#3#4!{% + \def\InCa@Pow#1#2!#3#4!{% \ifcase#3#4 % power = 0 1% \or % power = 1 @@ -958,7 +1070,7 @@ and the derived files \ifx#3-% power < 0 0% \else % power > 2 - \IntCalc@PowRec#1#2!#3#4!1!% + \InCa@PowRec#1#2!#3#4!1!% \fi \fi \fi @@ -966,7 +1078,7 @@ and the derived files }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@PowRec} +% \begin{macro}{\InCa@PowRec} %\begin{quote} %\begin{verbatim} %Pow(b, p) { @@ -974,7 +1086,7 @@ and the derived files %} %PowRec(b, p, r) { % if p == 1 then -% return r +% return r*b % else % ifodd p then % return PowRec(b*b, (p-1)/2, r*b) % p div 2 = (p-1)/2 @@ -986,17 +1098,17 @@ and the derived files %\end{verbatim} %\end{quote} % \begin{macrocode} - \def\IntCalc@PowRec#1!#2!#3!{% + \def\InCa@PowRec#1!#2!#3!{% \ifnum#2=\@ne \the\numexpr#1*#3\relax \else \ifodd#2 % - \expandafter\IntCalc@PowRec + \expandafter\InCa@PowRec \the\numexpr#1*#1\expandafter!% \the\numexpr(#2-1)/2\expandafter!% \the\numexpr#1*#3\expandafter\expandafter\expandafter!% \else - \expandafter\IntCalc@PowRec + \expandafter\InCa@PowRec \the\numexpr#1*#1\expandafter!% \the\numexpr(#2-1)/2\expandafter!% \number#3\expandafter\expandafter\expandafter!% @@ -1025,22 +1137,22 @@ and the derived files % \begin{macro}{\intcalcDiv} % \begin{macrocode} \def\intcalcDiv#1#2{% - \number\expandafter\IntCalc@Div + \number\expandafter\InCa@Div \the\numexpr#1\expandafter!% \the\numexpr#2! % }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Div} +% \begin{macro}{\InCa@Div} % \begin{macrocode} - \def\IntCalc@Div#1!#2!{% + \def\InCa@Div#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@@Div + \expandafter\InCa@@Div \romannumeral 0% \ifnum#1<\z@ \expandafter-\number-#1% @@ -1060,9 +1172,29 @@ and the derived files }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@Div} +% \begin{macro}{\IntCalcDiv} % \begin{macrocode} - \def\IntCalc@@Div#1#2!#3#4!{% + \def\InCa@Temp#1{% + \def\IntCalcDiv##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \the\numexpr(##1-(##2-1)/2)/##2\relax + \fi + \fi + #1% + }% + }% + \InCa@Temp{ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@@Div} +% \begin{macrocode} + \def\InCa@@Div#1#2!#3#4!{% #1#3% \the\numexpr(#2-(#4-1)/2)/#4\relax }% @@ -1072,22 +1204,22 @@ and the derived files % \begin{macro}{\intcalcMod} % \begin{macrocode} \def\intcalcMod#1#2{% - \number\expandafter\IntCalc@Mod + \number\expandafter\InCa@Mod \the\numexpr#1\expandafter!% \the\numexpr#2! % }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Mod} +% \begin{macro}{\InCa@Mod} % \begin{macrocode} - \def\IntCalc@Mod#1!#2!{% + \def\InCa@Mod#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@@Mod + \expandafter\InCa@@Mod \romannumeral 0% \ifnum#1<\z@ \expandafter-\number-#1% @@ -1107,31 +1239,51 @@ and the derived files }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@Mod} +% \begin{macro}{\IntCalcMod} % \begin{macrocode} - \def\IntCalc@@Mod#1#2!#3#4!{% + \def\InCa@Temp#1{% + \def\IntCalcMod##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \the\numexpr##1-(##1-(##2-1)/2)/##2*##2\relax + \fi + \fi + #1% + }% + }% + \InCa@Temp{ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@@Mod} +% \begin{macrocode} + \def\InCa@@Mod#1#2!#3#4!{% \if#3+% \if#1+% - \the\numexpr#2-\IntCalc@@Div+#2!+#4!*#4\relax + \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax \else - \expandafter\IntCalc@ModX - \the\numexpr-#2+\IntCalc@@Div+#2!+#4!*#4!#4!% + \expandafter\InCa@ModX + \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!% \fi \else -% \if#1+% - \expandafter\IntCalc@ModX - \the\numexpr-#2+\IntCalc@@Div+#2!+#4!*#4!#4!% + \expandafter\InCa@ModX + \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!% \else - \the\numexpr#2-\IntCalc@@Div+#2!+#4!*#4\relax + \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax \fi \fi }% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ModX} +% \begin{macro}{\InCa@ModX} % \begin{macrocode} - \def\IntCalc@ModX#1!#2!{% + \def\InCa@ModX#1!#2!{% \ifcase#1 % 0% \else @@ -1142,32 +1294,42 @@ and the derived files % \end{macro} % % \begin{macrocode} - \IntCalc@AtEnd + \InCa@AtEnd \expandafter\endinput \fi % \end{macrocode} % % \subsection{Implementation without \eTeX} % +% \subsubsection{\op{Num}} +% +% \begin{macro}{\intcalcNum} +% \begin{macrocode} +\def\intcalcNum#1{% + \number\expandafter\InCa@FirstOfOne\number#1! % +} +% \end{macrocode} +% \end{macro} +% % \subsubsection{\op{Inv}, \op{Abs}, \op{Sgn}} % % \begin{macro}{\intcalcInv} % \begin{macrocode} \def\intcalcInv#1{% - \number\expandafter\IntCalc@Inv\number-#1! % + \number\expandafter\InCa@FirstOfOne\number-#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Inv} +% \begin{macro}{\InCa@FirstOfOne} % \begin{macrocode} -\def\IntCalc@Inv#1!{#1} +\def\InCa@FirstOfOne#1!{#1} % \end{macrocode} % \end{macro} % % \begin{macro}{\intcalcAbs} % \begin{macrocode} \def\intcalcAbs#1{% - \number\expandafter\IntCalc@Abs\number#1! % + \number\expandafter\InCa@Abs\number#1! % } % \end{macrocode} % \end{macro} @@ -1175,7 +1337,7 @@ and the derived files % \begin{macro}{\intcalcSgn} % \begin{macrocode} \def\intcalcSgn#1{% - \number\expandafter\IntCalc@Sgn\number#1! % + \number\expandafter\InCa@Sgn\number#1! % } % \end{macrocode} % \end{macro} @@ -1185,7 +1347,7 @@ and the derived files % \begin{macro}{\intcalcMin} % \begin{macrocode} \def\intcalcMin#1#2{% - \number\expandafter\IntCalc@Min + \number\expandafter\InCa@Min \number\number#1\expandafter!\number#2! % } % \end{macrocode} @@ -1194,7 +1356,7 @@ and the derived files % \begin{macro}{\intcalcMax} % \begin{macrocode} \def\intcalcMax#1#2{% - \number\expandafter\IntCalc@Max + \number\expandafter\InCa@Max \number\number#1\expandafter!\number#2! % } % \end{macrocode} @@ -1203,7 +1365,7 @@ and the derived files % \begin{macro}{\intcalcCmp} % \begin{macrocode} \def\intcalcCmp#1#2{% - \number\expandafter\IntCalc@Cmp + \number\expandafter\InCa@Cmp \number\number#1\expandafter!\number#2! % }% % \end{macrocode} @@ -1214,20 +1376,20 @@ and the derived files % \begin{macro}{\intcalcInc} % \begin{macrocode} \def\intcalcInc#1{% - \number\expandafter\IntCalc@IncSwitch\number#1! % + \number\expandafter\InCa@IncSwitch\number#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@IncSwitch} +% \begin{macro}{\InCa@IncSwitch} % \begin{macrocode} -\def\IntCalc@IncSwitch#1#2!{% +\def\InCa@IncSwitch#1#2!{% \ifx#1-% -% - \csname IntCalc@Empty% - \IntCalc@Dec#2!% + \csname InCa@Empty% + \InCa@Dec#2!% \else - \csname IntCalc@Empty% - \IntCalc@Inc#1#2!% + \csname InCa@Empty% + \InCa@Inc#1#2!% \fi } % \end{macrocode} @@ -1235,45 +1397,60 @@ and the derived files % \begin{macro}{\intcalcDec} % \begin{macrocode} \def\intcalcDec#1{% - \number\expandafter\IntCalc@DecSwitch\number#1! % + \number\expandafter\InCa@DecSwitch\number#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DecSwitch} +% \begin{macro}{\InCa@DecSwitch} % \begin{macrocode} -\def\IntCalc@DecSwitch#1#2!{% +\def\InCa@DecSwitch#1#2!{% \ifx#1-% -% - \csname IntCalc@Empty% - \expandafter\IntCalc@Inc#2!% + \csname InCa@Empty% + \expandafter\InCa@Inc#2!% \else \ifx#10% -1% \else - \csname IntCalc@Empty% - \IntCalc@Dec#1#2!% + \csname InCa@Empty% + \InCa@Dec#1#2!% \fi \fi } % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@Inc} +% \begin{macro}{\IntCalcInc} % \begin{macrocode} -\def\IntCalc@Inc#1#2{% +\def\IntCalcInc#1!{% + \number\csname InCa@Empty\InCa@Inc#1! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\IntCalcDec} +% \begin{macrocode} +\def\IntCalcDec#1!{% + \number\csname InCa@Empty\InCa@Dec#1! % +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\InCa@Inc} +% \begin{macrocode} +\def\InCa@Inc#1#2{% \ifx#2!% - \csname IntCalc@IncDigit#1\endcsname1% + \csname InCa@IncDigit#1\endcsname1% \else - \csname IntCalc@IncDigit#1% - \expandafter\IntCalc@Inc\expandafter#2% + \csname InCa@IncDigit#1% + \expandafter\InCa@Inc\expandafter#2% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@IncDigit[0-8]} +% \begin{macro}{\InCa@IncDigit[0-8]} % \begin{macrocode} -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@IncDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@IncDigit#1\endcsname##1{% \endcsname 0% \ifcase##1 % @@ -1283,20 +1460,20 @@ and the derived files \fi }% } -\IntCalc@Temp 01 -\IntCalc@Temp 12 -\IntCalc@Temp 23 -\IntCalc@Temp 34 -\IntCalc@Temp 45 -\IntCalc@Temp 56 -\IntCalc@Temp 67 -\IntCalc@Temp 78 -\IntCalc@Temp 89 +\InCa@Temp 01 +\InCa@Temp 12 +\InCa@Temp 23 +\InCa@Temp 34 +\InCa@Temp 45 +\InCa@Temp 56 +\InCa@Temp 67 +\InCa@Temp 78 +\InCa@Temp 89 % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@IncDigit9} +% \begin{macro}{\InCa@IncDigit9} % \begin{macrocode} -\expandafter\def\csname IntCalc@IncDigit9\endcsname#1{% +\expandafter\def\csname InCa@IncDigit9\endcsname#1{% \expandafter\endcsname \ifcase#1 % 09% @@ -1307,22 +1484,22 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@Dec} +% \begin{macro}{\InCa@Dec} % \begin{macrocode} -\def\IntCalc@Dec#1#2{% +\def\InCa@Dec#1#2{% \ifx#2!% - \csname IntCalc@DecDigit#1\endcsname1% + \csname InCa@DecDigit#1\endcsname1% \else - \csname IntCalc@DecDigit#1% - \expandafter\IntCalc@Dec\expandafter#2% + \csname InCa@DecDigit#1% + \expandafter\InCa@Dec\expandafter#2% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DecDigit[1-9]} +% \begin{macro}{\InCa@DecDigit[1-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@DecDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@DecDigit#1\endcsname##1{% \endcsname 0% \ifcase##1 % @@ -1332,20 +1509,20 @@ and the derived files \fi }% } -\IntCalc@Temp 98 -\IntCalc@Temp 87 -\IntCalc@Temp 76 -\IntCalc@Temp 65 -\IntCalc@Temp 54 -\IntCalc@Temp 43 -\IntCalc@Temp 32 -\IntCalc@Temp 21 -\IntCalc@Temp 10 +\InCa@Temp 98 +\InCa@Temp 87 +\InCa@Temp 76 +\InCa@Temp 65 +\InCa@Temp 54 +\InCa@Temp 43 +\InCa@Temp 32 +\InCa@Temp 21 +\InCa@Temp 10 % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DecDigit0} +% \begin{macro}{\InCa@DecDigit0} % \begin{macrocode} -\expandafter\def\csname IntCalc@DecDigit0\endcsname#1{% +\expandafter\def\csname InCa@DecDigit0\endcsname#1{% \expandafter\endcsname \ifcase#1 % 00% @@ -1362,10 +1539,9 @@ and the derived files % \begin{macrocode} \def\intcalcAdd#1#2{% \number - \expandafter\IntCalc@AddSwitch + \expandafter\InCa@AddSwitch \number\number#1\expandafter!% - \number#2!% - \IntCalc@Space + \number#2! % } % \end{macrocode} % \end{macro} @@ -1373,18 +1549,17 @@ and the derived files % \begin{macrocode} \def\intcalcSub#1#2{% \number - \expandafter\IntCalc@AddSwitch + \expandafter\InCa@AddSwitch \number\number#1\expandafter!% - \number-\number#2!% - \IntCalc@Space + \number-\number#2! % } % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@AddSwitch} -% Decision table for \cs{IntCalc@AddSwitch}. -% By using less than zero operations, the sign -% of negative numbers can be removed by a simple \cs{IntCalc@Gobble} +% \begin{macro}{\InCa@AddSwitch} +% Decision table for \cs{InCa@AddSwitch}. +% The sign of negative numbers can be removed +% by a simple \cs{@gobble} % instead of the more expensive |\number-|. % \begin{quote} % \begin{tabular}[t]{@{}|l|l|l|l|l|@{}} @@ -1408,166 +1583,189 @@ and the derived files % \end{tabular} % \end{quote} % \begin{macrocode} -\def\IntCalc@AddSwitch#1!#2!{% +\def\InCa@AddSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ -% \ifnum#1<#2 % - \expandafter\IntCalc@Add\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Add\number-#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Add\number-#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Add\number-#2\expandafter!% + \@gobble#1!% \fi \else \ifnum-#1>#2 % -% - \expandafter\IntCalc@Sub\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Sub\@gobble#1!#2!% \else - \expandafter\IntCalc@Sub\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Sub\number#2\expandafter!% + \@gobble#1!% \fi \fi \else \ifnum#2<\z@ \ifnum#1>-#2 % - \expandafter\IntCalc@Sub\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Sub\number#1\expandafter!% + \@gobble#2!% \else -% - \expandafter\IntCalc@Sub\IntCalc@Gobble#2!#1!% + \expandafter\InCa@Sub\@gobble#2!#1!% \fi \else \ifnum#1>#2 % - \IntCalc@Add#1!#2!% + \InCa@Add#1!#2!% \else - \IntCalc@Add#2!#1!% + \InCa@Add#2!#1!% \fi \fi \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Add} +% \begin{macro}{\IntCalcAdd} +% \begin{macrocode} +\def\IntCalcAdd#1!#2!{% + \number\InCa@Add#1!#2! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\IntCalcSub} +% \begin{macrocode} +\def\IntCalcSub#1!#2!{% + \number\InCa@Sub#1!#2! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@Space} % \begin{macrocode} -\def\IntCalc@Add#1!#2!{% +\begingroup + \def\x#1{\endgroup + \let\InCa@Space= #1% + }% +\x{ } +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@Add} +% \begin{macrocode} +\def\InCa@Add#1!#2!{% \ifcase#2 % #1% \else - \IntCalc@@Add#1!#2!000000000\IntCalc@Space + \InCa@@Add#1!#2!000000000\InCa@Space \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Sub} +% \begin{macro}{\InCa@Sub} % \begin{macrocode} -\def\IntCalc@Sub#1!#2!{% +\def\InCa@Sub#1!#2!{% \ifnum#1=#2 % 0% \else - \IntCalc@@Sub#1!#2!000000000\IntCalc@Space + \InCa@@Sub#1!#2!000000000\InCa@Space \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@Add} +% \begin{macro}{\InCa@@Add} % \begin{macrocode} -\def\IntCalc@@Add#1!#2#3!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty +\def\InCa@@Add#1!#2#3!{% + \ifx\InCa@Empty#3\InCa@Empty \@ReturnAfterElseFi{% - \IntCalc@@@Add!!#1!#2% + \InCa@@@Add!!#1!#2% }% \else \@ReturnAfterFi{% - \IntCalc@@Add#1!#3!#2% + \InCa@@Add#1!#3!#2% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@Sub} +% \begin{macro}{\InCa@@Sub} % \begin{macrocode} -\def\IntCalc@@Sub#1!#2#3!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty +\def\InCa@@Sub#1!#2#3!{% + \ifx\InCa@Empty#3\InCa@Empty \@ReturnAfterElseFi{% - \IntCalc@@@Sub!!#1!#2% + \InCa@@@Sub!!#1!#2% }% \else \@ReturnAfterFi{% - \IntCalc@@Sub#1!#3!#2% + \InCa@@Sub#1!#3!#2% }% \fi } % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@@@Add} +% \begin{macro}{\InCa@@@Add} % \begin{macrocode} -\def\IntCalc@@@Add#1!#2!#3#4!#5{% - \ifx\IntCalc@Empty#4\IntCalc@Empty - \csname IntCalc@Empty% +\def\InCa@@@Add#1!#2!#3#4!#5{% + \ifx\InCa@Empty#4\InCa@Empty + \csname InCa@Empty% \@ReturnAfterElseFi{% - \IntCalc@ProcessAdd#1#3!#5#2% + \InCa@ProcessAdd#1#3!#5#2% }% \else \@ReturnAfterFi{% - \IntCalc@@@Add#1#3!#5#2!#4!% + \InCa@@@Add#1#3!#5#2!#4!% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@@Sub} +% \begin{macro}{\InCa@@@Sub} % \begin{macrocode} -\def\IntCalc@@@Sub#1!#2!#3#4!#5{% - \ifx\IntCalc@Empty#4\IntCalc@Empty - \csname IntCalc@Gobble% +\def\InCa@@@Sub#1!#2!#3#4!#5{% + \ifx\InCa@Empty#4\InCa@Empty + \csname @gobble% \@ReturnAfterElseFi{% - \IntCalc@ProcessSub#1#3!#5#2% + \InCa@ProcessSub#1#3!#5#2% }% \else \@ReturnAfterFi{% - \IntCalc@@@Sub#1#3!#5#2!#4!% + \InCa@@@Sub#1#3!#5#2!#4!% }% \fi } % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@ProcessAdd} +% \begin{macro}{\InCa@ProcessAdd} % \begin{macrocode} -\def\IntCalc@ProcessAdd#1#2!#3#4{% - \ifx\IntCalc@Empty#2\IntCalc@Empty - \csname IntCalc@AddDigit#1\endcsname#3% +\def\InCa@ProcessAdd#1#2!#3#4{% + \ifx\InCa@Empty#2\InCa@Empty + \csname InCa@AddDigit#1\endcsname#3% \romannumeral0#4% \else - \csname IntCalc@AddDigit#1\csname IntCalc@DigitCarry#3% + \csname InCa@AddDigit#1\csname InCa@DigitCarry#3% \@ReturnAfterFi{% - \IntCalc@ProcessAdd#2!#4% + \InCa@ProcessAdd#2!#4% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ProcessSub} +% \begin{macro}{\InCa@ProcessSub} % \begin{macrocode} -\def\IntCalc@ProcessSub#1#2!#3#4{% - \ifx\IntCalc@Empty#2\IntCalc@Empty - \csname IntCalc@SubDigit#1\endcsname#3% +\def\InCa@ProcessSub#1#2!#3#4{% + \ifx\InCa@Empty#2\InCa@Empty + \csname InCa@SubDigit#1\endcsname#3% \romannumeral0#4% \else - \csname IntCalc@SubDigit#1\csname IntCalc@DigitCarry#3% + \csname InCa@SubDigit#1\csname InCa@DigitCarry#3% \@ReturnAfterFi{% - \IntCalc@ProcessSub#2!#4% + \InCa@ProcessSub#2!#4% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DigitCarry[0-9]} +% \begin{macro}{\InCa@DigitCarry[0-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@DigitCarry#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@DigitCarry#1\endcsname##1{% \ifcase##1 % \endcsname#1% \else @@ -1575,22 +1773,22 @@ and the derived files \fi }% } -\IntCalc@Temp 01 -\IntCalc@Temp 12 -\IntCalc@Temp 23 -\IntCalc@Temp 34 -\IntCalc@Temp 45 -\IntCalc@Temp 56 -\IntCalc@Temp 67 -\IntCalc@Temp 78 -\IntCalc@Temp 89 -\IntCalc@Temp 9{{10}} +\InCa@Temp 01 +\InCa@Temp 12 +\InCa@Temp 23 +\InCa@Temp 34 +\InCa@Temp 45 +\InCa@Temp 56 +\InCa@Temp 67 +\InCa@Temp 78 +\InCa@Temp 89 +\InCa@Temp 9{{10}} % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@AddDigit0} +% \begin{macro}{\InCa@AddDigit0} % \begin{macrocode} -\expandafter\def\csname IntCalc@AddDigit0\endcsname#1{% +\expandafter\def\csname InCa@AddDigit0\endcsname#1{% \ifnum#1>9 % \endcsname10% \else @@ -1599,10 +1797,10 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@AddDigit[1-9]} +% \begin{macro}{\InCa@AddDigit[1-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2#3{% - \expandafter\def\csname IntCalc@AddDigit#1\endcsname##1{% +\def\InCa@Temp#1#2#3{% + \expandafter\def\csname InCa@AddDigit#1\endcsname##1{% \ifnum##1>#2 % \endcsname 1% \else @@ -1614,7 +1812,7 @@ and the derived files \fi }% } -\IntCalc@Temp 18{% +\InCa@Temp 18{% \or 2% 1 \or 3% 2 \or 4% 3 @@ -1625,7 +1823,7 @@ and the derived files \or 9% 8 \or 0% 9 }% -\IntCalc@Temp 27{% +\InCa@Temp 27{% \or 3% 1 \or 4% 2 \or 5% 3 @@ -1636,7 +1834,7 @@ and the derived files \or 0% 8 \or 1% 9 }% -\IntCalc@Temp 36{% +\InCa@Temp 36{% \or 4% 1 \or 5% 2 \or 6% 3 @@ -1647,7 +1845,7 @@ and the derived files \or 1% 8 \or 2% 9 }% -\IntCalc@Temp 45{% +\InCa@Temp 45{% \or 5% 1 \or 6% 2 \or 7% 3 @@ -1658,7 +1856,7 @@ and the derived files \or 2% 8 \or 3% 9 }% -\IntCalc@Temp 54{% +\InCa@Temp 54{% \or 6% 1 \or 7% 2 \or 8% 3 @@ -1669,7 +1867,7 @@ and the derived files \or 3% 8 \or 4% 9 }% -\IntCalc@Temp 63{% +\InCa@Temp 63{% \or 7% 1 \or 8% 2 \or 9% 3 @@ -1680,7 +1878,7 @@ and the derived files \or 4% 8 \or 5% 9 }% -\IntCalc@Temp 72{% +\InCa@Temp 72{% \or 8% 1 \or 9% 2 \or 0% 3 @@ -1691,7 +1889,7 @@ and the derived files \or 5% 8 \or 6% 9 }% -\IntCalc@Temp 81{% +\InCa@Temp 81{% \or 9% 1 \or 0% 2 \or 1% 3 @@ -1702,7 +1900,7 @@ and the derived files \or 6% 8 \or 7% 9 }% -\IntCalc@Temp 90{% +\InCa@Temp 90{% \or 0% 1 \or 1% 2 \or 2% 3 @@ -1716,10 +1914,10 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@SubDigit[0-9]} +% \begin{macro}{\InCa@SubDigit[0-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@SubDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@SubDigit#1\endcsname##1{% \ifnum##1>#1 % \endcsname 1% \else @@ -1731,7 +1929,7 @@ and the derived files \fi }% } -\IntCalc@Temp 0{% +\InCa@Temp 0{% \or 9% 1 \or 8% 2 \or 7% 3 @@ -1742,7 +1940,7 @@ and the derived files \or 2% 8 \or 1% 9 } -\IntCalc@Temp 1{% +\InCa@Temp 1{% \or 0% 1 \or 9% 2 \or 8% 3 @@ -1753,7 +1951,7 @@ and the derived files \or 3% 8 \or 2% 9 } -\IntCalc@Temp 2{% +\InCa@Temp 2{% \or 1% 1 \or 0% 2 \or 9% 3 @@ -1764,7 +1962,7 @@ and the derived files \or 4% 8 \or 3% 9 } -\IntCalc@Temp 3{% +\InCa@Temp 3{% \or 2% 1 \or 1% 2 \or 0% 3 @@ -1775,7 +1973,7 @@ and the derived files \or 5% 8 \or 4% 9 } -\IntCalc@Temp 4{% +\InCa@Temp 4{% \or 3% 1 \or 2% 2 \or 1% 3 @@ -1786,7 +1984,7 @@ and the derived files \or 6% 8 \or 5% 9 } -\IntCalc@Temp 5{% +\InCa@Temp 5{% \or 4% 1 \or 3% 2 \or 2% 3 @@ -1797,7 +1995,7 @@ and the derived files \or 7% 8 \or 6% 9 } -\IntCalc@Temp 6{% +\InCa@Temp 6{% \or 5% 1 \or 4% 2 \or 3% 3 @@ -1808,7 +2006,7 @@ and the derived files \or 8% 8 \or 7% 9 } -\IntCalc@Temp 7{% +\InCa@Temp 7{% \or 6% 1 \or 5% 2 \or 4% 3 @@ -1819,7 +2017,7 @@ and the derived files \or 9% 8 \or 8% 9 } -\IntCalc@Temp 8{% +\InCa@Temp 8{% \or 7% 1 \or 6% 2 \or 5% 3 @@ -1830,7 +2028,7 @@ and the derived files \or 0% 8 \or 9% 9 } -\IntCalc@Temp 9{% +\InCa@Temp 9{% \or 8% 1 \or 7% 2 \or 6% 3 @@ -1849,47 +2047,57 @@ and the derived files % \begin{macro}{\intcalcShl} % \begin{macrocode} \def\intcalcShl#1{% - \number\expandafter\IntCalc@ShlSwitch\number#1! % + \number\expandafter\InCa@ShlSwitch\number#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ShlSwitch} +% \begin{macro}{\InCa@ShlSwitch} % \begin{macrocode} -\def\IntCalc@ShlSwitch#1!{% - \ifnum#1<\z@ - 0\IntCalcError:ShlNegativeNumber% +\def\InCa@ShlSwitch#1#2!{% + \ifx#1-% + -\csname InCa@Empty% + \InCa@Shl#2!% \else - \csname IntCalc@Empty% - \IntCalc@Shl#1!% + \csname InCa@Empty% + \InCa@Shl#1#2!% \fi } % \end{macrocode} % \end{macro} +% \begin{macro}{\IntCalcShl} +% \begin{macrocode} +\def\IntCalcShl#1!{% + \number + \csname InCa@Empty% + \InCa@Shl#1! % +} +% \end{macrocode} +% \end{macro} % \begin{macro}{\IntCal@ShlDigit} % \begin{macrocode} -\def\IntCalc@Shl#1#2{% +\def\InCa@Shl#1#2{% \ifx#2!% - \csname IntCalc@ShlDigit#1\endcsname0% + \csname InCa@ShlDigit#1\endcsname0% \else - \csname IntCalc@ShlDigit#1% + \csname InCa@ShlDigit#1% \@ReturnAfterFi{% - \IntCalc@Shl#2% + \InCa@Shl#2% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ShlDigit0} +% \begin{macro}{\InCa@ShlDigit0} % \begin{macrocode} -\expandafter\def\csname IntCalc@ShlDigit0\endcsname{% +\expandafter\def\csname InCa@ShlDigit0\endcsname{% \endcsname0% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ShlDigit[1-9]} +% \begin{macro}{\InCa@ShlDigit[1-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2#3#4#5{% - \expandafter\def\csname IntCalc@ShlDigit#1\endcsname##1{% +\def\InCa@Temp#1#2#3#4#5{% + \expandafter\def\csname InCa@ShlDigit#1\endcsname##1{% \expandafter\endcsname \ifcase##1 % #2#3% @@ -1898,49 +2106,56 @@ and the derived files \fi }% } -\IntCalc@Temp 10203 -\IntCalc@Temp 20405 -\IntCalc@Temp 30607 -\IntCalc@Temp 40809 -\IntCalc@Temp 51011 -\IntCalc@Temp 61213 -\IntCalc@Temp 71415 -\IntCalc@Temp 81617 -\IntCalc@Temp 91819 +\InCa@Temp 10203 +\InCa@Temp 20405 +\InCa@Temp 30607 +\InCa@Temp 40809 +\InCa@Temp 51011 +\InCa@Temp 61213 +\InCa@Temp 71415 +\InCa@Temp 81617 +\InCa@Temp 91819 % \end{macrocode} % \end{macro} % % \begin{macro}{\intcalcShr} % \begin{macrocode} \def\intcalcShr#1{% - \number\expandafter\IntCalc@ShrSwitch\number#1! % + \number\expandafter\InCa@ShrSwitch\number#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ShrSwitch} +% \begin{macro}{\InCa@ShrSwitch} % \begin{macrocode} -\def\IntCalc@ShrSwitch#1!{% - \ifnum#1<\z@ - 0\IntCalcError:ShrNegativeNumber% +\def\InCa@ShrSwitch#1#2!{% + \ifx#1-% + -\InCa@Shr#2!% \else - \IntCalc@Shr#1!% + \InCa@Shr#1#2!% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Shr} +% \begin{macro}{\IntCalcShr} +% \begin{macrocode} +\def\IntCalcShr#1!{% + \number\InCa@Shr#1! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@Shr} % \begin{macrocode} -\def\IntCalc@Shr#1#2{% - \IntCalc@ShrDigit#1!% +\def\InCa@Shr#1#2{% + \InCa@ShrDigit#1!% \ifx#2!% \else \@ReturnAfterFi{% \ifodd#1 % \@ReturnAfterElseFi{% - \IntCalc@Shr{1#2}% + \InCa@Shr{1#2}% }% \else - \expandafter\IntCalc@Shr\expandafter#2% + \expandafter\InCa@Shr\expandafter#2% \fi }% \fi @@ -1948,7 +2163,7 @@ and the derived files % \end{macrocode} % \end{macro} % \begin{macrocode} -\def\IntCalc@ShrDigit#1!{% +\def\InCa@ShrDigit#1!{% \ifcase#1 0% 0 \or 0% 1 \or 1% 2 @@ -1973,83 +2188,86 @@ and the derived files } % \end{macrocode} % -% \subsubsection{\cs{IntCalc@Tim}} +% \subsubsection{\cs{InCa@Tim}} % -% \begin{macro}{\IntCalc@Tim} -% Macro \cs{IntCalc@Tim} implements +% \begin{macro}{\InCa@Tim} +% Macro \cs{InCa@Tim} implements % ``Number \emph{tim}es digit''. % \begin{macrocode} -\def\IntCalc@Tim#1#2{% - \number - \ifcase#2 % 0 - 0% - \or % 1 - #1% - \else % 2-9 - \csname IntCalc@Empty% - \IntCalc@ProcessTim#2#1!% - \fi - \IntCalc@Space +\def\InCa@Temp#1{% + \def\InCa@Tim##1##2{% + \number + \ifcase##2 % 0 + 0% + \or % 1 + ##1% + \else % 2-9 + \csname InCa@Empty% + \InCa@ProcessTim##2##1!% + \fi + #1% + }% } +\InCa@Temp{ } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ProcessTim} +% \begin{macro}{\InCa@ProcessTim} % \begin{macrocode} -\def\IntCalc@ProcessTim#1#2#3{% +\def\InCa@ProcessTim#1#2#3{% \ifx#3!% - \csname IntCalc@TimDigit#2\endcsname#10% + \csname InCa@TimDigit#2\endcsname#10% \else - \csname IntCalc@TimDigit#2\csname IntCalc@Param#1% + \csname InCa@TimDigit#2\csname InCa@Param#1% \@ReturnAfterFi{% - \IntCalc@ProcessTim#1#3% + \InCa@ProcessTim#1#3% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Param[0-9]} +% \begin{macro}{\InCa@Param[0-9]} % \begin{macrocode} -\def\IntCalc@Temp#1{% - \expandafter\def\csname IntCalc@Param#1\endcsname{% +\def\InCa@Temp#1{% + \expandafter\def\csname InCa@Param#1\endcsname{% \endcsname#1% }% } -\IntCalc@Temp 0% -\IntCalc@Temp 1% -\IntCalc@Temp 2% -\IntCalc@Temp 3% -\IntCalc@Temp 4% -\IntCalc@Temp 5% -\IntCalc@Temp 6% -\IntCalc@Temp 7% -\IntCalc@Temp 8% -\IntCalc@Temp 9% +\InCa@Temp 0% +\InCa@Temp 1% +\InCa@Temp 2% +\InCa@Temp 3% +\InCa@Temp 4% +\InCa@Temp 5% +\InCa@Temp 6% +\InCa@Temp 7% +\InCa@Temp 8% +\InCa@Temp 9% % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@TimDigit0} +% \begin{macro}{\InCa@TimDigit0} % \begin{macrocode} -\expandafter\def\csname IntCalc@TimDigit0\endcsname#1#2{% +\expandafter\def\csname InCa@TimDigit0\endcsname#1#2{% \endcsname 0#2% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@TimDigit1} +% \begin{macro}{\InCa@TimDigit1} % \begin{macrocode} -\expandafter\def\csname IntCalc@TimDigit1\endcsname#1#2{% +\expandafter\def\csname InCa@TimDigit1\endcsname#1#2{% \ifcase#2 % \endcsname 0#1% \else - \csname IntCalc@AddDigit#1\endcsname #2% + \csname InCa@AddDigit#1\endcsname #2% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@TimDigit[2-9]} +% \begin{macro}{\InCa@TimDigit[2-9]} % \begin{macrocode} -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@TimDigit#1\endcsname##1{% - \expandafter\IntCalc@TimDigitCarry +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@TimDigit#1\endcsname##1{% + \expandafter\InCa@TimDigitCarry \number \ifcase##1 0% 0 #2% @@ -2057,7 +2275,7 @@ and the derived files !% }% } -\IntCalc@Temp 2{% +\InCa@Temp 2{% \or 2% 1 \or 4% 2 \or 6% 3 @@ -2068,7 +2286,7 @@ and the derived files \or 16% 8 \or 18% 9 } -\IntCalc@Temp 3{% +\InCa@Temp 3{% \or 3% 1 \or 6% 2 \or 9% 3 @@ -2079,7 +2297,7 @@ and the derived files \or 24% 8 \or 27% 9 } -\IntCalc@Temp 4{% +\InCa@Temp 4{% \or 4% 1 \or 8% 2 \or 12% 3 @@ -2090,7 +2308,7 @@ and the derived files \or 32% 8 \or 36% 9 } -\IntCalc@Temp 5{% +\InCa@Temp 5{% \or 5% 1 \or 10% 2 \or 15% 3 @@ -2101,7 +2319,7 @@ and the derived files \or 40% 8 \or 45% 9 } -\IntCalc@Temp 6{% +\InCa@Temp 6{% \or 6% 1 \or 12% 2 \or 18% 3 @@ -2112,7 +2330,7 @@ and the derived files \or 48% 8 \or 54% 9 } -\IntCalc@Temp 7{% +\InCa@Temp 7{% \or 7% 1 \or 14% 2 \or 21% 3 @@ -2123,7 +2341,7 @@ and the derived files \or 56% 8 \or 63% 9 } -\IntCalc@Temp 8{% +\InCa@Temp 8{% \or 8% 1 \or 16% 2 \or 24% 3 @@ -2134,7 +2352,7 @@ and the derived files \or 64% 8 \or 72% 9 } -\IntCalc@Temp 9{% +\InCa@Temp 9{% \or 9% 1 \or 18% 2 \or 27% 3 @@ -2147,24 +2365,24 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@TimDigitCarry} +% \begin{macro}{\InCa@TimDigitCarry} % \begin{macrocode} -\def\IntCalc@TimDigitCarry#1!{% +\def\InCa@TimDigitCarry#1!{% \ifnum#1<10 % - \csname IntCalc@AddDigit#1\expandafter\endcsname + \csname InCa@AddDigit#1\expandafter\endcsname \else \@ReturnAfterFi{% - \IntCalc@@TimDigitCarry#1!% + \InCa@@TimDigitCarry#1!% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@TimDigitCarry} +% \begin{macro}{\InCa@@TimDigitCarry} % \begin{macrocode} -\def\IntCalc@@TimDigitCarry#1#2!#3{% - \csname IntCalc@DigitCarry#1% - \csname IntCalc@AddDigit#2\endcsname #3% +\def\InCa@@TimDigitCarry#1#2!#3{% + \csname InCa@DigitCarry#1% + \csname InCa@AddDigit#2\endcsname #3% } % \end{macrocode} % \end{macro} @@ -2175,16 +2393,15 @@ and the derived files % \begin{macrocode} \def\intcalcMul#1#2{% \number - \expandafter\IntCalc@MulSwitch + \expandafter\InCa@MulSwitch \number\number#1\expandafter!% - \number#2!% - \IntCalc@Space + \number#2! % } % \end{macrocode} % \end{macro} % -% \begin{macro}{\IntCalc@MulSwitch} -% Decision table for \cs{IntCalc@MulSwitch}. +% \begin{macro}{\InCa@MulSwitch} +% Decision table for \cs{InCa@MulSwitch}. % \begin{quote} % \begin{tabular}[t]{@{}|l|l|l|l|l|@{}} % \hline @@ -2207,82 +2424,89 @@ and the derived files % \end{tabular} % \end{quote} % \begin{macrocode} -\def\IntCalc@MulSwitch#1!#2!{% +\def\InCa@MulSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ \ifnum#1<#2 % - \expandafter\IntCalc@Mul\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Mul\number-#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Mul\number-#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Mul\number-#2\expandafter!% + \@gobble#1!% \fi \else -% \ifnum-#1>#2 % - \expandafter\IntCalc@Mul\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Mul\@gobble#1!#2!% \else - \expandafter\IntCalc@Mul\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Mul\number#2\expandafter!% + \@gobble#1!% \fi \fi \else \ifnum#2<\z@ -% \ifnum#1>-#2 % - \expandafter\IntCalc@Mul\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Mul\number#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Mul\IntCalc@Gobble#2!#1!% + \expandafter\InCa@Mul\@gobble#2!#1!% \fi \else \ifnum#1>#2 % - \IntCalc@Mul#1!#2!% + \InCa@Mul#1!#2!% \else - \IntCalc@Mul#2!#1!% + \InCa@Mul#2!#1!% \fi \fi \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Mul} +% \begin{macro}{\IntCalcMul} % \begin{macrocode} -\def\IntCalc@Mul#1!#2!{% +\def\IntCalcMul#1!#2!{% + \number\InCa@Mul#1!#2! % +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@Mul} +% \begin{macrocode} +\def\InCa@Mul#1!#2!{% \ifcase#2 % 0% \or #1% \or - \csname IntCalc@Empty% - \expandafter\IntCalc@Shl#1!% + \csname InCa@Empty% + \expandafter\InCa@Shl#1!% \else \ifnum#2<10 % - \IntCalc@Tim{#1}#2% + \InCa@Tim{#1}#2% \else - \IntCalc@ProcessMul!#2!#1!% + \InCa@ProcessMul!#2!#1!% \fi \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Mul} +% \begin{macro}{\InCa@Mul} % \begin{macrocode} -\def\IntCalc@ProcessMul#1!#2#3!#4!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty - \expandafter\IntCalc@Add\number +\def\InCa@ProcessMul#1!#2#3!#4!{% + \ifx\InCa@Empty#3\InCa@Empty + \expandafter\InCa@Add\number #10\expandafter\expandafter\expandafter!% - \IntCalc@Tim{#4}#2!% + \InCa@Tim{#4}#2!% \else - \ifx\IntCalc@Empty#1\IntCalc@Empty - \expandafter\expandafter\expandafter\IntCalc@ProcessMul - \IntCalc@Tim{#4}#2!% + \ifx\InCa@Empty#1\InCa@Empty + \expandafter\expandafter\expandafter\InCa@ProcessMul + \InCa@Tim{#4}#2!% #3!#4!% \else - \expandafter\IntCalc@ProcessMul\number - \expandafter\IntCalc@Add\number% + \expandafter\InCa@ProcessMul\number + \expandafter\InCa@Add\number% #10\expandafter\expandafter\expandafter!% - \IntCalc@Tim{#4}#2!!% + \InCa@Tim{#4}#2!!% #3!#4!% \fi \fi @@ -2295,17 +2519,17 @@ and the derived files % \begin{macro}{\intcalcSqr} % \begin{macrocode} \def\intcalcSqr#1{% - \number\expandafter\IntCalc@Sqr\number#1! % + \number\expandafter\InCa@Sqr\number#1! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Sqr} +% \begin{macro}{\InCa@Sqr} % \begin{macrocode} -\def\IntCalc@Sqr#1#2!{% +\def\InCa@Sqr#1#2!{% \ifx#1-% - \IntCalc@Mul#2!#2!% + \InCa@Mul#2!#2!% \else - \IntCalc@Mul#1#2!#1#2!% + \InCa@Mul#1#2!#1#2!% \fi } % \end{macrocode} @@ -2314,7 +2538,7 @@ and the derived files % \begin{macro}{\intcalcFac} % \begin{macrocode} \def\intcalcFac#1{% - \number\expandafter\IntCalc@Fac\number#1! % + \number\expandafter\InCa@Fac\number#1! % } % \end{macrocode} % \end{macro} @@ -2324,24 +2548,24 @@ and the derived files % \begin{macro}{\intcalcPow} % \begin{macrocode} \def\intcalcPow#1#2{% - \number\expandafter\IntCalc@Pow + \number\expandafter\InCa@Pow \number\number#1\expandafter!% \number#2! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Pow} +% \begin{macro}{\InCa@Pow} % \begin{macrocode} -\def\IntCalc@Pow#1#2!#3#4!{% +\def\InCa@Pow#1#2!#3#4!{% \ifcase#3#4 % power = 0 1% \or % power = 1 #1#2% \or % power = 2 \ifx#1-% - \IntCalc@Mul#2!#2!% + \InCa@Mul#2!#2!% \else - \IntCalc@Mul#1#2!#1#2!% + \InCa@Mul#1#2!#1#2!% \fi \else \ifcase#1#2 % basis = 0, power <> 0 @@ -2365,9 +2589,9 @@ and the derived files \ifodd#3#4 % -% \fi - \IntCalc@PowRec#2!#3#4!1!% + \InCa@PowRec#2!#3#4!1!% \else - \IntCalc@PowRec#1#2!#3#4!1!% + \InCa@PowRec#1#2!#3#4!1!% \fi \fi \fi @@ -2376,7 +2600,7 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@PowRec} +% \begin{macro}{\InCa@PowRec} %\begin{quote} %\begin{verbatim} %Pow(b, p) { @@ -2396,23 +2620,23 @@ and the derived files %\end{verbatim} %\end{quote} % \begin{macrocode} -\def\IntCalc@PowRec#1!#2!#3!{% +\def\InCa@PowRec#1!#2!#3!{% \ifnum#2=\@ne \ifnum#1>#3 % - \IntCalc@Mul#1!#3!% + \InCa@Mul#1!#3!% \else - \IntCalc@Mul#3!#1!% + \InCa@Mul#3!#1!% \fi \else - \expandafter\IntCalc@PowRec - \number\IntCalc@Mul#1!#1!\expandafter!% + \expandafter\InCa@PowRec + \number\InCa@Mul#1!#1!\expandafter!% \number\intcalcShr{#2}\expandafter!% \number \ifodd#2 % \ifnum#1>#3 % - \IntCalc@Mul#1!#3!% + \InCa@Mul#1!#3!% \else - \IntCalc@Mul#3!#1!% + \InCa@Mul#3!#1!% \fi \else #3% @@ -2428,22 +2652,22 @@ and the derived files % \begin{macro}{\intcalcDiv} % \begin{macrocode} \def\intcalcDiv#1#2{% - \number\expandafter\IntCalc@Div + \number\expandafter\InCa@Div \number\number#1\expandafter!% \number#2! % } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Div} +% \begin{macro}{\InCa@Div} % \begin{macrocode} -\def\IntCalc@Div#1!#2!{% +\def\InCa@Div#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@DivSwitch + \expandafter\InCa@DivSwitch \number#1\expandafter!% \number#2!% \fi @@ -2451,63 +2675,75 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DivSwitch} -% Decision table for \cs{IntCalc@DivSwitch}. +% \begin{macro}{\IntCalcDiv} +% \begin{macrocode} +\def\InCa@Temp#1{% + \def\IntCalcDiv##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \InCa@@Div##1!##2!% + \fi + \fi + #1% + }% +} +\InCa@Temp{ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@DivSwitch} +% Decision table for \cs{InCa@DivSwitch}. % \begin{quote} -% \begin{tabular}[t]{@{}|l|l|l|l|l|@{}} +% \begin{tabular}[t]{@{}|l|l|l|l|@{}} % \hline -% $x<0$ & $y<0$ & $ x< y$ & $+$ & $\opDiv(-x,-y)$\\ -% \cline{3-3}\cline{5-5} -% & & else & & $\opDiv(-y,-x)$\\ -% \cline{2-5} -% & else & $-x> y$ & $-$ & $\opDiv(-x, y)$\\ -% \cline{3-3}\cline{5-5} -% & & else & & $\opDiv( y,-x)$\\ +% $x<0$ & $y<0$ & $+$ & $\opDiv(-x,-y)$\\ +% \cline{2-4} +% & else & $-$ & $\opDiv(-x, y)$\\ % \hline -% else & $y<0$ & $ x>-y$ & $-$ & $\opDiv( x,-y)$\\ -% \cline{3-3}\cline{5-5} -% & & else & & $\opDiv(-y, x)$\\ -% \cline{2-5} -% & else & $ x> y$ & $+$ & $\opDiv( x, y)$\\ -% \cline{3-3}\cline{5-5} -% & & else & & $\opDiv( y, x)$\\ +% else & $y<0$ & $-$ & $\opDiv( x,-y)$\\ +% \cline{2-4} +% & else & $+$ & $\opDiv( x, y)$\\ % \hline % \end{tabular} % \end{quote} % \begin{macrocode} -\def\IntCalc@DivSwitch#1!#2!{% +\def\InCa@DivSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ - \expandafter\IntCalc@@Div\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@@Div\number-#1\expandafter!% + \@gobble#2!% \else -% - \expandafter\IntCalc@@Div\IntCalc@Gobble#1!#2!% + \expandafter\InCa@@Div\@gobble#1!#2!% \fi \else \ifnum#2<\z@ -% - \expandafter\IntCalc@@Div\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@@Div\number#1\expandafter!% + \@gobble#2!% \else - \IntCalc@@Div#1!#2!% + \InCa@@Div#1!#2!% \fi \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@Div} +% \begin{macro}{\InCa@@Div} % \begin{macrocode} -\def\IntCalc@@Div#1!#2!{% +\def\InCa@@Div#1!#2!{% \ifnum#1>#2 % \ifcase#2 % 0 already catched ? \IntCalcError:ThisCannotHappen% \or % 1 #1% \or % 2 - \IntCalc@Shr#1!% + \InCa@Shr#1!% \else - \IntCalc@DivStart!#1!#2!#2!% + \InCa@DivStart!#1!#2!#2!% \fi \else \ifnum#1=#2 % @@ -2519,77 +2755,77 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@DivStart} +% \begin{macro}{\InCa@DivStart} % \begin{macrocode} -\def\IntCalc@DivStart#1!#2#3!#4#5{% +\def\InCa@DivStart#1!#2#3!#4#5{% \ifx#5!% \@ReturnAfterElseFi{% - \IntCalc@DivStartI{#1#2}#3=!% + \InCa@DivStartI{#1#2}#3=!% }% \else \@ReturnAfterFi{% - \IntCalc@DivStart{#1#2}!#3!#5% + \InCa@DivStart{#1#2}!#3!#5% }% \fi } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@StartI} +% \begin{macro}{\InCa@StartI} % \begin{macrocode} -\def\IntCalc@DivStartI#1!#2!{% - \expandafter\IntCalc@DivStartII +\def\InCa@DivStartI#1!#2!{% + \expandafter\InCa@DivStartII \number#2\expandafter\expandafter\expandafter!% \intcalcShl{#2}!% #1!% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@StartII} +% \begin{macro}{\InCa@StartII} % \begin{macrocode} -\def\IntCalc@DivStartII#1!#2!{% - \expandafter\IntCalc@DivStartIII +\def\InCa@DivStartII#1!#2!{% + \expandafter\InCa@DivStartIII \number#1\expandafter!% \number#2\expandafter\expandafter\expandafter!% \intcalcShl{#2}!% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@StartIII} +% \begin{macro}{\InCa@StartIII} % \begin{macrocode} -\def\IntCalc@DivStartIII#1!#2!#3!{% - \expandafter\IntCalc@DivStartIV +\def\InCa@DivStartIII#1!#2!#3!{% + \expandafter\InCa@DivStartIV \number#1\expandafter!% \number#2\expandafter!% \number#3\expandafter!% - \number\IntCalc@Add#3!#2!\expandafter\expandafter\expandafter!% + \number\InCa@Add#3!#2!\expandafter\expandafter\expandafter!% \intcalcShl{#3}!% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@StartIV} +% \begin{macro}{\InCa@StartIV} % \begin{macrocode} -\def\IntCalc@DivStartIV#1!#2!#3!#4!#5!#6!{% - \IntCalc@ProcessDiv#6!#1!#2!#3!#4!#5!/% +\def\InCa@DivStartIV#1!#2!#3!#4!#5!#6!{% + \InCa@ProcessDiv#6!#1!#2!#3!#4!#5!/% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ProcessDiv} +% \begin{macro}{\InCa@ProcessDiv} % \begin{macrocode} -\def\IntCalc@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9/{% +\def\InCa@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9/{% #9% \ifnum#1<#4 % 0 0% \ifx#2=% \else - \IntCalc@ProcessDiv{#1#2}#3!#4!#5!#6!#7!#8!% + \InCa@ProcessDiv{#1#2}#3!#4!#5!#6!#7!#8!% \fi \else % 1-9 \ifnum#1<#5 % 1 1% \ifx#2=% \else - \expandafter\IntCalc@ProcessDiv\expandafter{% - \number\IntCalc@Sub#1!#4!% + \expandafter\InCa@ProcessDiv\expandafter{% + \number\InCa@Sub#1!#4!% #2% }#3!#4!#5!#6!#7!#8!% \fi @@ -2597,14 +2833,14 @@ and the derived files \ifnum#1<#7 % 2 3 4 5 \ifnum#1<#6 % 2 3 \@ReturnAfterElseFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#5!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#5!!% 23% }% \else % 4 5 \@ReturnAfterFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#6!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#6!!% 45% }% \fi @@ -2612,14 +2848,14 @@ and the derived files \else % 6 7 8 9 \ifnum#1<#8 % 6 7 \@ReturnAfterElseFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#7!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#7!!% 67% }% \else % 8 9 \@ReturnAfterFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#8!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#8!!% 89% }% \fi @@ -2628,23 +2864,23 @@ and the derived files \fi \fi \ifx#2=% - \expandafter\IntCalc@Gobble + \expandafter\@gobble \fi /% } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@@ProcessDiv} +% \begin{macro}{\InCa@@ProcessDiv} % \begin{macrocode} -\def\IntCalc@@ProcessDiv#1!#2#3#4#5!#6!{% +\def\InCa@@ProcessDiv#1!#2#3#4#5!#6!{% \ifnum#1<#6 % #2% \@ReturnAfterElseFi{% \ifx#4=% - \expandafter\IntCalc@CleanupIV + \expandafter\InCa@CleanupIV \else \@ReturnAfterFi{% - \IntCalc@ProcessDiv{#1#4}#5!#6!% + \InCa@ProcessDiv{#1#4}#5!#6!% }% \fi }% @@ -2652,11 +2888,11 @@ and the derived files #3% \@ReturnAfterFi{% \ifx#4=% - \expandafter\IntCalc@CleanupIV + \expandafter\InCa@CleanupIV \else \@ReturnAfterFi{% - \expandafter\IntCalc@ProcessDiv\expandafter{% - \number\IntCalc@Sub#1!#6!\IntCalc@Space + \expandafter\InCa@ProcessDiv\expandafter{% + \number\InCa@Sub#1!#6! % #4% }#5!#6!% }% @@ -2666,9 +2902,9 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@CleanupIV} +% \begin{macro}{\InCa@CleanupIV} % \begin{macrocode} -\def\IntCalc@CleanupIV#1!#2!#3!#4!{} +\def\InCa@CleanupIV#1!#2!#3!#4!{} % \end{macrocode} % \end{macro} % @@ -2677,7 +2913,7 @@ and the derived files % \begin{macro}{\intcalcMod} % \begin{macrocode} \def\intcalcMod#1#2{% - \number\expandafter\IntCalc@Mod + \number\expandafter\InCa@Mod \number\number#1\expandafter!% \number#2! % } @@ -2693,19 +2929,19 @@ and the derived files % elsif & $y=1$ & 0\\ % elsif & $y=2$ & $\opOdd(x)\mathbin{?}1\mathbin{:}0$\\ % elsif & $x<0$ & -% $z\leftarrow x+(x/y)*x;\quad (z<0)\mathbin{?}z+x\mathbin{:}z$\\ -% else & & $x-(x/y)*x$\\ +% $z\leftarrow x-(x/y)*y;\quad (z<0)\mathbin{?}z+y\mathbin{:}z$\\ +% else & & $x-(x/y)*y$\\ % \\ % \end{tabular} % \end{quote} % \begin{macrocode} -\def\IntCalc@Mod#1!#2!{% +\def\InCa@Mod#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifnum#2<\z@ -% - \expandafter\IntCalc@Mod + \expandafter\InCa@Mod \number-#1\expandafter!% \number-#2!% \else @@ -2717,24 +2953,20 @@ and the derived files \or % 1 0% \or % 2 - \ifodd#1 % - 1% - \else - 0% - \fi + \ifodd#1 1\else 0\fi \else \ifnum#1<\z@ - \expandafter\IntCalc@ModShift + \expandafter\InCa@ModShift \number-% - \expandafter\IntCalc@Sub - \number\IntCalc@Gobble#1\expandafter!% + \expandafter\InCa@Sub + \number\@gobble#1\expandafter!% \number\intcalcMul{#2}{% - \expandafter\IntCalc@Div\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Div\@gobble#1!#2!% }!% !#2!% \else - \expandafter\IntCalc@Sub\number#1\expandafter!% - \number\intcalcMul{#2}{\IntCalc@Div#1!#2!}!% + \expandafter\InCa@Sub\number#1\expandafter!% + \number\intcalcMul{#2}{\InCa@Div#1!#2!}!% \fi \fi \fi @@ -2743,12 +2975,41 @@ and the derived files } % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@ModShift} +% \begin{macro}{\IntCalcMod} % \begin{macrocode} -\def\IntCalc@ModShift#1!#2!{% +\def\InCa@Temp#1{% + \def\IntCalcMod##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \ifcase##2 % 0 already catched +? \IntCalcError:ThisCannotHappen + \or % 1 + 0% + \or % 2 + \ifodd ##1 1\else 0\fi + \else + \expandafter\InCa@Sub\number##1\expandafter!% + \number\intcalcMul{##2}{\InCa@Div##1!##2!}!% + \fi + \fi + \fi + #1% + }% +} +\InCa@Temp{ }% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\InCa@ModShift} +% \begin{macrocode} +\def\InCa@ModShift#1!#2!{% \ifnum#1<\z@ - \expandafter\IntCalc@Sub\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Sub\number#2\expandafter!% + \@gobble#1!% \else #1% \fi @@ -2758,14 +3019,16 @@ and the derived files % % \subsubsection{Help macros} % -% \begin{macro}{\IntCalc@Empty} +% \begin{macro}{\InCa@Empty} % \begin{macrocode} -\def\IntCalc@Empty{} +\def\InCa@Empty{} % \end{macrocode} % \end{macro} -% \begin{macro}{\IntCalc@Gobble} +% \begin{macro}{\@gobble} % \begin{macrocode} -\def\IntCalc@Gobble#1{} +\expandafter\ifx\csname @gobble\endcsname\relax + \long\def\@gobble#1{}% +\fi % \end{macrocode} % \end{macro} % \begin{macro}{\@ReturnAfterFi} @@ -2780,7 +3043,7 @@ and the derived files % \end{macro} % % \begin{macrocode} -\IntCalc@AtEnd +\InCa@AtEnd % \end{macrocode} % % \begin{macrocode} @@ -2846,22 +3109,22 @@ and the derived files % \subsubsection{Preamble with test macro definitions} % % \begin{macrocode} -%<*test2|test3|test4> +%<*test2|test4> \NeedsTeXFormat{LaTeX2e} \nofiles \documentclass{article} %<noetex>\let\SavedNumexpr\numexpr %<noetex>\let\numexpr\UNDEFINED \makeatletter -\chardef\IntCalc@TestMode=1 % +\chardef\InCa@TestMode=1 % \makeatother -\usepackage{intcalc}[2007/09/09] +\usepackage{intcalc}[2007/09/27] %<noetex>\let\numexpr\SavedNumexpr \usepackage{qstest} \IncludeTests{*} \LogTests{log}{*}{*} -%</test2|test3|test4> -%<*test2|test3> +%</test2|test4> +%<*test2> \newcommand*{\TestSpaceAtEnd}[1]{% %<noetex> \let\SavedNumexpr\numexpr %<noetex> \let\numexpr\UNDEFINED @@ -2904,6 +3167,9 @@ and the derived files \newcommand*{\TestInv}[2]{% \Test{\intcalcInv{#1}}{#2}% } +\newcommand*{\TestNum}[2]{% + \Test{\intcalcNum{#1}}{#2}% +} \newcommand*{\TestAbs}[2]{% \Test{\intcalcAbs{#1}}{#2}% } @@ -2921,24 +3187,92 @@ and the derived files } \newcommand*{\TestInc}[2]{% \Test{\intcalcInc{#1}}{#2}% + \ifnum\intcalcNum{#1}>-1 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcInc\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestDec}[2]{% \Test{\intcalcDec{#1}}{#2}% + \ifnum\intcalcNum{#1}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDec\intcalcNum{#1}!% + }{#2}% + }% + \x + \fi } \newcommand*{\TestAdd}[3]{% \Test{\intcalcAdd{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \else + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcAdd + \intcalcNum{#2}!\intcalcNum{#1}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestSub}[3]{% \Test{\intcalcSub{#1}{#2}}{#3}% + \ifnum\intcalcNum{#1}>0 % + \ifnum\intcalcNum{#2}> 0 % + \ifnum\intcalcCmp{#1}{#2}>0 % + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcSub + \intcalcNum{#1}!\intcalcNum{#2}!% + }{#3}% + }% + \x + \fi + \fi + \fi } \newcommand*{\TestShl}[2]{% \Test{\intcalcShl{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShl\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestShr}[2]{% \Test{\intcalcShr{#1}}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcShr\intcalcAbs{#1}!% + }{\intcalcAbs{#2}}% + }% + \x } \newcommand*{\TestMul}[3]{% \Test{\intcalcMul{#1}{#2}}{#3}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMul\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x } \newcommand*{\TestSqr}[2]{% \Test{\intcalcSqr{#1}}{#2}% @@ -2952,11 +3286,85 @@ and the derived files \newcommand*{\TestDiv}[3]{% \Test{\intcalcDiv{#1}{#2}}{#3}% \TestTeXDivide{#1}{#2}% + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcDiv\intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% } \newcommand*{\TestMod}[3]{% \Test{\intcalcMod{#1}{#2}}{#3}% + \ifcase\ifcase\intcalcSgn{#1} 0% + \or + \ifcase\intcalcSgn{#2} 1% + \or 0% + \else 1% + \fi + \else + \ifcase\intcalcSgn{#2} 1% + \or 1% + \else 0% + \fi + \fi\relax + \edef\x{% + \noexpand\Test{% + \noexpand\IntCalcMod + \intcalcAbs{#1}!\intcalcAbs{#2}!% + }{\intcalcAbs{#3}}% + }% + \x + \fi } -%</test2|test3> +%</test2> +% \end{macrocode} +% +% \subsubsection{Time} +% +% \begin{macrocode} +%<*test2> +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +%</test2> +% \end{macrocode} +% +% \subsubsection{Test 4: additional mod/div operations} +% +% \begin{macrocode} %<*test4> \newcommand*{\TestDo}[2]{% \ifcase\numexpr#2\relax @@ -2978,6 +3386,7 @@ and the derived files \TestDo{#1}{#2}% \TestDo{#2}{#1}% } +\let\TestNum\TestOne \let\TestInv\TestOne \let\TestAbs\TestOne \let\TestSgn\TestOne @@ -3002,9 +3411,30 @@ and the derived files % \subsubsection{Test sets} % % \begin{macrocode} -%<*test2|test3|test4> +%<*test2|test4> \makeatletter +\begin{qstest}{num}{num}% + \TestNum{0}{0}% + \TestNum{1}{1}% + \TestNum{-1}{-1}% + \TestNum{10}{10}% + \TestNum{-10}{-10}% + \TestNum{2147483647}{2147483647}% + \TestNum{-2147483647}{-2147483647}% + \TestNum{ 0 }{0}% + \TestNum{ 1 }{1}% + \TestNum{--1}{1}% + \TestNum{ - + - + 4 }{4}% + \TestNum{\z@}{0}% + \TestNum{\@ne}{1}% + \TestNum{\m@ne}{-1}% +%<*etex> + \TestNum{-10+30}{20}% + \TestNum{10-30}{-20}% +%</etex> +\end{qstest} + \begin{qstest}{inv}{inv}% \TestInv{0}{0}% \TestInv{1}{-1}% @@ -3224,6 +3654,8 @@ and the derived files \TestShl{1}{2}% \TestShl{5621}{11242}% \TestShl{1073741823}{2147483646}% + \TestShl{-1}{-2}% + \TestShl{-5621}{-11242}% \end{qstest} \begin{qstest}{shr}{shr} @@ -3253,6 +3685,10 @@ and the derived files \TestShr{11241}{5620}% \TestShr{73054202}{36527101}% \TestShr{2147483646}{1073741823}% + \TestShr{-1}{0}% + \TestShr{-2}{-1}% + \TestShr{-3}{-1}% + \TestShr{-11241}{-5620}% \end{qstest} \begin{qstest}{mul}{mul} @@ -3473,9 +3909,9 @@ and the derived files \TestMod{1+2}{1-5}{-1}% %</etex> \end{qstest} -%</test2|test3|test4> +%</test2|test4> -%<*test2|test3> +%<*test2> \newcommand*{\TestError}[2]{% \begingroup \expandafter\def\csname IntCalcError:#1\endcsname{}% @@ -3489,18 +3925,18 @@ and the derived files \TestError{FacNegative}{\intcalcFac{-2147483647}}% \TestError{FacOverflow}{\intcalcFac{13}}% \TestError{FacOverflow}{\intcalcFac{2147483647}}% - \TestError{ShlNegativeNumber}{\intcalcShl{-1}}% - \TestError{ShrNegativeNumber}{\intcalcShr{-1}}% \TestError{DivisionByZero}{\intcalcPow{0}{-1}}% \TestError{DivisionByZero}{\intcalcDiv{1}{0}}% \TestError{DivisionByZero}{\intcalcMod{1}{0}}% + \TestError{DivisionByZero}{\IntCalcDiv1!0!}% + \TestError{DivisionByZero}{\IntCalcMod1!0!}% \end{qstest} -%</test2|test3> +%</test2> -%<*test2|test3|test4> +%<*test2|test4> \begin{document} \end{document} -%</test2|test3|test4> +%</test2|test4> % \end{macrocode} % % \section{Installation} @@ -3693,6 +4129,21 @@ and the derived files % \item % First version. % \end{Version} +% \begin{Version}{2007/09/27 v1.1} +% \item +% \cs{intcalcNum} added. +% \item +% \cs{intcalcShl} and \cs{intcalcShr} allow negative numbers. +% The sign is preserved. +% \item +% Reuse \cs{@gobble} instead of own macro \cs{IntCalc@Gobble}. +% \item +% Small fixes. +% \item +% Shorter internal prefix. +% \item +% Some programmer's interface. +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/kvoptions.dtx b/Master/texmf-dist/source/latex/oberdiek/kvoptions.dtx index 03b34445f49..9148014c921 100644 --- a/Master/texmf-dist/source/latex/oberdiek/kvoptions.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/kvoptions.dtx @@ -18,7 +18,7 @@ % This work consists of the main source file kvoptions.dtx % and the derived files % kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, -% example-mycolorsetup.sty. +% example-mycolorsetup.sty, kvoptions-test1.tex. % % Distribution: % CTAN:macros/latex/contrib/oberdiek/kvoptions.dtx @@ -54,6 +54,7 @@ % TDS:tex/latex/oberdiek/kvoptions.sty % TDS:doc/latex/oberdiek/kvoptions.pdf % TDS:doc/latex/oberdiek/example-mycolorsetup.sty +% TDS:doc/latex/oberdiek/kvoptions-test1.tex % TDS:source/latex/oberdiek/kvoptions.dtx % %<*ignore> @@ -69,7 +70,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: kvoptions 2007/06/11 v2.7 Connects package keyval with LaTeX options (HO)} +\Msg{* Package: kvoptions 2007/10/02 v2.8 Connects package keyval with LaTeX options (HO)} \Msg{************************************************************************} \keepsilent @@ -97,7 +98,7 @@ This Current Maintainer of this work is Heiko Oberdiek. This work consists of the main source file kvoptions.dtx and the derived files kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, - example-mycolorsetup.sty. + example-mycolorsetup.sty, kvoptions-test1.tex. \endpreamble @@ -108,6 +109,7 @@ and the derived files \file{kvoptions.sty}{\from{kvoptions.dtx}{package}}% \usedir{doc/latex/oberdiek}% \file{example-mycolorsetup.sty}{\from{kvoptions.dtx}{example}}% + \file{kvoptions-test1.tex}{\from{kvoptions.dtx}{test1}}% } \obeyspaces @@ -133,7 +135,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{kvoptions.drv}% - [2007/06/11 v2.7 Connects package keyval with LaTeX options (HO)]% + [2007/10/02 v2.8 Connects package keyval with LaTeX options (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -142,7 +144,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{1536} +% \CheckSum{1741} % % \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 @@ -163,7 +165,7 @@ and the derived files % \GetFileInfo{kvoptions.drv} % % \title{The \xpackage{kvoptions} package} -% \date{2007/06/11 v2.7} +% \date{2007/10/02 v2.8} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -280,7 +282,7 @@ and the derived files % knows the family name already and you can use the star form % without mandatory argument. % -% Note, neither of the following commands are necessary for +% Neither of the following macros are necessary for % \cs{ProcessKeyvalOptions{}}. They just help the package/class % author in common tasks. % @@ -297,7 +299,7 @@ and the derived files % description of the default looks a little weird, therefor % an example is given for a package or class named |foobar|. % \begin{quote} -% \begin{tabular}{l|ll|l} +% \begin{tabular}{@{}l|ll|l@{}} % Key & Default & (example) & Used by\\ % \hline % \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A @@ -347,7 +349,7 @@ and the derived files % % Example for a package with the following two lines: % \begin{quote} -% |\ProvidedPackage{foobar}|\\ +% |\ProvidesPackage{foobar}|\\ % |\DeclareStringOption[me]{name}| % \end{quote} % Then \cs{DeclareStringOption} defines the macro with content |me|, @@ -414,7 +416,7 @@ and the derived files % \begin{declcs}{DeclareComplementaryOption}\,\M{key}\,\M{parent} % \end{declcs} % Sometimes contrasting names are used to characterize the -% two states of a boolean switch, for example \xoption{final} +% two states of a boolean switch, for example \xoption{draft} % vs.\@ \xoption{final}. Both options behave like boolean % options but they do not need to different switches, they % should share one. \cs{DeclareComplementaryOption} allows this. @@ -454,17 +456,19 @@ and the derived files % % \begin{declcs}{DeclareDefaultOption}\,\M{code} % \end{declcs} -% This command does not define a key, it is the equivalent +% \begin{sloppypar} +% This command does not define a specific key, it is the equivalent % to \LaTeX's \cs{DeclareOption*}. It allows the specification % of a default action \meta{code} that is invoked if an unknown option % is found. -% During the execution of \meta{code} -% \cs{CurrentOption} contains the current option string. -% Additionally \cs{CurrentOptionValue} contains the value part +% While \meta{code} is called, +% macro \cs{CurrentOption} contains the current option string. +% In addition \cs{CurrentOptionValue} contains the value part % if the option string is parsable as key value pair, otherwise % it is \cs{relax}. \cs{CurrentOptionKey} contains the key of % the key value pair, or the whole option string, if it misses % the equal sign. +% \end{sloppypar} % % Inside packages typical default actions are to pass unknown % options to another package. Or an error message can be thrown @@ -494,7 +498,8 @@ and the derived files % \xpackage{hyperref} the link colors can be changed % everywhere until the end in |\end{document}|. % -% However package \xpackage{color} is necessary and it +% However package \xpackage{color} that adds color support +% is necessary and it % cannot be loaded after |\begin{document}|. Option \xoption{colorlinks} % that loads \xpackage{color} should be active until |\begin{document}| % and die in some way if it is too late for loading packages. @@ -547,7 +552,7 @@ and the derived files % must be provided. % % Usually a macro would configure the option death, Example: -% \begin{quote} +%\begin{quote} %\begin{verbatim} %\ProvidesPackage{foobar} %\DeclareBoolOption{color} @@ -573,10 +578,10 @@ and the derived files %% No we don't need the option 'color'. %\foobar@DisableOption{warning}{color} % -%% With color support option 'emphcolor' will dynamically change -%% the color of \emph statements. +%% With color support option 'emphcolor' will dynamically +%% change the color of \emph statements. %\end{verbatim} -% \end{quote} +%\end{quote} % % \subsection{Summary of internal macros} % @@ -585,13 +590,13 @@ and the derived files % These macros can be used by the package/class author. % The name of the macros starts with the prefix \meta{prefix} % that can be configured by \cs{SetupKeyvalOptions}. -% \begin{quote} +% \begin{center} % \def\prefix{\cs{}\meta{prefix}\meta{key}}^^A % \def\Hline{^^A % \hline % \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A % }^^A -% \begin{tabular}{l|>{\ttfamily}l|l} +% \begin{tabular}{@{}l|>{\ttfamily}l|l@{}} % Declare \meta{key} & \textrm{Defined macro} & Description\\ % \Hline % \cs{DeclareStringOption} @@ -609,7 +614,17 @@ and the derived files % \cs{DeclareVoidOption} % & \prefix & holds the action % \end{tabular} -% \end{quote} +% \end{center} +% +% \subsection{\plainTeX} +% +% Package \xpackage{keyval} is also usable in \plainTeX\ with +% the help of file \xfile{miniltx.tex}. Some features of this +% package \xpackage{kvoptions} might also be useful for \plainTeX. +% If \LaTeX\ is not found, \cs{ProcessKeyvalOptions} and option +% \xoption{patch} are disabled. Before using the option declaration +% commands \cs{Declare...Option}, \cs{SetupKeyvalOptions} must be +% used. % % \hypersetup{bookmarksopenlevel=1} % @@ -626,7 +641,7 @@ and the derived files % Package identification % ----------------------- \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{example-mycolorsetup}[2007/06/11 Managing my colors] +\ProvidesPackage{example-mycolorsetup}[2007/10/02 Managing my colors] \RequirePackage{ifpdf} \RequirePackage{kvoptions} @@ -684,7 +699,8 @@ and the derived files }% % Pass the option to package color. % Again it is better to expand \CurrentOption. - \expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{color}% + \expandafter\PassOptionsToPackage + \expandafter{\CurrentOption}{color}% \else % Package color does not take options with values. % We provide the standard LaTeX error. @@ -875,8 +891,8 @@ and the derived files % % \subsubsection{Option comparisons} % -% In some situations \LaTeX\ compares options, e.g. option clash check, -% \cs{@ifpackagewith}, \cs{@ifclasswith}. Apart from catcode and +% In some situations \LaTeX\ compares option lists, e.g. option clash check, +% \cs{@ifpackagewith}, or \cs{@ifclasswith}. Apart from catcode and % sanitizing problems of option \xoption{patch}, there is another problem. % \LaTeX\ does not know about the type and default values of % options in key value style. Thus an option clash is reported, @@ -884,7 +900,7 @@ and the derived files % \begin{quote} % |\usepackage[scaled]{helvet} %| \texttt{\textit{default is }.95}\\ % |\usepackage[.95]{helvet}|\\ -% |\usepackage[0.95]{helvet}|\\ +% |\usepackage[0.95]{helvet}| % \end{quote} % % \subsubsection{Option list parsing with option \xoption{patch}} @@ -923,12 +939,101 @@ and the derived files % \section{Implementation} % % \subsection{Preamble} -% \paragraph{Package identification.} +% % \begin{macrocode} %<*package> -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{kvoptions} - [2007/06/11 v2.7 Connects package keyval with LaTeX options (HO)]% +% \end{macrocode} +% +% \paragraph{Reload check and 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@kvoptions.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{kvoptions}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +% \end{macrocode} +% Package identification: +% \begin{macrocode} +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@kvoptions.sty\endcsname +\ProvidesPackage{kvoptions}% + [2007/10/02 v2.8 Connects package keyval with LaTeX options (HO)] +% \end{macrocode} +% +% \paragraph{Catcodes} +% +% \begin{macrocode} +\expandafter\edef\csname KVO@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\KVO@AtEnd{% + \KVO@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{1}{14}% ^^A (comment) +\TMP@EnsureCode{2}{14}% ^^A (comment) +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{12}% : +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{94}{7}% ^ (superscript) +\TMP@EnsureCode{96}{12}% ` % \end{macrocode} % % \paragraph{External resources.} @@ -938,7 +1043,33 @@ and the derived files % \cs{SetupKeyvalOptions}. AFAIK this does not disturb % users of \xpackage{xkeyval}. % \begin{macrocode} -\RequirePackage{keyval} +\@ifundefined{define@key}{% + \RequirePackage{keyval}\relax +}{} +% \end{macrocode} +% +% \paragraph{Provide macros for \plainTeX.} +% \begin{macrocode} +\@ifundefined{@onelevel@sanitize}{% + \def\@onelevel@sanitize#1{% + \edef#1{\expandafter\strip@prefix\meaning#1}% + }% +}{} +\@ifundefined{strip@prefix}{% + \def\strip@prefix#1>{}% +}{} +\@ifundefined{@x@protect}{% + \def\@x@protect#1\fi#2#3{% + \fi\protect#1% + }% + \let\@typeset@protect\relax +}{} +\@ifundefined{@currname}{% + \def\@currname{}% +}{} +\@ifundefined{@currext}{% + \def\@currext{}% +}{} % \end{macrocode} % % \paragraph{Options} @@ -946,16 +1077,6 @@ and the derived files % code that prints information into the \xfile{.log} % file. % \begin{macrocode} -\begingroup - \edef\x{\endgroup - \noexpand\AtEndOfPackage{% - \catcode\@ne=\the\catcode\@ne\relax - \catcode\tw@=\the\catcode\tw@\relax - }% - }% -\x -\catcode\@ne=14 % -\catcode\tw@=14 % \DeclareOption{debugshow}{\catcode\@ne=9 } % \end{macrocode} % @@ -986,7 +1107,8 @@ and the derived files % class/package system. % \begin{macrocode} \define@key{KVO}{family}{% - \expandafter\edef\csname KVO@family@\@currname.\@currext\endcsname{#1}% + \expandafter\edef\csname KVO@family@% + \@currname.\@currext\endcsname{#1}% } \def\KVO@family{% \@ifundefined{KVO@family@\@currname.\@currext}{% @@ -999,7 +1121,7 @@ and the derived files % \end{macro} % % \begin{macro}{\KVO@prefix} -% The value settings of options, declared by \cs{DeclareBoolOption} +% The value settings of options that are declared by \cs{DeclareBoolOption} % and \cs{DeclareStringOption} need to be saved in macros. % in the first case this is a switch \cs{if}\meta{prefix}\meta{key}, % in the latter case a macro \cs{}\meta{prefix}\meta{key}. @@ -1007,7 +1129,8 @@ and the derived files % here. The default is the package name with |@| appended. % \begin{macrocode} \define@key{KVO}{prefix}{% - \expandafter\edef\csname KVO@prefix@\@currname.\@currext\endcsname{#1}% + \expandafter\edef\csname KVO@prefix@% + \@currname.\@currext\endcsname{#1}% } \def\KVO@prefix{% \@ifundefined{KVO@prefix@\@currname.\@currext}{% @@ -1050,7 +1173,8 @@ and the derived files \KVO@ifdefinable{if\KVO@prefix#2}{% \KVO@ifdefinable{\KVO@prefix#2true}{% \KVO@ifdefinable{\KVO@prefix#2false}{% - \expandafter\newif\csname if\KVO@prefix#2\endcsname + \csname newif\expandafter\endcsname + \csname if\KVO@prefix#2\endcsname \@ifundefined{\KVO@prefix#2#1}{% \PackageWarning{kvoptions}{% Initialization of option `#2' failed,\MessageBreak @@ -1097,8 +1221,10 @@ and the derived files You are inside % \ifx\@currext\@clsextension class\else package\fi\space `\@currname.\@currext'.\MessageBreak - `\KVO@family' is used as familiy for the keyval options.\MessageBreak - `\KVO@prefix' serves as prefix for internal switch macros.\MessageBreak + `\KVO@family' is used as familiy % + for the keyval options.\MessageBreak + `\KVO@prefix' serves as prefix % + for internal switch macros.\MessageBreak \MessageBreak \@ehc }% @@ -1501,7 +1627,8 @@ and the derived files \ifx\@classoptionslist\relax \else \@for\KVO@CurrentOption:=\@classoptionslist\do{% - \@ifundefined{KV@#1@\expandafter\KVO@getkey\KVO@CurrentOption=\@nil}{% + \@ifundefined{KV@#1@\expandafter\KVO@getkey + \KVO@CurrentOption=\@nil}{% }{% \edef\KVO@temp{% ^^B \etex@unexpanded\expandafter{% @@ -1658,12 +1785,27 @@ and the derived files % \end{macrocode} % \end{macro} % +% \subsection{\plainTeX} +% +% Disable \LaTeX\ stuff. +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname documentclass\endcsname\relax + \def\ProcessKeyvalOptions{% + \@ifstar{}\@gobble + }% + \catcode\tw@=14 % +\fi +% \end{macrocode} +% % \subsection{Patch} % -% Caution: docstrip stops at \cs{endinput} at begin of line! +% Caution: docstrip stops at \cs{endinput} if it starts a line. +% \begin{macrocode} +^^B\@gobbletwo +\KVO@AtEnd\endinput +% \end{macrocode} % \begin{macrocode} -^^B\@gobble - \endinput \PackageInfo{kvoptions}{Patching LaTeX's option system} % \end{macrocode} % @@ -1874,11 +2016,15 @@ and the derived files } \def\KVO@ExecuteOptions#1#2{% \let#1\CurrentOption - \edef\CurrentOption@SaveLevel{\the\numexpr\CurrentOption@SaveLevel+1}% + \edef\CurrentOption@SaveLevel{% + \the\numexpr\CurrentOption@SaveLevel+1% + }% \@for\CurrentOption:=#2\do{% \csname ds@\CurrentOption\endcsname }% - \edef\CurrentOption@SaveLevel{\the\numexpr\CurrentOption@SaveLevel-1}% + \edef\CurrentOption@SaveLevel{% + \the\numexpr\CurrentOption@SaveLevel-1% + }% \let\CurrentOption#1% } % \end{macrocode} @@ -1910,7 +2056,8 @@ and the derived files \else \ifx\relax##1\relax \else - \KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]\@pkgextension + \KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]% + \@pkgextension \fi \expandafter\reserved@b \fi @@ -2149,9 +2296,72 @@ and the derived files % \end{macrocode} % % \begin{macrocode} +KVO@AtEnd %</package> % \end{macrocode} % +% \section{Test} +% +% \subsection{Preface for standard catcode check} +% +% \begin{macrocode} +%<*test1> +\input miniltx.tex\relax +%</test1> +% \end{macrocode} +% +% \subsection{Catcode checks for loading} +% +% \begin{macrocode} +%<*test1> +% \end{macrocode} +% \begin{macrocode} +\catcode`\@=11 % +\def\RestoreCatcodes{} +\count@=0 % +\loop + \edef\RestoreCatcodes{% + \RestoreCatcodes + \catcode\the\count@=\the\catcode\count@\relax + }% +\ifnum\count@<255 % + \advance\count@\@ne +\repeat + +\def\RangeCatcodeInvalid#1#2{% + \count@=#1\relax + \loop + \catcode\count@=15 % + \ifnum\count@<#2\relax + \advance\count@\@ne + \repeat +} +\def\Test{% + \RangeCatcodeInvalid{0}{47}% + \RangeCatcodeInvalid{58}{64}% + \RangeCatcodeInvalid{91}{96}% + \RangeCatcodeInvalid{123}{255}% + \catcode`\@=12 % + \catcode`\\=0 % + \catcode`\{=1 % + \catcode`\}=2 % + \catcode`\#=6 % + \catcode`\[=12 % + \catcode`\]=12 % + \catcode`\%=14 % + \catcode`\ =10 % + \catcode13=5 % + \input kvoptions.sty\relax + \RestoreCatcodes +} +\Test +\csname @@end\endcsname +\end +% \end{macrocode} +% \begin{macrocode} +%</test1> +% \end{macrocode} +% % \section{Installation} % % \subsection{Download} @@ -2214,6 +2424,7 @@ and the derived files % kvoptions.sty & tex/latex/oberdiek/kvoptions.sty\\ % kvoptions.pdf & doc/latex/oberdiek/kvoptions.pdf\\ % example-mycolorsetup.sty & doc/latex/oberdiek/example-mycolorsetup.sty\\ +% kvoptions-test1.tex & doc/latex/oberdiek/kvoptions-test1.tex\\ % kvoptions.dtx & source/latex/oberdiek/kvoptions.dtx\\ % \end{tabular}^^A % }^^A @@ -2416,7 +2627,7 @@ and the derived files % \begin{Version}{2006/08/22 v2.4} % \item % Option \xoption{patch}: \cs{ExecuteOptions} does not -% change meaning of \cs{CurrentOption} at all. +% change the meaning of macro \cs{CurrentOption} at all. % \end{Version} % \begin{Version}{2007/04/11 v2.5} % \item @@ -2430,6 +2641,12 @@ and the derived files % \item % The patch part fixes LaTeX bug latex/3965. % \end{Version} +% \begin{Version}{2007/10/02 v2.8} +% \item +% Compatibility for \plainTeX\ added. +% \item +% Typos in documentation fixed (Axel Sommerfeldt). +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx b/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx index 6d9d13470f6..7c4bd21a780 100644 --- a/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx @@ -17,7 +17,8 @@ % This work consists of the main source file kvsetkeys.dtx % and the derived files % kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, -% kvsetkeys-example.tex, kvsetkeys-test1.tex. +% kvsetkeys-example.tex, kvsetkeys-test1.tex, +% kvsetkeys-test2.tex, kvsetkeys-test3.tex. % % Distribution: % CTAN:macros/latex/contrib/oberdiek/kvsetkeys.dtx @@ -54,6 +55,8 @@ % TDS:doc/latex/oberdiek/kvsetkeys.pdf % TDS:doc/latex/oberdiek/kvsetkeys-example.tex % TDS:doc/latex/oberdiek/kvsetkeys-test1.tex +% TDS:doc/latex/oberdiek/kvsetkeys-test2.tex +% TDS:doc/latex/oberdiek/kvsetkeys-test3.tex % TDS:source/latex/oberdiek/kvsetkeys.dtx % %<*ignore> @@ -69,7 +72,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: kvsetkeys 2007/09/09 v1.2 Key value parser with default handler support (HO)} +\Msg{* Package: kvsetkeys 2007/09/29 v1.3 Key value parser with default handler support (HO)} \Msg{************************************************************************} \keepsilent @@ -96,7 +99,8 @@ This Current Maintainer of this work is Heiko Oberdiek. This work consists of the main source file kvsetkeys.dtx and the derived files kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, - kvsetkeys-example.tex, kvsetkeys-test1.tex. + kvsetkeys-example.tex, kvsetkeys-test1.tex, + kvsetkeys-test2.tex, kvsetkeys-test3.tex. \endpreamble @@ -108,6 +112,8 @@ and the derived files \usedir{doc/latex/oberdiek}% \file{kvsetkeys-example.tex}{\from{kvsetkeys.dtx}{example}}% \file{kvsetkeys-test1.tex}{\from{kvsetkeys.dtx}{test1}}% + \file{kvsetkeys-test2.tex}{\from{kvsetkeys.dtx}{test2}}% + \file{kvsetkeys-test3.tex}{\from{kvsetkeys.dtx}{test2,noetex}}% } \obeyspaces @@ -133,7 +139,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{kvsetkeys.drv}% - [2007/09/09 v1.2 Key value parser with default handler support (HO)]% + [2007/09/29 v1.3 Key value parser with default handler support (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} @@ -142,7 +148,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{625} +% \CheckSum{1010} % % \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 @@ -163,7 +169,7 @@ and the derived files % \GetFileInfo{kvsetkeys.drv} % % \title{The \xpackage{kvsetkeys} package} -% \date{2007/09/09 v1.2} +% \date{2007/09/29 v1.3} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -182,8 +188,44 @@ and the derived files % % \section{Documentation} % -% \cs{kvsetkeys} can be used as replacement for \xpackage{keyval}'s -% \cs{setkeys}. Also it uses the same syntax. Before I describe +% \subsection{Motivation} +% +% \cs{kvsetkeys} serves as replacement for \xpackage{keyval}'s +% \cs{setkeys}. It basically uses the same syntax. But the +% implementation is more robust and predictable: +% \begin{description} +% \item[Active syntax characters:] +% Comma `|,|' and the equals sign `|=|' are used inside +% key value lists as syntax characters. Package \xpackage{keyval} +% uses the catcode of the characters that is active during +% package loading, usually this is catcode 12 (other). +% But it can happen that the catcode setting of the syntax characters +% changes. Especially active characters are of interest, because +% some language adaptations uses them. For example, option \xoption{turkish} +% of package \xpackage{babel} uses the equals sign as active shorthand +% character. Therefore package \xpackage{kvsetkeys} deals with +% both catcode settings 12 (other) and 13 (active). +% \item[Brace removal:] +% Package \xpackage{keyval}'s \cs{setkeys} removes up to two +% levels of curly braces around the value in some unpredictable way: +%\begin{quote} +%|\setkeys{fam}{key={{value}}} || || | $\rightarrow$ |value|\\ +%|\setkeys{fam}{key={{{value}}}} | $\rightarrow$ |{value}|\\ +%|\setkeys{fam}{key= {{{value}}}}| $\rightarrow$ |{{value}}| +%\end{quote} +% This package \xpackage{kvsetkeys} follows a much stronger rule: +% Exactly one level of braces are removed from an item, if the +% item is surrounded by curly braces. An item can be a +% the key value pair, the key or the value. +%\begin{quote} +%|\kvsetkeys{fam}{key={value}} || | $\rightarrow$ |value|\\ +%|\kvsetkeys{fam}{key={{value}} | $\rightarrow$ |{value}|\\ +%|\kvsetkeys{fam}{key= {{value}}| $\rightarrow$ |{value}| +%\end{quote} +% \item[Arbitrary values:] Unmatched conditionals are supported. +% \end{description} +% +% Before I describe % \cs{kvsetkeys} in more detail, first I want to explain, how % this package deals with key value lists. For the package also % provides low level interfaces that can be used by package authors. @@ -192,8 +234,8 @@ and the derived files % % \begin{declcs}{kv@normalize}\,\M{key value list} % \end{declcs} -% Specifying key value lists, the user usually wants to have -% nice formatted souce code, e.g.: +% If the user specifies key value lists, he usually prefers +% nice formatted source code, e.g.: % \begin{quote} %\begin{verbatim} %\hypersetup{ @@ -216,16 +258,25 @@ and the derived files % \begin{itemize} % \item Spaces are removed. % \item Syntax characters (comma and equal sign) that are active -% are replaces by the same characters with standard catcode. +% are replaced by the same characters with standard catcode. % (Example: \xpackage{babel}'s language option \xoption{turkish} % uses the equal sign as active shorthand character.) % \end{itemize} % The result is stored in \cs{kv@list}, e.g.: % \begin{quote} -% |\kv@list| $\rightarrow$ |,pdftitle={},pdfsubject={},...,| +% |\kv@list| $\rightarrow$ |,pdftitle={...},pdfsubject={...},...,| % \end{quote} +% Curly braces around values (or keys) remain untouched. +% \begin{description} +% \item[v1.3+:] +% One comma is added in front of the list and each pair ends with +% a comma. Thus an empty list consists of one comma, otherwise +% two commas encloses the list. Empty entries other than the first +% are removed. +% \item[v1.0 -- v1.2:] % Empty entries are removed later. In fact it adds a comma at the begin % and end to protect the last value and an easier implementation. +% \end{description} % % \subsection{Parsing key value lists} % @@ -297,7 +348,7 @@ and the derived files % can be used for the key and the value. If the value is not given, % \cs{kv@value} has the meaning \cs{relax}. % -% \subsection{Do it all} +% \subsection{Put it all together} % % \begin{declcs}{kvsetkeys}\,\M{family}\,\M{key value list} % \end{declcs} @@ -316,6 +367,31 @@ and the derived files % |\let\setkeys\kvsetkeys| % \end{quote} % +% \subsection{Comma separated lists} +% +% Since version 2007/09/29 v1.3 this package also supports the normalizing +% and parsing of general comma separated lists. +% +% \begin{declcs}{comma@normalize}\,\M{comma list} +% \end{declcs} +% Macro \cs{comma@normalize} normalizes the comma separated list, +% removes spaces around commas. The result is put in macro \cs{comma@list}. +% +% \begin{declcs}{comma@parse}\,\M{comma list}\,\M{processor} +% \end{declcs} +% Macro \cs{comma@parse} first normalizes the comma separated list +% and then parses the list by calling \cs{comma@parse@normalized}. +% +% \begin{declcs}{comma@parse@normalized}\,\M{normalized comma list}% +% \,\M{processor} +% \end{declcs} +% The list is parsed. Empty entries are ignored. \meta{processor} +% is called for each non-empty entry with the entry as argument: +% \begin{quote} +% \meta{processor}|{|\meta{entry}|}| +% \end{quote} +% Also the entry is stored in the macro \cs{comma@entry}. +% % \section{Example} % % The following example prints a short piece of HTML code using @@ -439,7 +515,7 @@ and the derived files \fi \expandafter\x\csname ver@kvsetkeys.sty\endcsname \ProvidesPackage{kvsetkeys}% - [2007/09/09 v1.2 Key value parser with default handler support (HO)] + [2007/09/29 v1.3 Key value parser with default handler support (HO)] % \end{macrocode} % % \begin{macrocode} @@ -454,6 +530,8 @@ and the derived files }% \catcode#1 #2\relax } +\TMP@EnsureCode{36}{3}% $ +\TMP@EnsureCode{38}{4}% & \TMP@EnsureCode{39}{12}% ' \TMP@EnsureCode{44}{12}% , \TMP@EnsureCode{46}{12}% . @@ -464,31 +542,112 @@ and the derived files \TMP@EnsureCode{126}{13}% ~ (active) % \end{macrocode} % +% \subsection{Package loading} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input infwarerr.sty\relax + \input etexcmds.sty\relax +\else + \RequirePackage{infwarerr}[2007/09/09]% + \RequirePackage{etexcmds}[2007/09/09]% +\fi +% \end{macrocode} +% +% \subsection{Check for \eTeX} +% +% \cs{unexpanded}, \cs{ifcsname}, and \cs{unless} are used if found. % \begin{macrocode} -\def\KVS@empty{} -\long\def\@ReturnAfterFi#1\fi{\fi#1} +\begingroup\expandafter\endgroup +\ifcase0\ifetex@unexpanded + \expandafter\ifx\csname ifcsname\endcsname\relax + \else + \expandafter\ifx\csname unless\endcsname\relax + \else + 1% + \fi + \fi + \fi + \catcode`\$=9 % ignore + \catcode`\&=14 % comment +\else % e-TeX + \catcode`\$=14 % comment + \catcode`\&=9 % ignore +\fi % \end{macrocode} % -% \subsection{Normalizing key value lists} +% \subsection{Generic help macros} +% +% \begin{macro}{\KVS@Empty} +% \begin{macrocode} +\def\KVS@Empty{} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@FirstOfTwo} +% \begin{macrocode} +\long\def\KVS@FirstOfTwo#1#2{#1} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@SecondOfTwo} +% \begin{macrocode} +\long\def\KVS@SecondOfTwo#1#2{#2} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\KVS@IfEmpty} +% \begin{macrocode} +\def\KVS@IfEmpty#1{% +& \edef\KVS@Temp{\etex@unexpanded{#1}}% +$ \begingroup +$ \toks@{#1}% +$ \edef\KVS@Temp{\the\toks@}% +$ \expandafter\endgroup + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo + \else + \expandafter\KVS@SecondOfTwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Normalizing} % % \begin{macro}{\kv@normalize} % \begin{macrocode} \def\kv@normalize#1{% \begingroup - \toks@{,#1}% - \KVS@comma - \KVS@equal - \KVS@spaceA - \KVS@spaceB{ }% - \KVS@spaceC - \KVS@spaceD{ }% - \xdef\kv@global{\the\toks@}% + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma{ }% + \KVS@CommaSpace + \KVS@CommaComma + \KVS@Equals + \KVS@SpaceEquals{ }% + \KVS@EqualsSpace{ }% + \xdef\KVS@Global{\the\toks@}% \endgroup - \let\kv@list\kv@global + \let\kv@list\KVS@Global } % \end{macrocode} % \end{macro} -% \begin{macro}{\KVS@comma} +% \begin{macro}{\comma@normalize} +% \begin{macrocode} +\def\comma@normalize#1{% + \begingroup + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma{ }% + \KVS@CommaSpace + \KVS@CommaComma + \xdef\KVS@Global{\the\toks@}% + \endgroup + \let\comma@list\KVS@Global +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@Comma} % Converts active commas into comma with catcode other. % Also adds a comma at the end to protect the last value % for next cleanup steps. @@ -497,154 +656,153 @@ and the derived files \lccode`\,=`\,% \lccode`\~=`\,% \lowercase{\endgroup - \def\KVS@comma{% + \def\KVS@Comma{% \toks@\expandafter{\expandafter}\expandafter - \KVS@@comma\the\toks@~\KVS@nil + \KVS@@Comma\the\toks@~\KVS@Nil }% - \def\KVS@@comma#1~#2\KVS@nil{% - \toks@\expandafter{\the\toks@#1,}% - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@comma#2\KVS@nil - }% - \fi + \def\KVS@@Comma#1~#2\KVS@Nil{% + \toks@\expandafter{\the\toks@#1}% + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Comma,#2\KVS@Nil + }% + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@SpaceComma} +% Removes spaces before the comma, may add commas at the end. +% \begin{macrocode} +\def\KVS@SpaceComma#1{% + \toks@\expandafter{\the\toks@#1,}% + \expandafter\KVS@@SpaceComma\the\toks@\KVS@Nil +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@@SpaceComma} +% \begin{macrocode} +\def\KVS@@SpaceComma#1 ,#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \toks@{#1,#2}% + \expandafter\KVS@@SpaceComma\the\toks@\KVS@Nil }% } % \end{macrocode} % \end{macro} -% \begin{macro}{\KVS@equal} -% Converts active equal signs into catcode other characters. +% \begin{macro}{\KVS@CommaSpace} +% Removes spaces after the comma, may add commas at the end. +% \begin{macrocode} +\def\KVS@CommaSpace{% + \toks@\expandafter{\the\toks@, }% + \expandafter\KVS@@CommaSpace\the\toks@\KVS@Nil +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@@CommaSpace} +% \begin{macrocode} +\def\KVS@@CommaSpace#1, #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \toks@{#1,#2}% + \expandafter\KVS@@CommaSpace\the\toks@\KVS@Nil + }% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@CommaComma} +% Replaces multiple commas by one comma. +% \begin{macrocode} +\def\KVS@CommaComma{% + \toks@\expandafter{\the\toks@,}% + \expandafter\KVS@@CommaComma\the\toks@\KVS@Nil +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@@CommaComma} +% \begin{macrocode} +\def\KVS@@CommaComma#1,,#2\KVS@Nil{% + \toks@{#1,#2}% + \KVS@IfEmpty{#2}{% + }{% + \expandafter\KVS@@CommaComma\the\toks@\KVS@Nil + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\KVS@Equals} +% Converts active equals signs into catcode other characters. % \begin{macrocode} \begingroup \lccode`\==`\=% \lccode`\~=`\=% \lowercase{\endgroup - \def\KVS@equal{% + \def\KVS@Equals{% \toks@\expandafter{\expandafter}\expandafter - \KVS@@equal\the\toks@~\KVS@nil + \KVS@@Equals\the\toks@~\KVS@Nil }% - \def\KVS@@equal#1~#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% + \def\KVS@@Equals#1~#2\KVS@Nil{% + \edef\KVS@Temp{\the\toks@}% + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@equal#2\KVS@nil - }% + \expandafter\KVS@SecondOfTwo \fi + {% + \toks@{#1}% + }{% + \toks@\expandafter{\the\toks@=#1}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Equals#2\KVS@Nil + }% }% } % \end{macrocode} % \end{macro} -% \begin{macro}{\KVS@spaceA} -% Removes one space after the equal sign. In theory also several -% spaces could be removed, but this is not really necessary, -% because \TeX\ usually collapses several spaces to one already. +% \begin{macro}{\KVS@SpaceEquals} +% Removes spaces before the equals sign. % \begin{macrocode} -\def\KVS@spaceA{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceA\the\toks@= \KVS@nil -} -\def\KVS@@spaceA#1= #2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% - \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceA#2\KVS@nil - }% - \fi +\def\KVS@SpaceEquals#1{% + \toks@\expandafter{\the\toks@#1=}% + \expandafter\KVS@@SpaceEquals\the\toks@\KVS@Nil } % \end{macrocode} % \end{macro} -% \begin{macro}{\KVS@spaceB} -% Removes one space before the comma. +% \begin{macro}{\KVS@@SpaceEquals} % \begin{macrocode} -\def\KVS@spaceB#1{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceB\the\toks@#1,\KVS@nil -} -\def\KVS@@spaceB#1 ,#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty +\def\KVS@@SpaceEquals#1 =#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% \toks@{#1}% - \else - \toks@\expandafter{\the\toks@,#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceB#2\KVS@nil - }% - \fi + }{% + \toks@{#1=#2}% + \expandafter\KVS@@SpaceEquals\the\toks@\KVS@Nil + }% } % \end{macrocode} % \end{macro} -% -% \begin{macro}{\KVS@spaceC} -% Removes one space after the comma. +% \begin{macro}{\KVS@EqualsSpace} +% Removes spaces after the equals sign. % \begin{macrocode} -\def\KVS@spaceC{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceC\the\toks@, \KVS@nil -} -\def\KVS@@spaceC#1, #2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% - \else - \toks@\expandafter{\the\toks@,#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceC#2\KVS@nil - }% - \fi +\def\KVS@EqualsSpace{% + \toks@\expandafter{\the\toks@= }% + \expandafter\KVS@@EqualsSpace\the\toks@\KVS@Nil } % \end{macrocode} % \end{macro} -% \begin{macro}{\KVS@spaceD} -% Removes one space before the equal sign. +% \begin{macro}{\KVS@@EqualsSpace} % \begin{macrocode} -\def\KVS@spaceD#1{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceD\the\toks@#1=\KVS@nil -} -\def\KVS@@spaceD#1 =#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty +\def\KVS@@EqualsSpace#1= #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% \toks@{#1}% - \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceD#2\KVS@nil - }% - \fi + }{% + \toks@{#1=#2}% + \expandafter\KVS@@EqualsSpace\the\toks@\KVS@Nil + }% } % \end{macrocode} % \end{macro} @@ -661,67 +819,113 @@ and the derived files % \end{macrocode} % \end{macro} % \begin{macro}{\kv@parse@normalized} +% |#1|: key value list\\ +% |#2|: processor % \begin{macrocode} \def\kv@parse@normalized#1#2{% - \KVS@parse#1,\KVS@nil{#2}% + \KVS@Parse#1,\KVS@Nil{#2}% } % \end{macrocode} % \end{macro} +% \begin{macro}{\KVS@Parse} +% |#1,#2|: key value list\\ +% |#3|: processor % \begin{macrocode} -\def\KVS@parse#1,#2\KVS@nil#3{% - \begingroup - \toks@{#1}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty - \else - \KVS@process#1=\KVS@nil{#3}% - \fi - \begingroup - \toks@{#2}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@parse#2\KVS@nil{#3}% - }% - \fi +\def\KVS@Parse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \KVS@Process#1=\KVS@Nil{#3}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@Parse#2\KVS@Nil{#3}% + }% } % \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@Process} +% |#1|: key\\ +% |#2|: value, |=|\\ +% |#3|: processor % \begin{macrocode} -\def\KVS@process#1=#2\KVS@nil#3{% +\def\KVS@Process#1=#2\KVS@Nil#3{% \def\kv@key{#1}% - \begingroup - \toks@{#2}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty + \KVS@IfEmpty{#2}{% \let\kv@value\relax #3{#1}{}% - \else - \KVS@@process{#1}#2\KVS@nil{#3}% - \fi + }{% + \KVS@@Process{#1}#2\KVS@Nil{#3}% + }% } -\def\KVS@@process#1#2=\KVS@nil#3{% - \begingroup - \toks@{#2}% - \xdef\KVS@global{\the\toks@}% - \endgroup - \let\kv@value\KVS@global +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@@Process} +% |#1|: key\\ +% |#2|: value\\ +% |#3|: processor +% \begin{macrocode} +\def\KVS@@Process#1#2=\KVS@Nil#3{% +& \edef\kv@value{\etex@unexpanded{#2}}% +$ \begingroup +$ \toks@{#2}% +$ \xdef\KVS@Global{\the\toks@}% +$ \endgroup +$ \let\kv@value\KVS@Global #3{#1}{#2}% } % \end{macrocode} +% \end{macro} +% +% \subsection{Parsing comma lists} +% +% \begin{macro}{\comma@parse} +% Normalizes and parses the key value list. Also sets \cs{comma@list}. +% \begin{macrocode} +\def\comma@parse#1{% + \comma@normalize{#1}% + \expandafter\comma@parse@normalized\expandafter{\comma@list}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\comma@parse@normalized} +% |#1|: comma list\\ +% |#2|: processor +% \begin{macrocode} +\def\comma@parse@normalized#1#2{% + \KVS@CommaParse#1,\KVS@Nil{#2}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@CommaParse} +% |#1,#2|: comma list\\ +% |#3|: processor +% \begin{macrocode} +\def\KVS@CommaParse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \def\comma@entry{#1}% + #3{#1}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@CommaParse#2\KVS@Nil{#3}% + }% +} +% \end{macrocode} +% \end{macro} % % \subsection{Processing key value pairs} % % \begin{macro}{\kv@processor@default} % \begin{macrocode} \def\kv@processor@default#1#2#3{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KV@#1@#2\endcsname\relax - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KVS@#1@handler\endcsname\relax +& \unless\ifcsname KV@#1@#2\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2\endcsname\relax +& \unless\ifcsname KVS@#1@handler\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax \kv@error@unknownkey{#1}{#2}% \else \csname KVS@#1@handler\endcsname{#2}{#3}% @@ -729,8 +933,9 @@ and the derived files \fi \else \ifx\kv@value\relax - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax +& \unless\ifcsname KV@#1@#2@default\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax \kv@error@novalue{#1}{#2}% \else \csname KV@#1@#2@default\endcsname @@ -747,9 +952,13 @@ and the derived files % \begin{macro}{\kv@set@family@handler} % \begin{macrocode} \def\kv@set@family@handler#1{% - \KVS@set@family@handler{#1}\@nil + \KVS@SetFamilyHandler{#1}\@nil } -\def\KVS@set@family@handler#1\@nil#{% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KVS@SetFamilyHandler} +% \begin{macrocode} +\def\KVS@SetFamilyHandler#1\@nil#{% \expandafter\def\csname KVS@#1@handler\endcsname##1##2% } % \end{macrocode} @@ -757,15 +966,6 @@ and the derived files % % \subsection{Error handling} % -% \begin{macrocode} -\begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname RequirePackage\endcsname\relax - \input infwarerr.sty\relax -\else - \RequirePackage{infwarerr}[2007/09/09]% -\fi -% \end{macrocode} -% % \begin{macro}{\kv@error@novalue} % \begin{macrocode} \def\kv@error@novalue{% @@ -863,6 +1063,259 @@ and the derived files %</test1> % \end{macrocode} % +% \subsection{Macro tests} +% +% \subsubsection{Preamble} +% +% \begin{macrocode} +%<*test2> +\NeedsTeXFormat{LaTeX2e} +\nofiles +\documentclass{article} +%<noetex>\let\SavedUnexpanded\unexpanded +%<noetex>\let\unexpanded\UNDEFINED +\makeatletter +\chardef\KVS@TestMode=1 % +\makeatother +\usepackage{kvsetkeys}[2007/09/29] +%<noetex>\let\unexpanded\SavedUnexpanded +\usepackage{qstest} +\IncludeTests{*} +\LogTests{log}{*}{*} +% \end{macrocode} +% +% \subsubsection{Time} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfresettimer\endcsname\relax +\else + \makeatletter + \newcount\SummaryTime + \newcount\TestTime + \SummaryTime=\z@ + \newcommand*{\PrintTime}[2]{% + \typeout{% + [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]% + }% + }% + \newcommand*{\StartTime}[1]{% + \renewcommand*{\TimeDescription}{#1}% + \pdfresettimer + }% + \newcommand*{\TimeDescription}{}% + \newcommand*{\StopTime}{% + \TestTime=\pdfelapsedtime + \global\advance\SummaryTime\TestTime + \PrintTime\TimeDescription\TestTime + }% + \let\saved@qstest\qstest + \let\saved@endqstest\endqstest + \def\qstest#1#2{% + \saved@qstest{#1}{#2}% + \StartTime{#1}% + }% + \def\endqstest{% + \StopTime + \saved@endqstest + }% + \AtEndDocument{% + \PrintTime{summary}\SummaryTime + }% + \makeatother +\fi +% \end{macrocode} +% +% \subsubsection{Test sets} +% +% \begin{macrocode} +\makeatletter +\def\@makeactive#1{% + \catcode`#1=13\relax +} +\@makeactive\, +\def,{\errmessage{COMMA}} +\@makeother\, +\@makeactive\= +\def={\errmessage{EQUALS}} +\@makeother\= + +\begin{qstest}{normalize}{normalize,active-chars,space-removal}% + \def\Test#1#2{% + \@makeother\,% + \@makeother\=% + \scantokens{\toks@={#2}}% + \edef\Result{\the\toks@}% + \@makeother\,% + \@makeother\=% + \@Test{#1}% + \@makeactive\,% + \@Test{#1}% + \@makeactive\=% + \@Test{#1}% + \@makeother\,% + \@Test{#1}% + \@makeother\=% + }% + \def\@Test#1{% + \scantokens{\kv@normalize{#1}}% + \expandafter\expandafter\expandafter\Expect + \expandafter\expandafter\expandafter + {\expandafter\kv@list\expandafter}\expandafter{\Result}% + \Expect*{\ifx\kv@list\Result true\else false\fi}{true}% + }% + \Test{}{,}% + \Test{,}{,}% + \Test{,,}{,}% + \Test{,,,}{,}% + \Test{ , }{,}% + \Test{{a}}{,{a},}% + \Test{,{a}}{,{a},}% + \Test{{a},}{,{a},}% + \Test{{a},{b}}{,{a},{b},}% + \Test{{b}={c},{}=,{}={},{d}=}{,{b}={c},{}=,{}={},{d}=,}% + \Test{{}}{,{},}% + \Test{{},{},{}}{,{},{},{},}% + \Test{=}{,=,}% + \Test{=,=,=}{,=,=,=,}% + \def\TestSet#1{% + \Test{#1#1}{,}% + \Test{#1#1,#1#1}{,}% + \Test{#1#1,#1#1,#1#1}{,}% + \Test{#1#1#1#1#1}{,}% + \Test{{a}#1#1=#1#1{b}}{,{a}={b},}% + }% + \TestSet{ }% + \begingroup + \let\saved@normalize\kv@normalize + \def\kv@normalize#1{% + \saved@normalize{#1}% + \@onelevel@sanitize\kv@list + \@onelevel@sanitize\Result + }% + \Test{#,#=#,{#}={#},{#}=,{#}}{,#,#=#,{#}={#},{#}=,{#},}% + \endgroup + \begingroup + \def\Test#1#2{% + \edef\Result{#2}% + \@Test{#1}% + }% + \Test{{ a = b }}{,{ a = b },}% + \@makeactive\,% + \Test{{,}}{\string,{\noexpand,}\string,}% + \@makeother\,% + \@makeactive\=% + \Test{a={=}}{,a\string={\noexpand=},}% + \endgroup + \Test{a=b}{,a=b,}% + \Test{a={b}}{,a={b},}% + \Test{a ={b}}{,a={b},}% + \Test{a= {b}}{,a={b},}% + \Test{a = {b}}{,a={b},}% + \Test{a = {b} ,}{,a={b},}% + \Test{a}{,a,}% + \Test{ a}{,a,}% + \Test{a }{,a,}% + \Test{ a }{,a,}% + \Test{, a ,}{,a,}% + \Test{, a b ,}{,a b,}% + \Test{,a ,}{,a,}% + \Test{ a =}{,a=,}% + \Test{ a = }{,a=,}% + \Test{a =}{,a=,}% + \Test{{a} =}{,{a}=,}% + \Test{{a}= {}}{,{a}={},}% + \Test{, a = {}}{,a={},}% + \Test{a,,b}{,a,b,}% + \Test{a=\fi}{,a=\fi,}% + \Test{a=\iffalse}{,a=\iffalse,}% + \Test{a=\iffalse,b=\fi}{,a=\iffalse,b=\fi,}% +\end{qstest} + +\begin{qstest}{parse}{parse,brace-removal} + \def\Processor#1#2{% + \expandafter\Expect\expandafter{\kv@key}{#1}% + \toks@{#2}% + \edef\x{\the\toks@}% + \ifx\kv@value\relax + \Expect*{\the\toks@}{}% + \def\Value{<>}% + \else + \edef\Value{[\the\toks@]}% + \@onelevel@sanitize\Value + \fi + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]=\Value}% + \else + \edef\Result{\Result,[\the\toks@]=\Value}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \kv@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[]=<>}% + \Test{{{{}}}}{[{}]=<>}% + \Test{a}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{a}}{[a]=<>}% + \Test{{{a}}}{[a]=<>}% + \Test{{{{a}}}}{[{a}]=<>}% + \Test{a=}{[a]=[]}% + \Test{{a}=}{[a]=[]}% + \Test{{{a}}=}{[{a}]=[]}% + \Test{a={}}{[a]=[]}% + \Test{{a}={{}}}{[a]=[{}]}% + \Test{a=b}{[a]=[b]}% + \Test{a=\fi}{[a]=[\fi]}% + \Test{a=\iffalse}{[a]=[\iffalse]}% + \Test{a=\iffalse,b=\fi}{[a]=[\iffalse],[b]=[\fi]}% + \Test{{ a = b }}{[ a ]=[ b ]}% + \Test{{{ a = b }}}{[ a = b ]=<>}% +\end{qstest} + +\begin{qstest}{comma}{comma,parse} + \def\Processor#1{% + \expandafter\Expect\expandafter{\comma@entry}{#1}% + \toks@{#1}% + \ifx\Result\@empty + \edef\Result{[\the\toks@]}% + \else + \edef\Result{\Result,[\the\toks@]}% + \fi + \@onelevel@sanitize\Result + }% + \def\Test#1#2{% + \let\Result\@empty + \comma@parse{#1}\Processor + \Expect*{\Result}{#2}% + }% +\tracingmacros=1 + \Test{}{}% + \Test{{}}{}% + \Test{{{}}}{[{}]}% + \Test{a}{[a]}% + \Test{{a}}{[a]}% + \Test{{{a}}}{[{a}]}% + \Test{a=}{[a=]}% + \Test{a\fi}{[a\fi]}% + \Test{a\iffalse}{[a\iffalse]}% + \Test{\iffalse,\fi}{[\iffalse],[\fi]}% + \Test{ a , b , c }{[a],[b],[c]}% + \Test{ { } ,{ }, { }, { } , { } }{[ ],[ ],[ ],[ ],[ ]}% + \Test{ {{}} ,{{}}, {{}}, {{}} , {{}} }{[{}],[{}],[{}],[{}],[{}]}% +\end{qstest} + +\begin{document} +\end{document} +%</test2> +% \end{macrocode} +% % \section{Installation} % % \subsection{Download} @@ -926,6 +1379,8 @@ and the derived files % kvsetkeys.pdf & doc/latex/oberdiek/kvsetkeys.pdf\\ % kvsetkeys-example.tex & doc/latex/oberdiek/kvsetkeys-example.tex\\ % kvsetkeys-test1.tex & doc/latex/oberdiek/kvsetkeys-test1.tex\\ +% kvsetkeys-test2.tex & doc/latex/oberdiek/kvsetkeys-test2.tex\\ +% kvsetkeys-test3.tex & doc/latex/oberdiek/kvsetkeys-test3.tex\\ % kvsetkeys.dtx & source/latex/oberdiek/kvsetkeys.dtx\\ % \end{tabular}^^A % }^^A @@ -1073,6 +1528,19 @@ and the derived files % \item % Catcode section rewritten. % \end{Version} +% \begin{Version}{2007/09/29 v1.4} +% \item +% Normalizing and parsing of comma separated lists added. +% \item +% \cs{kv@normalize} rewritten. +% \item +% Robustness increased for normalizing and parsing, +% e.g. for values with unmatched conditionals. +% \item +% \eTeX\ is used if available. +% \item +% Tests added for normalizing and parsing. +% \end{Version} % \end{History} % % \PrintIndex diff --git a/Master/texmf-dist/source/latex/oberdiek/oberdiek.ins b/Master/texmf-dist/source/latex/oberdiek/oberdiek.ins index 6e1f3d9784a..457d7bd9523 100644 --- a/Master/texmf-dist/source/latex/oberdiek/oberdiek.ins +++ b/Master/texmf-dist/source/latex/oberdiek/oberdiek.ins @@ -1,5 +1,5 @@ % oberdiek.ins -% 2007/09/14 +% 2007/10/04 % % Copyright (C) 1999, 2001, 2006 by % Heiko Oberdiek <oberdiek@uni-freiburg.de> @@ -29,6 +29,8 @@ \batchinput{atenddvi.dtx} \batchinput{attachfile2.dtx} \batchinput{auxhook.dtx} +\batchinput{bigintcalc.dtx} +\batchinput{bitset.dtx} \batchinput{bmpsize.dtx} \batchinput{bookmark.dtx} \batchinput{catchfile.dtx} @@ -42,6 +44,7 @@ \batchinput{epstopdf.dtx} \batchinput{etexcmds.dtx} \batchinput{flags.dtx} +\batchinput{grfext.dtx} \batchinput{grffile.dtx} \batchinput{holtxdoc.dtx} \batchinput{hycolor.dtx} diff --git a/Master/texmf-dist/source/latex/oberdiek/oberdiek.tex b/Master/texmf-dist/source/latex/oberdiek/oberdiek.tex index fcad0f2255d..aa6297aebfa 100644 --- a/Master/texmf-dist/source/latex/oberdiek/oberdiek.tex +++ b/Master/texmf-dist/source/latex/oberdiek/oberdiek.tex @@ -6,7 +6,7 @@ \newcommand*{\Subject}{CTAN:\CTANdir} \newcommand*{\Author}{Heiko Oberdiek} \newcommand*{\Email}{oberdiek@uni-freiburg.de} -\newcommand*{\Date}{2007/09/14} +\newcommand*{\Date}{2007/10/04} % Copyright (C) 2006 by % Heiko Oberdiek <oberdiek@uni-freiburg.de> @@ -170,9 +170,13 @@ [\entrysep] \entry{auxhook}{2006/04/06}{1.1}{Hooks for auxiliary files}% [\entrysep] +\entry{bigintcalc}{2007/09/27}{1.0}{Expandable big integer calculations}% +[\entrysep] +\entry{bitset}{2007/09/28}{1.0}{Data type bit set}% +[\entrysep] \entry{bmpsize}{2007/04/29}{1.3}{Extract size and resolution data from bitmap files}% [\entrysep] -\entry{bookmark}{2007/07/13}{1.1}{PDF bookmarks}% +\entry{bookmark}{2007/09/25}{1.2}{PDF bookmarks}% [\entrysep] \entry{catchfile}{2007/09/09}{1.1}{Catches the contents of a file}% [\entrysep] @@ -188,13 +192,15 @@ [\entrysep] \entry{embedfile}{2007/09/09}{1.2}{embed files into PDF}% [\entrysep] -\entry{engord}{2007/09/09}{1.5}{Provides the ifpdf switch}% +\entry{engord}{2007/09/20}{1.6}{Provides English ordinal numbers}% [\entrysep] -\entry{epstopdf}{2007/04/26}{1.4}{Conversion with epstopdf on the fly}% +\entry{epstopdf}{2007/10/02}{1.5}{Conversion with epstopdf on the fly}% [\entrysep] \entry{etexcmds}{2007/09/09}{1.1}{Providing prefix for e-TeX command names}% [\entrysep] -\entry{flags}{2007/03/07}{0.3}{Flag setting in bit fields}% +\entry{flags}{2007/09/30}{0.4}{Flag setting in bit fields}% +[\entrysep] +\entry{grfext}{2007/09/30}{1.0}{Managing graphics extensions}% [\entrysep] \entry{grffile}{2007/08/16}{1.5}{Extended file name support for graphics}% [\entrysep] @@ -222,11 +228,11 @@ [\entrysep] \entry{inputenx}{2007/08/16}{1.3}{Enhanced input encoding handling}% [\entrysep] -\entry{intcalc}{2007/09/09}{1.0}{Expandable integer calculations}% +\entry{intcalc}{2007/09/27}{1.1}{Expandable integer calculations}% [\entrysep] -\entry{kvoptions}{2007/06/11}{2.7}{Connects package keyval with \LaTeX{} options}% +\entry{kvoptions}{2007/10/02}{2.8}{Connects package keyval with \LaTeX{} options}% [\entrysep] -\entry{kvsetkeys}{2007/09/09}{1.2}{Key value parser with default handler support}% +\entry{kvsetkeys}{2007/09/29}{1.3}{Key value parser with default handler support}% [\entrysep] \entry{makerobust}{2006/03/18}{1.0}{Making a macro robust}% [\entrysep] @@ -357,6 +363,25 @@ the begin of \xfile{.aux} files. \tocinclude{auxhook} \newpage +\subsection{\pkgsectformat{bigintcalc}} +\label{bigintcalc} +\begin{abstract} +This package provides expandable arithmetic operations +with big integers that can exceed \TeX's number limits. +\end{abstract} +\tocinclude{bigintcalc} + +\newpage +\subsection{\pkgsectformat{bitset}} +\label{bitset} +\begin{abstract} +This package defines and implements the data type bit set, +a vector of bits. The size of the vector may grow dynamically. +Individual bits can be manipulated. +\end{abstract} +\tocinclude{bitset} + +\newpage \subsection{\pkgsectformat{bmpsize}} \label{bmpsize} \begin{abstract} @@ -494,6 +519,15 @@ decimal number. Currently the bit field is limited to 31 bits. \tocinclude{flags} \newpage +\subsection{\pkgsectformat{grfext}} +\label{grfext} +\begin{abstract} +This package provides macros for adding and reordering +graphics extensions of package \xpackage{graphics}. +\end{abstract} +\tocinclude{grfext} + +\newpage \subsection{\pkgsectformat{grffile}} \label{grffile} \begin{abstract} diff --git a/Master/texmf-dist/source/latex/oberdiek/twoopt.dtx b/Master/texmf-dist/source/latex/oberdiek/twoopt.dtx index 09ce98d6730..df7c0658b6b 100644 --- a/Master/texmf-dist/source/latex/oberdiek/twoopt.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/twoopt.dtx @@ -223,15 +223,15 @@ and the derived files \ProvidesPackage{twoopt} [2006/02/20 v1.4 Definitions with two optional arguments (HO)]% % \end{macrocode} -% \begin{macro}{\newcommandtwoopt} +% \begin{macro}{\newcommandtwoopt} % \begin{macrocode} \newcommand{\newcommandtwoopt}{% \@ifstar{\@newcommandtwoopt*}{\@newcommandtwoopt{}}% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\@newcommandtwoopt} +% \begin{macro}{\@newcommandtwoopt} % \begin{param} % \entry1 star\\ % \entry2 macro name to be defined @@ -243,9 +243,9 @@ and the derived files \csname2\string#2\endcsname{#1}{#2}% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\@@newcommandtwoopt} +% \begin{macro}{\@@newcommandtwoopt} % \begin{param} % \entry1 help command to be defined % (\expandafter\cmd\csname 2\bslash<name>\endcsname)\\ @@ -264,17 +264,17 @@ and the derived files \newcommand#2#1[{#4}]% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\renewcommandtwoopt} +% \begin{macro}{\renewcommandtwoopt} % \begin{macrocode} \newcommand{\renewcommandtwoopt}{% \@ifstar{\@renewcommandtwoopt*}{\@renewcommandtwoopt{}}% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\@renewcommandtwoopt} +% \begin{macro}{\@renewcommandtwoopt} % \begin{param} % \entry1 star\\ % \entry2 command name to be defined @@ -295,17 +295,17 @@ and the derived files \csname2\string#2\endcsname{#1}{#2}% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\providecommandtwoopt} +% \begin{macro}{\providecommandtwoopt} % \begin{macrocode} \newcommand{\providecommandtwoopt}{% \@ifstar{\@providecommandtwoopt*}{\@providecommandtwoopt{}}% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\@providecommandtwoopt} +% \begin{macro}{\@providecommandtwoopt} % \begin{param} % \entry1 star\\ % \entry2 command name to be defined @@ -327,9 +327,9 @@ and the derived files }% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\to@ScanSecondOptArg} +% \begin{macro}{\to@ScanSecondOptArg} % \begin{param} % \entry1 help command to be defined % (\expandafter\cmd\csname 2\bslash<name>\endcsname)\\ @@ -345,14 +345,14 @@ and the derived files }% } % \end{macrocode} -% \end{macro} +% \end{macro} % -% \begin{macro}{\to@ArgOptToArgArg} +% \begin{macro}{\to@ArgOptToArgArg} % \begin{macrocode} \newcommand{\to@ArgOptToArgArg}{} \long\def\to@ArgOptToArgArg#1[#2]{{#1}{#2}} % \end{macrocode} -% \end{macro} +% \end{macro} % % \begin{macrocode} %</package> diff --git a/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty b/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty new file mode 100644 index 00000000000..664b8e46a12 --- /dev/null +++ b/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty @@ -0,0 +1,1766 @@ +%% +%% This is file `bigintcalc.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bigintcalc.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bigintcalc.dtx +%% and the derived files +%% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv, +%% bigintcalc-test1.tex, bigintcalc-test2.tex, +%% bigintcalc-test3.tex. +%% +\begingroup + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\let\expandafter\x\csname ver@bigintcalc.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{bigintcalc}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@bigintcalc.sty\endcsname +\ProvidesPackage{bigintcalc}% + [2007/09/27 v1.0 Expandable big integer calculations (HO)] +\expandafter\edef\csname BIC@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\BIC@AtEnd{% + \BIC@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{36}{14}% $ (comment!) +\TMP@EnsureCode{38}{14}% & (comment!) +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{11}% : (letter!) +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{63}{14}% ? (comment!) +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname BIC@TestMode\endcsname\relax +\else + \catcode63=9 % ? (ignore) +\fi +? \let\BIC@@TestMode\BIC@TestMode +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname numexpr\endcsname\relax + \catcode36=9 % $ (ignore) +\else + \catcode38=9 % & (ignore) +\fi +\let\BIC@Fi\fi +\def\BIC@AfterFi#1#2\BIC@Fi{\fi#1}% +\def\BIC@AfterFiFi#1#2\BIC@Fi{\fi\fi#1}% +\def\BIC@AfterFiFiFi#1#2\BIC@Fi{\fi\fi\fi#1}% +\begingroup + \def\x#1{\endgroup + \let\BIC@Space= #1% + }% +\x{ } +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdfescapehex\endcsname\relax + \def\BIC@Expand#1{% + \romannumeral0% + \BIC@@Expand#1!\@nil{}% + }% + \def\BIC@@Expand#1#2\@nil#3{% + \expandafter\ifcat\noexpand#1\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {% + \expandafter\BIC@@Expand#1#2\@nil{#3}% + }{% + \ifx#1!% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + { #3}{% + \BIC@@Expand#2\@nil{#3#1}% + }% + }% + }% + \expandafter\ifx\csname @firstoftwo\endcsname\relax + \long\def\@firstoftwo#1#2{#1}% + \fi + \expandafter\ifx\csname @secondoftwo\endcsname\relax + \long\def\@secondoftwo#1#2{#2}% + \fi +\else + \def\BIC@Expand#1{% + \pdfunescapehex{% + \expandafter\BIC@StripHexSpace\pdfescapehex{#1}20\@nil + }% + }% + \def\BIC@StripHexSpace#120#2\@nil{% + #1% + \ifx\\#2\\% + \else + \BIC@AfterFi{% + \BIC@StripHexSpace#2\@nil + }% + \BIC@Fi + }% +\fi +\def\BIC@Normalize#1#2{% + \ifx#2-% + \ifx\\#1\\% + \BIC@AfterFiFi{% + \BIC@Normalize-% + }% + \else + \BIC@AfterFiFi{% + \BIC@Normalize{}% + }% + \fi + \else + \ifx#2+% + \BIC@AfterFiFi{% + \BIC@Normalize{#1}% + }% + \else + \ifx#20% + \BIC@AfterFiFiFi{% + \BIC@NormalizeZero{#1}% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@NormalizeDigits#1#2% + }% + \fi + \fi + \BIC@Fi +} +\def\BIC@NormalizeZero#1#2{% + \ifx#2!% + \BIC@AfterFi{ 0}% + \else + \ifx#20% + \BIC@AfterFiFi{% + \BIC@NormalizeZero{#1}% + }% + \else + \BIC@AfterFiFi{% + \BIC@NormalizeDigits#1#2% + }% + \fi + \BIC@Fi +} +\def\BIC@NormalizeDigits#1!{ #1} +\def\bigintcalcNum#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Normalize + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \BIC@Expand{#1}!% +} +\def\bigintcalcInv#1{% + \romannumeral0\expandafter\expandafter\expandafter\BIC@Space + \bigintcalcNum{-#1}% +} +\def\bigintcalcAbs#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Abs + \bigintcalcNum{#1}% +} +\def\BIC@Abs#1{% + \ifx#1-% + \expandafter\BIC@Space + \else + \expandafter\BIC@Space + \expandafter#1% + \fi +} +\def\bigintcalcSgn#1{% + \number + \expandafter\expandafter\expandafter\BIC@Sgn + \bigintcalcNum{#1}! % +} +\def\BIC@Sgn#1#2!{% + \ifx#1-% + -1% + \else + \ifx#10% + 0% + \else + 1% + \fi + \fi +} +\def\bigintcalcCmp#1#2{% + \number + \expandafter\expandafter\expandafter\BIC@Cmp + \bigintcalcNum{#2}!{#1}% +} +\def\BIC@Cmp#1!#2{% + \expandafter\expandafter\expandafter\BIC@@Cmp + \bigintcalcNum{#2}!#1!% +} +\def\BIC@@Cmp#1#2!#3#4!{% + \ifx#1-% + \ifx#3-% + \BIC@AfterFiFi{% + \BIC@@Cmp#4!#2!% + }% + \else + \BIC@AfterFiFi{% + -1 % + }% + \fi + \else + \ifx#3-% + \BIC@AfterFiFi{% + 1 % + }% + \else + \BIC@AfterFiFi{% + \BIC@CmpLength#1#2!#3#4!#1#2!#3#4!% + }% + \fi + \BIC@Fi +} +\def\BIC@PosCmp#1!#2!{% + \BIC@CmpLength#1!#2!#1!#2!% +} +\def\BIC@CmpLength#1#2!#3#4!{% + \ifx\\#2\\% + \ifx\\#4\\% + \BIC@AfterFiFi\BIC@CmpDiff + \else + \BIC@AfterFiFi{% + \BIC@CmpResult{-1}% + }% + \fi + \else + \ifx\\#4\\% + \BIC@AfterFiFi{% + \BIC@CmpResult1% + }% + \else + \BIC@AfterFiFi{% + \BIC@CmpLength#2!#4!% + }% + \fi + \BIC@Fi +} +\def\BIC@CmpResult#1#2!#3!{#1 } +\def\BIC@CmpDiff#1#2!#3#4!{% + \ifnum#1<#3 % + \BIC@AfterFi{% + -1 % + }% + \else + \ifnum#1>#3 % + \BIC@AfterFiFi{% + 1 % + }% + \else + \ifx\\#2\\% + \BIC@AfterFiFiFi{% + 0 % + }% + \else + \BIC@AfterFiFiFi{% + \BIC@CmpDiff#2!#4!% + }% + \fi + \fi + \BIC@Fi +} +\def\bigintcalcMin#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@MinMax + \bigintcalcNum{#1}!-!% +} +\def\bigintcalcMax#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@MinMax + \bigintcalcNum{#1}!!% +} +\def\BIC@MinMax#1!#2!#3{% + \expandafter\expandafter\expandafter\BIC@@MinMax + \bigintcalcNum{#3}!#1!#2!% +} +\def\BIC@@MinMax#1!#2!#3!{% + \ifnum\BIC@@Cmp#1!#2!=#31 % + \BIC@AfterFi{ #1}% + \else + \BIC@AfterFi{ #2}% + \BIC@Fi +} +\def\bigintcalcOdd#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Odd + \bigintcalcAbs{#1}!% +} +\def\BigIntCalcOdd#1!{% + \romannumeral0% + \BIC@Odd#1!% +} +\def\BIC@Odd#1#2{% + \ifx#2!% + \ifodd#1 % + \BIC@AfterFiFi{ 1}% + \else + \BIC@AfterFiFi{ 0}% + \fi + \else + \expandafter\BIC@Odd\expandafter#2% + \BIC@Fi +} +\def\bigintcalcInc#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@IncSwitch + \bigintcalcNum{#1}!% +} +\def\BIC@IncSwitch#1#2!{% + \ifcase\BIC@@Cmp#1#2!-1!% + \BIC@AfterFi{ 0}% + \or + \BIC@AfterFi{% + \BIC@Inc#1#2!{}% + }% + \else + \BIC@AfterFi{% + \expandafter-\romannumeral0% + \BIC@Dec#2!{}% + }% + \BIC@Fi +} +\def\bigintcalcDec#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@DecSwitch + \bigintcalcNum{#1}!% +} +\def\BIC@DecSwitch#1#2!{% + \ifcase\BIC@Sgn#1#2! % + \BIC@AfterFi{ -1}% + \or + \BIC@AfterFi{% + \BIC@Dec#1#2!{}% + }% + \else + \BIC@AfterFi{% + \expandafter-\romannumeral0% + \BIC@Inc#2!{}% + }% + \BIC@Fi +} +\def\BigIntCalcInc#1!{% + \romannumeral0\BIC@Inc#1!{}% +} +\def\BigIntCalcDec#1!{% + \romannumeral0\BIC@Dec#1!{}% +} +\def\BIC@Inc#1#2!#3{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@@Inc1#1#3!{}% + }% + \else + \BIC@AfterFi{% + \BIC@Inc#2!{#1#3}% + }% + \BIC@Fi +} +\def\BIC@@Inc#1#2#3!#4{% + \ifcase#1 % + \ifx\\#3\\% + \BIC@AfterFiFi{ #2#4}% + \else + \BIC@AfterFiFi{% + \BIC@@Inc0#3!{#2#4}% + }% + \fi + \else + \ifnum#2<9 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@Inc\the\numexpr#2+1\relax +$ \expandafter\expandafter\expandafter\BIC@@@Inc +$ \ifcase#2 \expandafter1% +$ \or\expandafter2% +$ \or\expandafter3% +$ \or\expandafter4% +$ \or\expandafter5% +$ \or\expandafter6% +$ \or\expandafter7% +$ \or\expandafter8% +$ \or\expandafter9% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi + 0#3!{#4}% + }% + \else + \BIC@AfterFiFi{% + \BIC@@@Inc01#3!{#4}% + }% + \fi + \BIC@Fi +} +\def\BIC@@@Inc#1#2#3!#4{% + \ifx\\#3\\% + \ifnum#2=1 % + \BIC@AfterFiFi{ 1#1#4}% + \else + \BIC@AfterFiFi{ #1#4}% + \fi + \else + \BIC@AfterFi{% + \BIC@@Inc#2#3!{#1#4}% + }% + \BIC@Fi +} +\def\BIC@Dec#1#2!#3{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@@Dec1#1#3!{}% + }% + \else + \BIC@AfterFi{% + \BIC@Dec#2!{#1#3}% + }% + \BIC@Fi +} +\def\BIC@@Dec#1#2#3!#4{% + \ifcase#1 % + \ifx\\#3\\% + \BIC@AfterFiFi{ #2#4}% + \else + \BIC@AfterFiFi{% + \BIC@@Dec0#3!{#2#4}% + }% + \fi + \else + \ifnum#2>0 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@Dec\the\numexpr#2-1\relax +$ \expandafter\expandafter\expandafter\BIC@@@Dec +$ \ifcase#2 +$? \BigIntCalcError:ThisCannotHappen% +$ \or\expandafter0% +$ \or\expandafter1% +$ \or\expandafter2% +$ \or\expandafter3% +$ \or\expandafter4% +$ \or\expandafter5% +$ \or\expandafter6% +$ \or\expandafter7% +$ \or\expandafter8% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi + 0#3!{#4}% + }% + \else + \BIC@AfterFiFi{% + \BIC@@@Dec91#3!{#4}% + }% + \fi + \BIC@Fi +} +\def\BIC@@@Dec#1#2#3!#4{% + \ifx\\#3\\% + \ifcase#1 % + \ifx\\#4\\% + \BIC@AfterFiFiFi{ 0}% + \else + \BIC@AfterFiFiFi{ #4}% + \fi + \else + \BIC@AfterFiFi{ #1#4}% + \fi + \else + \BIC@AfterFi{% + \BIC@@Dec#2#3!{#1#4}% + }% + \BIC@Fi +} +\def\bigintcalcAdd#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Add + \bigintcalcNum{#1}!% +} +\def\BIC@Add#1!#2{% + \expandafter\expandafter\expandafter + \BIC@AddSwitch\bigintcalcNum{#2}!#1!% +} +\def\bigintcalcSub#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Add + \bigintcalcNum{-#2}!{#1}% +} +\def\BIC@AddSwitch#1#2!#3#4!{% + \ifx#1-% x < 0 + \ifx#3-% y < 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!#4!!!% + }% + \else % -x <= -y + \BIC@AfterFiFiFi{% + \BIC@AddXY#4!#2!!!% + }% + \fi + \else % y >= 0 + \ifcase\BIC@PosCmp#2!#3#4!% -x = y + \BIC@AfterFiFiFi{ 0}% + \or % -x > y + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!#3#4!!!% + }% + \else % -x <= y + \BIC@AfterFiFiFi{% + \BIC@SubXY#3#4!#2!!!% + }% + \fi + \fi + \else % x >= 0 + \ifx#3-% y < 0 + \ifcase\BIC@PosCmp#1#2!#4!% x = -y + \BIC@AfterFiFiFi{ 0}% + \or % x > -y + \BIC@AfterFiFiFi{% + \BIC@SubXY#1#2!#4!!!% + }% + \else % x <= -y + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@SubXY#4!#1#2!!!% + }% + \fi + \else % y >= 0 + \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y + \BIC@AfterFiFiFi{% + \BIC@AddXY#1#2!#3#4!!!% + }% + \else % x <= y + \BIC@AfterFiFiFi{% + \BIC@AddXY#3#4!#1#2!!!% + }% + \fi + \fi + \BIC@Fi +} +\def\BigIntCalcAdd#1!#2!{% + \romannumeral0\BIC@AddXY#1!#2!!!% +} +\def\BigIntCalcSub#1!#2!{% + \romannumeral0\BIC@SubXY#1!#2!!!% +} +\def\BIC@AddXY#1#2!#3#4!#5!#6!{% + \ifx\\#2\\% + \ifx\\#3\\% + \BIC@AfterFiFi{% + \BIC@DoAdd0!#1#5!#60!% + }% + \else + \BIC@AfterFiFi{% + \BIC@DoAdd0!#1#5!#3#6!% + }% + \fi + \else + \ifx\\#4\\% + \ifx\\#3\\% + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!{}!#1#5!#60!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@AddXY#2!{}!#1#5!#3#6!% + }% + \fi + \else + \BIC@AfterFiFi{% + \BIC@AddXY#2!#4!#1#5!#3#6!% + }% + \fi + \BIC@Fi +} +\def\BIC@DoAdd#1#2!#3#4!#5#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% +& \expandafter\BIC@Space +& \the\numexpr#1+#3+#5\relax#2% +$ \expandafter\expandafter\expandafter\BIC@AddResult +$ \BIC@AddDigit#1#3#5#2% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@DoAdd + \BIC@AddDigit#1#3#5#2!#4!#6!% + }% + \BIC@Fi +} +$ \def\BIC@AddResult#1{% +$ \ifx#10% +$ \expandafter\BIC@Space +$ \else +$ \expandafter\BIC@Space\expandafter#1% +$ \fi +$ }% +\def\BIC@AddDigit#1#2#3{% + \romannumeral0% +& \expandafter\BIC@@AddDigit\the\numexpr#1+#2+#3!% +$ \expandafter\BIC@@AddDigit\number% +$ \csname +$ BIC@AddCarry% +$ \ifcase#1 % +$ #2% +$ \else +$ \ifcase#2 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi +$ \fi +$ \endcsname#3!% +} +\def\BIC@@AddDigit#1!{% + \ifnum#1<10 % + \BIC@AfterFi{ 0#1}% + \else + \BIC@AfterFi{ #1}% + \BIC@Fi +} +$ \expandafter\def\csname BIC@AddCarry0\endcsname#1{#1}% +$ \expandafter\def\csname BIC@AddCarry10\endcsname#1{1#1}% +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@AddCarry#1\endcsname##1{% +$ \ifcase##1 #1\or +$ #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 0{1\or2\or3\or4\or5\or6\or7\or8\or9}% +$ \BIC@Temp 1{2\or3\or4\or5\or6\or7\or8\or9\or10}% +$ \BIC@Temp 2{3\or4\or5\or6\or7\or8\or9\or10\or11}% +$ \BIC@Temp 3{4\or5\or6\or7\or8\or9\or10\or11\or12}% +$ \BIC@Temp 4{5\or6\or7\or8\or9\or10\or11\or12\or13}% +$ \BIC@Temp 5{6\or7\or8\or9\or10\or11\or12\or13\or14}% +$ \BIC@Temp 6{7\or8\or9\or10\or11\or12\or13\or14\or15}% +$ \BIC@Temp 7{8\or9\or10\or11\or12\or13\or14\or15\or16}% +$ \BIC@Temp 8{9\or10\or11\or12\or13\or14\or15\or16\or17}% +$ \BIC@Temp 9{10\or11\or12\or13\or14\or15\or16\or17\or18}% +\def\BIC@SubXY#1#2!#3#4!#5!#6!{% + \ifx\\#2\\% + \ifx\\#3\\% + \BIC@AfterFiFi{% + \BIC@DoSub0!#1#5!#60!% + }% + \else + \BIC@AfterFiFi{% + \BIC@DoSub0!#1#5!#3#6!% + }% + \fi + \else + \ifx\\#4\\% + \ifx\\#3\\% + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!{}!#1#5!#60!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@SubXY#2!{}!#1#5!#3#6!% + }% + \fi + \else + \BIC@AfterFiFi{% + \BIC@SubXY#2!#4!#1#5!#3#6!% + }% + \fi + \BIC@Fi +} +\def\BIC@DoSub#1#2!#3#4!#5#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@SubResult + \BIC@SubDigit#1#3#5#2% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@DoSub + \BIC@SubDigit#1#3#5#2!#4!#6!% + }% + \BIC@Fi +} +\def\BIC@SubResult#1{% + \ifx#10% + \expandafter\BIC@SubResult + \else + \expandafter\BIC@Space\expandafter#1% + \fi +} +\def\BIC@SubDigit#1#2#3{% + \romannumeral0% +& \expandafter\BIC@@SubDigit\the\numexpr#2-#3-#1!% +$ \expandafter\BIC@@AddDigit\number +$ \csname +$ BIC@SubCarry% +$ \ifcase#1 % +$ #3% +$ \else +$ \ifcase#3 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi +$ \fi +$ \endcsname#2!% +} +& \def\BIC@@SubDigit#1!{% +& \ifnum#1<0 % +& \BIC@AfterFi{% +& \expandafter\BIC@Space +& \expandafter1\the\numexpr#1+10\relax +& }% +& \else +& \BIC@AfterFi{ 0#1}% +& \BIC@Fi +& }% +$ \expandafter\def\csname BIC@SubCarry0\endcsname#1{#1}% +$ \expandafter\def\csname BIC@SubCarry10\endcsname#1{1#1}% +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@SubCarry#1\endcsname##1{% +$ \ifcase##1 #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 1{19\or0\or1\or2\or3\or4\or5\or6\or7\or8}% +$ \BIC@Temp 2{18\or19\or0\or1\or2\or3\or4\or5\or6\or7}% +$ \BIC@Temp 3{17\or18\or19\or0\or1\or2\or3\or4\or5\or6}% +$ \BIC@Temp 4{16\or17\or18\or19\or0\or1\or2\or3\or4\or5}% +$ \BIC@Temp 5{15\or16\or17\or18\or19\or0\or1\or2\or3\or4}% +$ \BIC@Temp 6{14\or15\or16\or17\or18\or19\or0\or1\or2\or3}% +$ \BIC@Temp 7{13\or14\or15\or16\or17\or18\or19\or0\or1\or2}% +$ \BIC@Temp 8{12\or13\or14\or15\or16\or17\or18\or19\or0\or1}% +$ \BIC@Temp 9{11\or12\or13\or14\or15\or16\or17\or18\or19\or0}% +\def\bigintcalcShl#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Shl + \bigintcalcNum{#1}!% +} +\def\BIC@Shl#1#2!{% + \ifx#1-% + \BIC@AfterFi{% + \expandafter-\romannumeral0% +& \BIC@@Shl#2!!% +$ \BIC@AddXY#2!#2!!!% + }% + \else + \BIC@AfterFi{% +& \BIC@@Shl#1#2!!% +$ \BIC@AddXY#1#2!#1#2!!!% + }% + \BIC@Fi +} +\def\BigIntCalcShl#1!{% + \romannumeral0% +& \BIC@@Shl#1!!% +$ \BIC@AddXY#1!#1!!!% +} +& \def\BIC@@Shl#1#2!{% +& \ifx\\#2\\% +& \BIC@AfterFi{% +& \BIC@@@Shl0!#1% +& }% +& \else +& \BIC@AfterFi{% +& \BIC@@Shl#2!#1% +& }% +& \BIC@Fi +& }% +& \def\BIC@@@Shl#1#2!#3#4!{% +& \ifx\\#4\\% +& \BIC@AfterFi{% +& \expandafter\BIC@Space +& \the\numexpr#3*2+#1\relax#2% +& }% +& \else +& \BIC@AfterFi{% +& \expandafter\BIC@@@@Shl\the\numexpr#3*2+#1!#2!#4!% +& }% +& \BIC@Fi +& }% +& \def\BIC@@@@Shl#1!{% +& \ifnum#1<10 % +& \BIC@AfterFi{% +& \BIC@@@Shl0#1% +& }% +& \else +& \BIC@AfterFi{% +& \BIC@@@Shl#1% +& }% +& \BIC@Fi +& }% +\def\bigintcalcShr#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Shr + \bigintcalcNum{#1}!% +} +\def\BIC@Shr#1#2!{% + \ifx#1-% + \expandafter-\romannumeral0% + \BIC@AfterFi{% + \BIC@@Shr#2!% + }% + \else + \BIC@AfterFi{% + \BIC@@Shr#1#2!% + }% + \BIC@Fi +} +\def\BigIntCalcShr#1!{% + \romannumeral0% + \BIC@@Shr#1!% +} +\def\BIC@@Shr#1#2!{% + \ifcase#1 % + \BIC@AfterFi{ 0}% + \or + \ifx\\#2\\% + \BIC@AfterFiFi{ 0}% + \else + \BIC@AfterFiFi{% + \BIC@@@Shr#1#2!!% + }% + \fi + \else + \BIC@AfterFi{% + \BIC@@@Shr0#1#2!!% + }% + \BIC@Fi +} +\def\BIC@@@Shr#1#2#3!#4!{% + \ifx\\#3\\% + \ifodd#1#2 % + \BIC@AfterFiFi{% +& \expandafter\BIC@ShrResult\the\numexpr(#1#2-1)/2\relax +$ \expandafter\expandafter\expandafter\BIC@ShrResult +$ \csname BIC@ShrDigit#1#2\endcsname + #4!% + }% + \else + \BIC@AfterFiFi{% +& \expandafter\BIC@ShrResult\the\numexpr#1#2/2\relax +$ \expandafter\expandafter\expandafter\BIC@ShrResult +$ \csname BIC@ShrDigit#1#2\endcsname + #4!% + }% + \fi + \else + \ifodd#1#2 % + \BIC@AfterFiFi{% +& \expandafter\BIC@@@@Shr\the\numexpr(#1#2-1)/2\relax1% +$ \expandafter\expandafter\expandafter\BIC@@@@Shr +$ \csname BIC@ShrDigit#1#2\endcsname + #3!#4!% + }% + \else + \BIC@AfterFiFi{% +& \expandafter\BIC@@@@Shr\the\numexpr#1#2/2\relax0% +$ \expandafter\expandafter\expandafter\BIC@@@@Shr +$ \csname BIC@ShrDigit#1#2\endcsname + #3!#4!% + }% + \fi + \BIC@Fi +} +& \def\BIC@ShrResult#1#2!{ #2#1}% +$ \def\BIC@ShrResult#1#2#3!{ #3#1}% +\def\BIC@@@@Shr#1#2#3!#4!{% + \BIC@@@Shr#2#3!#4#1!% +} +$ \def\BIC@Temp#1#2#3#4{% +$ \expandafter\def\csname BIC@ShrDigit#1#2\endcsname{#3#4}% +$ }% +$ \BIC@Temp 0000% +$ \BIC@Temp 0101% +$ \BIC@Temp 0210% +$ \BIC@Temp 0311% +$ \BIC@Temp 0420% +$ \BIC@Temp 0521% +$ \BIC@Temp 0630% +$ \BIC@Temp 0731% +$ \BIC@Temp 0840% +$ \BIC@Temp 0941% +$ \BIC@Temp 1050% +$ \BIC@Temp 1151% +$ \BIC@Temp 1260% +$ \BIC@Temp 1361% +$ \BIC@Temp 1470% +$ \BIC@Temp 1571% +$ \BIC@Temp 1680% +$ \BIC@Temp 1781% +$ \BIC@Temp 1890% +$ \BIC@Temp 1991% +\def\BIC@Tim#1!#2{% + \romannumeral0% + \ifcase#2 % 0 + \BIC@AfterFi{ 0}% + \or % 1 + \BIC@AfterFi{ #1}% + \or % 2 + \BIC@AfterFi{% + \BIC@Shl#1!% + }% + \else % 3-9 + \BIC@AfterFi{% + \BIC@@Tim#1!!#2% + }% + \BIC@Fi +} +\def\BIC@@Tim#1#2!{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@ProcessTim0!#1% + }% + \else + \BIC@AfterFi{% + \BIC@@Tim#2!#1% + }% + \BIC@Fi +} +\def\BIC@ProcessTim#1#2!#3#4!#5{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\BIC@Space +& \the\numexpr#3*#5+#1\relax +$ \romannumeral0\BIC@TimDigit#3#5#1% + #2% + }% + \else + \BIC@AfterFi{% + \expandafter\BIC@@ProcessTim +& \the\numexpr#3*#5+#1% +$ \romannumeral0\BIC@TimDigit#3#5#1% + !#2!#4!#5% + }% + \BIC@Fi +} +\def\BIC@@ProcessTim#1#2!{% + \ifx\\#2\\% + \BIC@AfterFi{% + \BIC@ProcessTim0#1% + }% + \else + \BIC@AfterFi{% + \BIC@ProcessTim#1#2% + }% + \BIC@Fi +} +$ \def\BIC@TimDigit#1#2#3{% +$ \ifcase#1 % 0 +$ \BIC@AfterFi{ #3}% +$ \or % 1 +$ \BIC@AfterFi{% +$ \expandafter\BIC@Space +$ \number\csname BIC@AddCarry#2\endcsname#3 % +$ }% +$ \else +$ \ifcase#3 % +$ \BIC@AfterFiFi{% +$ \expandafter\BIC@Space +$ \number\csname BIC@MulDigit#2\endcsname#1 % +$ }% +$ \else +$ \BIC@AfterFiFi{% +$ \expandafter\BIC@Space +$ \romannumeral0% +$ \expandafter\BIC@AddXY +$ \number\csname BIC@MulDigit#2\endcsname#1!% +$ #3!!!% +$ }% +$ \fi +$ \BIC@Fi +$ }% +$ \def\BIC@Temp#1#2{% +$ \expandafter\def\csname BIC@MulDigit#1\endcsname##1{% +$ \ifcase##1 0% +$ \or ##1% +$ \or #2% +$? \else\BigIntCalcError:ThisCannotHappen% +$ \fi +$ }% +$ }% +$ \BIC@Temp 3{6\or9\or12\or15\or18\or21\or24\or27}% +$ \BIC@Temp 4{8\or12\or16\or20\or24\or28\or32\or36}% +$ \BIC@Temp 5{10\or15\or20\or25\or30\or35\or40\or45}% +$ \BIC@Temp 6{12\or18\or24\or30\or36\or42\or48\or54}% +$ \BIC@Temp 7{14\or21\or28\or35\or42\or49\or56\or63}% +$ \BIC@Temp 8{16\or24\or32\or40\or48\or56\or64\or72}% +$ \BIC@Temp 9{18\or27\or36\or45\or54\or63\or72\or81}% +\def\bigintcalcMul#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Mul + \bigintcalcNum{#1}!{#2}% +} +\def\BIC@Mul#1!#2{% + \expandafter\expandafter\expandafter\BIC@MulSwitch + \bigintcalcNum{#2}!#1!% +} +\def\BIC@MulSwitch#1#2!#3#4!{% + \ifcase\BIC@Sgn#1#2! % x = 0 + \BIC@AfterFi{ 0}% + \or % x > 0 + \ifcase\BIC@Sgn#3#4! % y = 0 + \BIC@AfterFiFi{ 0}% + \or % y > 0 + \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#1#2!#3#4!% + }% + \else % x <= y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#3#4!#1#2!% + }% + \fi + \else % y < 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#1#2!#4!=1 % x > -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#1#2!#4!% + }% + \else % x <= -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#4!#1#2!% + }% + \fi + \fi + \else % x < 0 + \ifcase\BIC@Sgn#3#4! % y = 0 + \BIC@AfterFiFi{ 0}% + \or % y > 0 + \expandafter-\romannumeral0% + \ifnum\BIC@PosCmp#2!#3#4!=1 % -x > y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#2!#3#4!% + }% + \else % -x <= y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#3#4!#2!% + }% + \fi + \else % y < 0 + \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#2!#4!% + }% + \else % -x <= -y + \BIC@AfterFiFiFi{% + \BIC@ProcessMul0!#4!#2!% + }% + \fi + \fi + \BIC@Fi +} +\def\BigIntCalcMul#1!#2!{% + \romannumeral0% + \BIC@ProcessMul0!#1!#2!% +} +\def\BIC@ProcessMul#1!#2!#3#4!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@Space + \bigintcalcAdd{\BIC@Tim#2!#3}{#10}% + }% + \else + \BIC@AfterFi{% + \expandafter\expandafter\expandafter\BIC@ProcessMul + \bigintcalcAdd{\BIC@Tim#2!#3}{#10}!#2!#4!% + }% + \BIC@Fi +} + +\def\bigintcalcSqr#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Sqr + \bigintcalcNum{#1}!% +} +\def\BIC@Sqr#1{% + \ifx#1-% + \expandafter\BIC@@Sqr + \else + \expandafter\BIC@@Sqr\expandafter#1% + \fi +} +\def\BIC@@Sqr#1!{% + \BIC@ProcessMul0!#1!#1!% +} +\def\bigintcalcFac#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Fac + \bigintcalcNum{#1}!% +} +\def\BIC@Fac#1#2!{% + \ifx#1-% + \BIC@AfterFi{ 0\BigIntCalcError:FacNegative}% + \else + \ifnum\BIC@PosCmp#1#2!13!<0 % + \ifcase#1#2 % + \BIC@AfterFiFiFi{ 1}% 0! + \or\BIC@AfterFiFiFi{ 1}% 1! + \or\BIC@AfterFiFiFi{ 2}% 2! + \or\BIC@AfterFiFiFi{ 6}% 3! + \or\BIC@AfterFiFiFi{ 24}% 4! + \or\BIC@AfterFiFiFi{ 120}% 5! + \or\BIC@AfterFiFiFi{ 720}% 6! + \or\BIC@AfterFiFiFi{ 5040}% 7! + \or\BIC@AfterFiFiFi{ 40320}% 8! + \or\BIC@AfterFiFiFi{ 362880}% 9! + \or\BIC@AfterFiFiFi{ 3628800}% 10! + \or\BIC@AfterFiFiFi{ 39916800}% 11! + \or\BIC@AfterFiFiFi{ 479001600}% 12! +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \else + \BIC@AfterFiFi{% + \BIC@ProcessFac#1#2!479001600!% + }% + \fi + \BIC@Fi +} +\def\BIC@ProcessFac#1!#2!{% + \ifnum\BIC@PosCmp#1!12!=0 % + \BIC@AfterFi{ #2}% + \else + \BIC@AfterFi{% + \expandafter\BIC@@ProcessFac + \romannumeral0\BIC@ProcessMul0!#2!#1!% + !#1!% + }% + \BIC@Fi +} +\def\BIC@@ProcessFac#1!#2!{% + \expandafter\BIC@ProcessFac + \romannumeral0\BIC@Dec#2!{}% + !#1!% +} +\def\bigintcalcPow#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Pow + \bigintcalcNum{#1}!% +} +\def\BIC@Pow#1!#2{% + \expandafter\expandafter\expandafter\BIC@PowSwitch + \bigintcalcNum{#2}!#1!% +} +\def\BIC@PowSwitch#1#2!#3#4!{% + \ifcase\ifx\\#2\\% + \ifx#100 % y = 0 + \else\ifx#111 % y = 1 + \else\ifx#122 % y = 2 + \else4 % y > 2 + \fi\fi\fi + \else + \ifx#1-3 % y < 0 + \else4 % y > 2 + \fi + \fi + \BIC@AfterFi{ 1}% y = 0 + \or % y = 1 + \BIC@AfterFi{ #3#4}% + \or % y = 2 + \ifx#3-% x < 0 + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#4!#4!% + }% + \else % x >= 0 + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#3#4!#3#4!% + }% + \fi + \or % y < 0 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else\ifx#311 % x = 1 + \else3 % x > 1 + \fi\fi + \else + \ifcase\BIC@MinusOne#3#4! % + 3 % |x| > 1 + \or + 2 % x = -1 +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \fi + \BIC@AfterFiFi{ 0\BigIntCalcError:DivisionByZero}% x = 0 + \or % x = 1 + \BIC@AfterFiFi{ 1}% x = 1 + \or % x = -1 + \ifcase\BIC@ModTwo#2! % even(y) + \BIC@AfterFiFiFi{ 1}% + \or % odd(y) + \BIC@AfterFiFiFi{ -1}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % |x| > 1 + \BIC@AfterFiFi{ 0}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % y > 2 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else\ifx#311 % x = 1 + \else4 % x > 1 + \fi\fi + \else + \ifx#3-% + \ifcase\BIC@MinusOne#3#4! % + 3 % x < -1 + \else + 2 % x = -1 + \fi + \else + 4 % x > 1 + \fi + \fi + \BIC@AfterFiFi{ 0}% x = 0 + \or % x = 1 + \BIC@AfterFiFi{ 1}% x = 1 + \or % x = -1 + \ifcase\BIC@ModTwo#1#2! % even(y) + \BIC@AfterFiFiFi{ 1}% + \or % odd(y) + \BIC@AfterFiFiFi{ -1}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % x < -1 + \ifcase\BIC@ModTwo#1#2! % even(y) + \BIC@AfterFiFiFi{% + \BIC@PowRec#4!#1#2!1!% + }% + \or % odd(y) + \expandafter-\romannumeral0% + \BIC@AfterFiFiFi{% + \BIC@PowRec#4!#1#2!1!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % x > 1 + \BIC@AfterFiFi{% + \BIC@PowRec#3#4!#1#2!1!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +\def\BIC@ModTwo#1#2!{% + \ifx\\#2\\% + \ifodd#1 % + \BIC@AfterFiFi1% + \else + \BIC@AfterFiFi0% + \fi + \else + \BIC@AfterFi{% + \BIC@ModTwo#2!% + }% + \BIC@Fi +} +\def\BIC@MinusOne#1#2!{% + \ifx#1-% + \BIC@@MinusOne#2!% + \else + 0% + \fi +} +\def\BIC@@MinusOne#1#2!{% + \ifx#11% + \ifx\\#2\\% + 1% + \else + 0% + \fi + \else + 0% + \fi +} +\def\BIC@PowRec#1!#2#3!#4!{% + \ifcase\ifx#21\ifx\\#3\\0 \else1 \fi\else1 \fi % y = 1 + \ifnum\BIC@PosCmp#1!#4!=1 % x > r + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#1!#4!% + }% + \else + \BIC@AfterFiFi{% + \BIC@ProcessMul0!#4!#1!% + }% + \fi + \or + \ifcase\BIC@ModTwo#2#3! % even(y) + \BIC@AfterFiFi{% + \expandafter\BIC@@PowRec\romannumeral0% + \BIC@@Shr#2#3!% + !#1!#4!% + }% + \or % odd(y) + \ifnum\BIC@PosCmp#1!#4!=1 % x > r + \BIC@AfterFiFiFi{% + \expandafter\BIC@@@PowRec\romannumeral0% + \BIC@ProcessMul0!#1!#4!% + !#1!#2#3!% + }% + \else + \BIC@AfterFiFiFi{% + \expandafter\BIC@@@PowRec\romannumeral0% + \BIC@ProcessMul0!#1!#4!% + !#1!#2#3!% + }% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +\def\BIC@@PowRec#1!#2!#3!{% + \expandafter\BIC@PowRec\romannumeral0% + \BIC@ProcessMul0!#2!#2!% + !#1!#3!% +} +\def\BIC@@@PowRec#1!#2!#3!{% + \expandafter\BIC@@PowRec\romannumeral0% + \BIC@@Shr#3!% + !#2!#1!% +} +\def\bigintcalcDiv#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Div + \bigintcalcNum{#1}!% +} +\def\BIC@Div#1!#2{% + \expandafter\expandafter\expandafter\BIC@DivSwitchSign + \bigintcalcNum{#2}!#1!% +} +\def\BigIntCalcDiv#1!#2!{% + \romannumeral0% + \BIC@DivSwitchSign#2!#1!% +} +\def\BIC@DivSwitchSign#1#2!#3#4!{% + \ifcase\BIC@Sgn#1#2! % y = 0 + \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}% + \or % y > 0 + \ifcase\BIC@Sgn#3#4! % x = 0 + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch{}#3#4!#1#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch-#4!#1#2!% + }% + \fi + \else % y < 0 + \ifcase\BIC@Sgn#3#4! % x = 0 + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch-#3#4!#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@DivSwitch{}#4!#2!% + }% + \fi + \BIC@Fi +} +\def\BIC@DivSwitch#1#2!#3#4!{% + \ifcase\BIC@PosCmp#3#4!#2!% y = x + \BIC@AfterFi{ #11}% + \or % y > x + \BIC@AfterFi{ 0}% + \else % y < x + \ifx\\#1\\% + \else + \expandafter-\romannumeral0% + \fi + \ifcase\ifx\\#4\\% + \ifx#310 % y = 1 + \else\ifx#321 % y = 2 + \else\ifx#342 % y = 4 + \else3 % y > 2 + \fi\fi\fi + \else + 3 % y > 2 + \fi + \BIC@AfterFiFi{ #2}% y = 1 + \or % y = 2 + \BIC@AfterFiFi{% + \BIC@@Shr#2!% + }% + \or % y = 4 + \BIC@AfterFiFi{% + \expandafter\BIC@@Shr\romannumeral0% + \BIC@@Shr#2!!% + }% + \or % y > 2 + \BIC@AfterFiFi{% + \BIC@DivStartX#2!#3#4!!!% + }% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \BIC@Fi +} +\def\BIC@DivStartX#1#2!#3#4!#5!#6!{% + \ifx\\#4\\% + \BIC@AfterFi{% + \BIC@DivStartYii#6#3#4!{#5#1}#2=!% + }% + \else + \BIC@AfterFi{% + \BIC@DivStartX#2!#4!#5#1!#6#3!% + }% + \BIC@Fi +} +\def\BIC@DivStartYii#1!{% + \expandafter\BIC@DivStartYiv\romannumeral0% + \BIC@Shl#1!% + !#1!% +} +\def\BIC@DivStartYiv#1!{% + \expandafter\BIC@DivStartYvi\romannumeral0% + \BIC@Shl#1!% + !#1!% +} +\def\BIC@DivStartYvi#1!#2!{% + \expandafter\BIC@DivStartYviii\romannumeral0% + \BIC@AddXY#1!#2!!!% + !#1!#2!% +} +\def\BIC@DivStartYviii#1!#2!{% + \expandafter\BIC@DivStart\romannumeral0% + \BIC@Shl#2!% + !#1!#2!% +} +\def\BIC@DivStart#1!#2!#3!#4!#5!#6!{% + \BIC@ProcessDiv#6!!#5!#4!#3!#2!#1!=% +} +\def\BIC@ProcessDiv#1#2#3!#4!#5!{% + \ifcase\BIC@PosCmp#5!#1!% y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#41}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#41!#5!% + }% + \fi + \or % y > #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#40}}% + \else + \ifx\\#4\\% + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv{#1#2}#3!!#5!% + }% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv{#1#2}#3!#40!#5!% + }% + \fi + \fi + \else % y < #1 + \BIC@AfterFi{% + \BIC@@ProcessDiv{#1}#2#3!#4!#5!% + }% + \BIC@Fi +} +\def\BIC@DivCleanup#1#2={ #1}% +\def\BIC@@ProcessDiv#1#2#3!#4!#5!#6!#7!{% + \ifcase\BIC@PosCmp#7!#1!% 4y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#44}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#44!#5!#6!#7!% + }% + \fi + \or % 4y > #1 + \ifcase\BIC@PosCmp#6!#1!% 2y = #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#42}}% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv#2#3!#42!#5!#6!#7!% + }% + \fi + \or % 2y > #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#41}}% + \else + \BIC@AfterFiFiFi{% + \BIC@DivSub#1!#5!#2#3!#41!#5!#6!#7!% + }% + \fi + \else % 2y < #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#6!!!% + !#2#3!#4!#5!23% + #6!#7!% + }% + \fi + \else % 4y < #1 + \BIC@AfterFi{% + \BIC@@@ProcessDiv{#1}#2#3!#4!#5!#6!#7!% + }% + \BIC@Fi +} +\def\BIC@DivSub#1!#2!#3{% + \expandafter\BIC@ProcessDiv\expandafter{% + \romannumeral0% + \BIC@SubXY#1!#2!!!% + #3% + }% +} +\def\BIC@ProcessDivII#1!#2#3!#4!#5!#6#7{% + \ifcase\BIC@PosCmp#5!#1!% y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#4#7!#5!% + }% + \fi + \or % y > #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#6}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv{#1#2}#3!#4#6!#5!% + }% + \fi + \else % y < #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}% + \else + \BIC@AfterFiFi{% + \BIC@DivSub#1!#5!#2#3!#4#7!#5!% + }% + \fi + \BIC@Fi +} +\def\BIC@@@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9!{% + \ifcase\BIC@PosCmp#8!#1!% 6y = #1 + \ifx#2=% + \BIC@AfterFiFi{\BIC@DivCleanup{#46}}% + \else + \BIC@AfterFiFi{% + \BIC@ProcessDiv#2#3!#46!#5!#6!#7!#8!#9!% + }% + \fi + \or % 6y > #1 + \BIC@AfterFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#7!!!% + !#2#3!#4!#5!45% + #6!#7!#8!#9!% + }% + \else % 6y < #1 + \ifcase\BIC@PosCmp#9!#1!% 8y = #1 + \ifx#2=% + \BIC@AfterFiFiFi{\BIC@DivCleanup{#48}}% + \else + \BIC@AfterFiFiFi{% + \BIC@ProcessDiv#2#3!#48!#5!#6!#7!#8!#9!% + }% + \fi + \or % 8y > #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#8!!!% + !#2#3!#4!#5!67% + #6!#7!#8!#9!% + }% + \else % 8y < #1 + \BIC@AfterFiFi{% + \expandafter\BIC@ProcessDivII\romannumeral0% + \BIC@SubXY#1!#9!!!% + !#2#3!#4!#5!89% + #6!#7!#8!#9!% + }% + \fi + \BIC@Fi +} +\def\bigintcalcMod#1{% + \romannumeral0% + \expandafter\expandafter\expandafter\BIC@Mod + \bigintcalcNum{#1}!% +} +\def\BIC@Mod#1!#2{% + \expandafter\expandafter\expandafter\BIC@ModSwitchSign + \bigintcalcNum{#2}!#1!% +} +\def\BigIntCalcMod#1!#2!{% + \romannumeral0% + \BIC@ModSwitchSign#2!#1!% +} +\def\BIC@ModSwitchSign#1#2!#3#4!{% + \ifcase\ifx\\#2\\% + \ifx#100 % y = 0 + \else1 % y > 0 + \fi + \else + \ifx#1-2 % y < 0 + \else1 % y > 0 + \fi + \fi + \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}% + \or % y > 0 + \ifcase\ifx\\#4\\\ifx#300 \else1 \fi\else1 \fi % x = 0 + \BIC@AfterFiFi{ 0}% + \else + \BIC@AfterFiFi{% + \BIC@ModSwitch{}#3#4!#1#2!% + }% + \fi + \else % y < 0 + \ifcase\ifx\\#4\\% + \ifx#300 % x = 0 + \else1 % x > 0 + \fi + \else + \ifx#3-2 % x < 0 + \else1 % x > 0 + \fi + \fi + \BIC@AfterFiFi{ 0}% + \or % x > 0 + \BIC@AfterFiFi{% + \BIC@ModSwitch--#3#4!#2!% + }% + \else % x < 0 + \BIC@AfterFiFi{% + \BIC@ModSwitch-#4!#2!% + }% + \fi + \BIC@Fi +} +\def\BIC@ModSwitch#1#2#3!#4#5!{% + \ifcase\ifx\\#5\\% + \ifx#410 % y = 1 + \else\ifx#421 % y = 2 + \else2 % y > 2 + \fi\fi + \else2 % y > 2 + \fi + \BIC@AfterFi{ 0}% y = 1 + \or % y = 2 + \ifcase\BIC@ModTwo#2#3! % even(x) + \BIC@AfterFiFi{ 0}% + \or % odd(x) + \BIC@AfterFiFi{ #11}% +? \else\BigIntCalcError:ThisCannotHappen% + \fi + \or % y > 2 + \ifx\\#1\\% + \else + \expandafter\BIC@Space\romannumeral0% + \expandafter\BIC@ModMinus\romannumeral0% + \fi + \ifx#2-% x < 0 + \BIC@AfterFiFi{% + \expandafter\expandafter\expandafter\BIC@ModX + \bigintcalcSub{#2#3}{% + \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}% + }!#4#5!% + }% + \else % x > 0 + \BIC@AfterFiFi{% + \expandafter\expandafter\expandafter\BIC@Space + \bigintcalcSub{#2#3}{% + \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}% + }% + }% + \fi +? \else\BigIntCalcError:ThisCannotHappen% + \BIC@Fi +} +\def\BIC@ModMinus#1{% + \ifx#10% + \BIC@AfterFi{ 0}% + \else + \BIC@AfterFi{ -#1}% + \BIC@Fi +} +\def\BIC@ModX#1#2!#3!{% + \ifx#1-% z < 0 + \BIC@AfterFi{% + \expandafter\BIC@Space\romannumeral0% + \BIC@SubXY#3!#2!!!% + }% + \else % z >= 0 + \BIC@AfterFi{ #1#2}% + \BIC@Fi +} +\BIC@AtEnd +\endinput +%% +%% End of file `bigintcalc.sty'. diff --git a/Master/texmf-dist/tex/generic/oberdiek/bitset.sty b/Master/texmf-dist/tex/generic/oberdiek/bitset.sty new file mode 100644 index 00000000000..4536394a322 --- /dev/null +++ b/Master/texmf-dist/tex/generic/oberdiek/bitset.sty @@ -0,0 +1,1395 @@ +%% +%% This is file `bitset.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bitset.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file bitset.dtx +%% and the derived files +%% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, +%% bitset-test1.tex, bitset-test2.tex, bitset-test3.tex. +%% +\begingroup + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\let\expandafter\x\csname ver@bitset.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{bitset}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@bitset.sty\endcsname +\ProvidesPackage{bitset}% + [2007/09/28 v1.0 Data type bit set (HO)] +\expandafter\edef\csname BitSet@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\BitSet@AtEnd{% + \BitSet@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{11}% : (letter!) +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{63}{14}% ? (comment!) +\TMP@EnsureCode{96}{12}% ` +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname BitSet@TestMode\endcsname\relax +\else + \catcode63=9 % ? (ignore) +\fi +? \let\BitSet@@TestMode\BitSet@TestMode +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input infwarerr.sty\relax + \input intcalc.sty\relax + \input bigintcalc.sty\relax +\else + \RequirePackage{infwarerr}[2007/09/09]% + \RequirePackage{intcalc}[2007/09/27]% + \RequirePackage{bigintcalc}[2007/09/27]% +\fi +\def\BitSet@MaxSize{2147483647}% +\def\BitSet@Empty{} +\def\BitSet@FirstOfOne#1{#1} +\def\BitSet@Gobble#1{} +\def\BitSet@FirstOfTwo#1#2{#1} +\def\BitSet@SecondOfTwo#1#2{#2} +\def\BitSet@Space{ } +\def\BitSet@ZapSpace#1 #2{% + #1% + \ifx\BitSet@Empty#2% + \else + \expandafter\BitSet@ZapSpace + \fi + #2% +} +\let\BitSet@Fi\fi +\def\BitSet@AfterFi#1#2\BitSet@Fi{\fi#1} +\def\BitSet@AfterFiFi#1#2\BitSet@Fi{\fi\fi#1}% +\def\BitSet@AfterFiFiFi#1#2\BitSet@Fi{\fi\fi\fi#1}% +\def\BitSet@IfUndefined#1{% + \expandafter\ifx\csname BS@#1\endcsname\relax + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi +} +\def\BitSet@CheckIndex#1#2#3{% + \BitSet@IfUndefined{#2}{\bitsetReset{#2}}{}% + \expandafter\expandafter\expandafter\BitSet@@CheckIndex + \intcalcNum{#3}!% + {#2}{#1}% +} +\def\BitSet@@CheckIndex#1!#2#3{% + \ifnum#1<0 % + \BitSet@AfterFi{% + \@PackageError{bitset}{% + Invalid negative index (#1)% + }\@ehc + }% + \else + \BitSet@AfterFi{% + #3{#2}{#1}% + }% + \BitSet@Fi +} +\def\bitsetReset#1{% + \expandafter\def\csname BS@#1\endcsname{0}% +} +\def\bitsetLet#1#2{% + \BitSet@IfUndefined{#2}{% + \bitsetReset{#1}% + }{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }% +} +\def\bitsetSetBin#1#2{% + \edef\BitSet@Temp{#2}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \else + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@Reverse\BitSet@Temp!% + }% + \fi +} +\def\BitSet@KillZeros#1{% + \ifx#10% + \expandafter\BitSet@KillZeros + \else + #1% + \fi +} +\def\BitSet@Reverse#1#2!{% + \ifx\\#2\\% + #1% + \else + \BitSet@AfterFi{% + \BitSet@Reverse#2!#1% + }% + \BitSet@Fi +} +\def\bitsetSetOct{% + \BitSet@SetOctHex\BitSet@FromFirstOct +} +\def\bitsetSetHex{% + \BitSet@SetOctHex\BitSet@FromFirstHex +} +\def\BitSet@SetOctHex#1#2#3{% + \edef\BitSet@Temp{#3}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#2\endcsname\BitSet@Zero + \else + \edef\BitSet@Temp{% + \expandafter#1\BitSet@Temp!% + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#2\endcsname\BitSet@Zero + \else + \expandafter\edef\csname BS@#2\endcsname{% + \expandafter\BitSet@Reverse\BitSet@Temp!% + }% + \fi + \fi +} +\def\BitSet@FromFirstOct#1{% + \ifx#1!% + \else + \ifcase#1 \BitSet@AfterFiFi\BitSet@FromFirstOct + \or 1% + \or 10% + \or 11% + \or 100% + \or 101% + \or 110% + \or 111% + \else \BitSetError:WrongOctalDigit% + \fi + \expandafter\BitSet@FromOct + \BitSet@Fi +} +\def\BitSet@FromOct#1{% + \ifx#1!% + \else + \ifcase#1 000% + \or 001% + \or 010% + \or 011% + \or 100% + \or 101% + \or 110% + \or 111% + \else \BitSetError:WrongOctalDigit% + \fi + \expandafter\BitSet@FromOct + \fi +} +\def\BitSet@FromFirstHex#1{% + \ifx#1!% + \else + \ifx#10% + \BitSet@AfterFiFi\BitSet@FromFirstHex + \fi + \expandafter\ifx\csname BitSet@Hex#1\endcsname\relax + \BitSetError:InvalidHexDigit% + \else + \expandafter\expandafter\expandafter\BitSet@KillZeros + \csname BitSet@Hex#1\endcsname + \fi + \expandafter\BitSet@FromHex + \BitSet@Fi +} +\def\BitSet@FromHex#1{% + \ifx#1!% + \else + \expandafter\ifx\csname BitSet@Hex#1\endcsname\relax + \BitSetError:InvalidHexDigit% + \else + \csname BitSet@Hex#1\endcsname + \fi + \expandafter\BitSet@FromHex + \fi +} +\def\BitSet@Temp#1{% + \expandafter\def\csname BitSet@Hex#1\endcsname +} +\BitSet@Temp 0{0000}% +\BitSet@Temp 1{0001}% +\BitSet@Temp 2{0010}% +\BitSet@Temp 3{0011}% +\BitSet@Temp 4{0100}% +\BitSet@Temp 5{0101}% +\BitSet@Temp 6{0110}% +\BitSet@Temp 7{0111}% +\BitSet@Temp 8{1000}% +\BitSet@Temp 9{1001}% +\BitSet@Temp A{1010}% +\BitSet@Temp B{1011}% +\BitSet@Temp C{1100}% +\BitSet@Temp D{1101}% +\BitSet@Temp E{1110}% +\BitSet@Temp F{1111}% +\BitSet@Temp a{1010}% +\BitSet@Temp b{1011}% +\BitSet@Temp c{1100}% +\BitSet@Temp d{1101}% +\BitSet@Temp e{1110}% +\BitSet@Temp f{1111}% +\def\bitsetSetDec#1#2{% + \edef\BitSet@Temp{#2}% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@ZapSpace + \expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty + }% + \edef\BitSet@Temp{% + \expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty + }% + \ifx\BitSet@Temp\BitSet@Empty + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \else + \ifcase\bigintcalcSgn{\BitSet@Temp} % + \expandafter\let\csname BS@#1\endcsname\BitSet@Zero + \or + \ifnum\bigintcalcCmp\BitSet@Temp\BitSet@MaxSize>0 % + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@SetDecBig\BitSet@Temp!% + }% + \else + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\BitSet@SetDec\BitSet@Temp!% + }% + \fi + \else + \@PackageError{bitset}{% + Bit sets cannot be negative% + }\@ehc + \fi + \fi +} +\def\BitSet@SetDecBig#1#2#3#4#5#6#7#8#9!{% + \ifx\\#9\\% + \BitSet@SetDec#1#2#3#4#5#6#7#8!% + \else + \ifcase\BigIntCalcOdd#1#2#4#5#6#7#8#9! % + 0% + \or + 1% +? \else\BitSetError:ThisCannotHappen% + \fi + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@SetDecBig + \BigIntCalcShr#1#2#3#4#5#6#7#8#9!!% + }% + \BitSet@Fi +} +\def\BitSet@SetDec#1!{% + \ifcase#1 % + \or 1% + \else + \ifodd#1 % + 1% + \else + 0% + \fi + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@SetDec + \IntCalcShr#1!!% + }% + \BitSet@Fi +} +\def\bitsetGetBin#1#2{% + \romannumeral0% + \expandafter\expandafter\expandafter\BitSet@@GetBin + \intcalcNum{#2}!{#1}% +} +\def\BitSet@@GetBin#1!#2{% + \BitSet@IfUndefined{#2}{% + \ifnum#1>1 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcDec#1!!0% + }% + \else + \BitSet@AfterFi{ 0}% + \BitSet@Fi + }{% + \expandafter\expandafter\expandafter\BitSet@NumBinRev + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!#1!% + }% +} +\def\BitSet@Fill#1!{% + \ifnum#1>0 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcDec#1!!0% + }% + \else + \BitSet@AfterFi{ }% + \BitSet@Fi +} +\def\BitSet@NumBinRev#1!#2#3!{% + \ifx\\#3\\% + \BitSet@AfterFi{% + \BitSet@NumBinFill#1!#2% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@NumBinRev + \IntCalcInc#1!!#3!#2% + }% + \BitSet@Fi +} +\def\BitSet@NumBinFill#1!#2!#3!{% + \ifnum#3>#1 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@Fill + \IntCalcSub#3!#1!!#2% + }% + \else + \BitSet@AfterFi{ #2}% + \BitSet@Fi +} +\def\bitsetGetOct#1#2{% + \romannumeral0% + \bitsetIsEmpty{#1}{% + \expandafter\expandafter\expandafter\BitSet@@GetOctHex + \intcalcNum{#2}!3!230% + }{% + \expandafter\expandafter\expandafter\BitSet@@GetOct + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname00% + \BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% + }% +} +\def\bitsetGetHex#1#2{% + \romannumeral0% + \bitsetIsEmpty{#1}{% + \expandafter\expandafter\expandafter\BitSet@@GetOctHex + \intcalcNum{#2}!4!340% + }{% + \expandafter\expandafter\expandafter\BitSet@@GetHex + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname000% + \BitSet@Empty\BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% + }% +} +\def\BitSet@@GetOct#1!#2!#3#4#5{% + \ifx#5\BitSet@Empty + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@GetOctHex + \IntCalcDec#1!!#2!23% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@GetOct + \number\IntCalcInc#1!\expandafter\expandafter\expandafter!% + \csname BitSet@Oct#5#4#3\endcsname#2!% + }% + \BitSet@Fi +} +\def\BitSet@Temp#1#2#3#4{% + \expandafter\def\csname BitSet@Oct#1#2#3\endcsname{#4}% +} +\BitSet@Temp0000% +\BitSet@Temp0011% +\BitSet@Temp0102% +\BitSet@Temp0113% +\BitSet@Temp1004% +\BitSet@Temp1015% +\BitSet@Temp1106% +\BitSet@Temp1117% +\def\BitSet@@GetHex#1!#2!#3#4#5#6{% + \ifx#6\BitSet@Empty + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@GetOctHex + \IntCalcDec#1!!#2!34% + }% + \else + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@GetHex + \number\IntCalcInc#1!\expandafter\expandafter\expandafter!% + \csname BitSet@Hex#6#5#4#3\endcsname#2!% + }% + \BitSet@Fi +} +\def\BitSet@Temp#1#2#3#4#5{% + \expandafter\def\csname BitSet@Hex#1#2#3#4\endcsname{#5}% +} +\BitSet@Temp00000% +\BitSet@Temp00011% +\BitSet@Temp00102% +\BitSet@Temp00113% +\BitSet@Temp01004% +\BitSet@Temp01015% +\BitSet@Temp01106% +\BitSet@Temp01117% +\BitSet@Temp10008% +\BitSet@Temp10019% +\BitSet@Temp1010A% +\BitSet@Temp1011B% +\BitSet@Temp1100C% +\BitSet@Temp1101D% +\BitSet@Temp1110E% +\BitSet@Temp1111F% +\def\BitSet@GetOctHex#1!#2!#3#4#5!#6{% + \expandafter\BitSet@@GetOctHex + \number\intcalcNum{#6}\expandafter\expandafter\expandafter!% + \IntCalcMul#1!#4!!#3#4#2% +} +\def\BitSet@@GetOctHex#1!#2!#3#4{% + \ifnum#1>#2 % + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\BitSet@Fill + \expandafter\IntCalcDiv\number + \expandafter\expandafter\expandafter\IntCalcAdd + \IntCalcSub#1!#2!!#3!!#4!!% + }% + \else + \BitSet@AfterFi{ }% + \BitSet@Fi +} +\def\bitsetGetDec#1{% + \romannumeral0% + \BitSet@IfUndefined{#1}{ 0}{% + \expandafter\expandafter\expandafter\BitSet@GetDec + \csname BS@#1\endcsname!% + }% +} +\def\BitSet@GetDec#1#2!{% + \ifx\\#2\\% + \BitSet@AfterFi{ #1}% + \else + \BitSet@AfterFi{% + \BitSet@@GetDec2!#1!#2!% + }% + \BitSet@Fi +} +\def\BitSet@@GetDec#1!#2!#3#4!{% + \ifx\\#4\\% + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Space + \IntCalcAdd#1!#2!% + }% + \else + \BitSet@AfterFiFi{ #2}% + \fi + \else + \ifx#31% + \BitSet@AfterFiFi{% + \csname BitSet@N#1% + \expandafter\expandafter\expandafter\endcsname + \IntCalcAdd#1!#2!!#4!% + }% + \else + \BitSet@AfterFiFi{% + \csname BitSet@N#1\endcsname#2!#4!% + }% + \fi + \BitSet@Fi +} +\def\BitSet@Temp#1#2{% + \expandafter\def\csname BitSet@N#1\endcsname{% + \BitSet@@GetDec#2!% + }% +} +\BitSet@Temp{1}{2} +\BitSet@Temp{2}{4} +\BitSet@Temp{4}{8} +\BitSet@Temp{8}{16} +\BitSet@Temp{16}{32} +\BitSet@Temp{32}{64} +\BitSet@Temp{64}{128} +\BitSet@Temp{128}{256} +\BitSet@Temp{256}{512} +\BitSet@Temp{512}{1024} +\BitSet@Temp{1024}{2048} +\BitSet@Temp{2048}{4096} +\BitSet@Temp{4096}{8192} +\BitSet@Temp{8192}{16384} +\BitSet@Temp{16384}{32768} +\BitSet@Temp{32768}{65536} +\BitSet@Temp{65536}{131072} +\BitSet@Temp{131072}{262144} +\BitSet@Temp{262144}{524288} +\BitSet@Temp{524288}{1048576} +\BitSet@Temp{1048576}{2097152} +\BitSet@Temp{2097152}{4194304} +\BitSet@Temp{4194304}{8388608} +\BitSet@Temp{8388608}{16777216} +\BitSet@Temp{16777216}{33554432} +\BitSet@Temp{33554432}{67108864} +\BitSet@Temp{67108864}{134217728} +\BitSet@Temp{134217728}{268435456} +\BitSet@Temp{268435456}{536870912} +\BitSet@Temp{536870912}{1073741824} +\expandafter\def\csname BitSet@N1073741824\endcsname{% + \BitSet@GetDecBig2147483648!% +}% +\def\BitSet@GetDecBig#1!#2!#3#4!{% + \ifx\\#4\\% + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Space + \BigIntCalcAdd#1!#2!% + }% + \else + \BitSet@AfterFiFi{ #2}% + \fi + \else + \ifx#31% + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@GetDecBig + \BigIntCalcAdd#1!#2!!#1!#4!% + }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@GetDecBig + \BigIntCalcShl#1!!#2!#4!% + }% + \fi + \BitSet@Fi +} +\def\BitSet@@GetDecBig#1!#2!{% + \expandafter\expandafter\expandafter\BitSet@GetDecBig + \BigIntCalcShl#2!!#1!% +} +\def\bitsetAnd#1#2{% + \bitsetIsEmpty{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#2}{% + \bitsetReset{#1}% + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@And + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +\def\BitSet@And#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifnum#1#3=11 #51\fi + \else + \ifx\\#4\\% + \ifnum#1#3=11 #51\fi + \else + \ifnum#1#3=11 % + #51% + \BitSet@AfterFiFiFi{% + \BitSet@And#2!#4!!% + }% + \else + \BitSet@AfterFiFiFi{% + \BitSet@And#2!#4!#50!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetAndNot#1#2{% + \bitsetIsEmpty{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#2}{% + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@AndNot + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +\def\BitSet@AndNot#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifnum#1#3=10 #51\fi + \else + \ifx\\#4\\% + #5% + \ifnum#1#3=10 1\else 0\fi + #2% + \else + \ifnum#1#3=10 % + #51% + \BitSet@AfterFiFiFi{% + \BitSet@AndNot#2!#4!!% + }% + \else + \BitSet@AfterFiFiFi{% + \BitSet@AndNot#2!#4!#50!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetOr#1#2{% + \bitsetIsEmpty{#2}{% + \BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% + }{% + \bitsetIsEmpty{#1}{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Or + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!% + }% + }% + }% +} +\def\BitSet@Or#1#2!#3#4!{% + \ifnum#1#3>0 1\else 0\fi + \ifx\\#2\\% + #4% + \else + \ifx\\#4\\% + #2% + \else + \BitSet@AfterFiFi{% + \BitSet@Or#2!#4!% + }% + \fi + \BitSet@Fi +} +\def\bitsetXor#1#2{% + \bitsetIsEmpty{#2}{% + \BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% + }{% + \bitsetIsEmpty{#1}{% + \expandafter\let\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + }{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Xor + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!% + }% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty + \bitsetReset{#1}% + \fi + }% + }% +} +\def\BitSet@Xor#1#2!#3#4!#5!{% + \ifx\\#2\\% + \ifx#1#3% + \ifx\\#4\\% + \else + #50#4% + \fi + \else + #51#4% + \fi + \else + \ifx\\#4\\% + #5% + \ifx#1#30\else 1\fi + #2% + \else + \ifx#1#3% + \BitSet@AfterFiFiFi{% + \BitSet@Xor#2!#4!#50!% + }% + \else + #51% + \BitSet@AfterFiFiFi{% + \BitSet@Xor#2!#4!!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetShiftLeft#1#2{% + \BitSet@IfUndefined{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#1}{% + }{% + \expandafter\expandafter\expandafter\BitSet@ShiftLeft + \intcalcNum{#2}!{#1}% + }% + }% +} +\def\BitSet@ShiftLeft#1!#2{% + \ifcase\intcalcSgn{#1} % + \or + \begingroup + \uccode`m=`0 % + \uppercase\expandafter{\expandafter\endgroup + \expandafter\edef\csname BS@#2\expandafter\endcsname + \expandafter{% + \romannumeral#1000\expandafter\BitSet@Space + \csname BS@#2\endcsname + }% + }% + \else + \expandafter\BitSet@ShiftRight\BitSet@Gobble#1!{#2}% + \fi +} +\def\bitsetShiftRight#1#2{% + \BitSet@IfUndefined{#1}{% + \bitsetReset{#1}% + }{% + \bitsetIsEmpty{#1}{% + }{% + \expandafter\expandafter\expandafter\BitSet@ShiftRight + \intcalcNum{#2}!{#1}% + }% + }% +} +\def\BitSet@ShiftRight#1!#2{% + \ifcase\intcalcSgn{#1} % + \or + \expandafter\edef\csname BS@#2\endcsname{% + \expandafter\expandafter\expandafter\BitSet@Kill + \csname BS@#2\expandafter\endcsname\expandafter\BitSet@Empty + \expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral#1000!% + }% + \else + \expandafter\BitSet@ShiftLeft\BitSet@Gobble#1!{#2}% + \fi +} +\def\BitSet@Kill#1#2=#3#4#5{% + #3#4% + \ifx#5!% + \ifx#1\BitSet@Empty + 0% + \else + #1#2% + \fi + \else + \ifx#1\BitSet@Empty + 0% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@Kill#2=% + \fi + \BitSet@Fi +} +\def\bitsetClear{% + \BitSet@CheckIndex\BitSet@Clear +} +\def\bitsetSet{% + \BitSet@CheckIndex\BitSet@Set +} +\def\bitsetFlip{% + \BitSet@CheckIndex\BitSet@Flip +} +\def\bitsetSetValue#1#2#3{% + \expandafter\expandafter\expandafter\BitSet@SetValue + \intcalcNum{#3}!{#1}{#2}% +} +\def\BitSet@SetValue#1!{% + \BitSet@CheckIndex{% + \ifcase#1 % + \expandafter\BitSet@Clear + \or + \expandafter\BitSet@Set + \else + \BitSet@ErrorInvalidBitValue{#1}% + \expandafter\expandafter\expandafter\BitSet@Gobble + \expandafter\BitSet@Gobble + \fi + }% +} +\def\BitSet@ErrorInvalidBitValue#1{% + \@PackageError{bitset}{% + Invalid bit value (#1) not in range 0..1% + }\@ehc +} +\def\BitSet@Clear#1#2{% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@@Clear + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=\expandafter!% + \romannumeral#2000!% + }% + \expandafter\let\csname BS@#1\expandafter\endcsname + \ifx\BitSet@Temp\BitSet@Empty + \BitSet@Zero + \else + \BitSet@Temp + \fi +} +\def\BitSet@@Clear#1#2=#3!#4{% + \ifx#4!% + \ifx#1\BitSet@Empty + \else + \ifx\BitSet@Empty#2% + \else + #30#2% + \fi + \fi + \else + \ifx#1\BitSet@Empty + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \ifx#10% + \BitSet@AfterFiFiFi{% + \BitSet@@Clear#2=#30!% + }% + \else + #31% + \BitSet@AfterFiFiFi{% + \BitSet@@Clear#2=!% + }% + \fi + \fi + \BitSet@Fi +} +\def\BitSet@Set#1#2{% + \expandafter\edef\csname BS@#1\endcsname{% + \expandafter\expandafter\expandafter\BitSet@@Set + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral#2000!% + }% +} +\def\BitSet@@Set#1#2=#3#4#5{% + #3#4% + \ifx#5!% + 1#2% + \else + \ifx#1\BitSet@Empty + 0% + \BitSet@AfterFiFi\BitSet@@@Set + \else + #1% + \BitSet@@Set#2=% + \fi + \BitSet@Fi +} +\def\BitSet@@@Set#1{% + \ifx#1!% + 1% + \else + 0% + \expandafter\BitSet@@@Set + \fi +} +\def\BitSet@Flip#1#2{% + \edef\BitSet@Temp{% + \expandafter\expandafter\expandafter\BitSet@@Flip + \csname BS@#1\expandafter\endcsname + \expandafter\BitSet@Empty\expandafter=\expandafter!% + \romannumeral#2000!% + }% + \expandafter\let\csname BS@#1\expandafter\endcsname + \ifx\BitSet@Temp\BitSet@Empty + \BitSet@Zero + \else + \BitSet@Temp + \fi +} +\def\BitSet@@Flip#1#2=#3!#4{% + \ifx#4!% + \ifx#11% + \ifx\BitSet@Empty#2% + \else + #30#2% + \fi + \else + #31#2% + \fi + \else + \ifx#1\BitSet@Empty + #30% + \BitSet@AfterFiFi\BitSet@@@Set + \else + \ifx#10% + \BitSet@AfterFiFiFi{% + \BitSet@@Flip#2=#30!% + }% + \else + #31% + \BitSet@AfterFiFiFi{% + \BitSet@@Flip#2=!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetClearRange{% + \BitSet@Range\BitSet@Clear +} +\def\bitsetSetRange{% + \BitSet@Range\BitSet@Set +} +\def\bitsetFlipRange{% + \BitSet@Range\BitSet@Flip +} +\def\bitsetSetValueRange#1#2#3#4{% + \expandafter\expandafter\expandafter\BitSet@SetValueRange + \intcalcNum{#4}!{#1}{#2}{#3}% +} +\def\BitSet@SetValueRange#1!#2#3#4{% + \ifcase#1 % + \BitSet@Range\BitSet@Clear{#2}{#3}{#4}% + \or + \BitSet@Range\BitSet@Set{#2}{#3}{#4}% + \else + \BitSet@ErrorInvalidBitValue{#1}% + \fi +} +\def\BitSet@Range#1#2#3#4{% + \edef\BitSet@Temp{% + \noexpand\BitSet@@Range\noexpand#1{#2}% + \intcalcNum{#3}!\intcalcNum{#4}!% + }% + \BitSet@Temp +} +\def\BitSet@@Range#1#2#3!#4!{% + \ifnum#3<0 % + \BitSet@NegativeIndex#1{#2}#3!#4!0!#4!% + \else + \ifnum#4<0 % + \BitSet@NegativeIndex#1{#2}#3!#4!#3!0!% + \else + \ifcase\intcalcCmp{#3}{#4} % + \or + \@PackageError{bitset}{% + Wrong index numbers in range [#3..#4]\MessageBreak% hash-ok + for clear/set/flip on bit set `#2'.\MessageBreak + The lower index exceeds the upper index.\MessageBreak + Canceling the operation as error recovery% + }\@ehc + \else + \BitSet@@@Range#3!#4!#1{#2}% + \fi + \fi + \fi +} +\def\BitSet@NegativeIndex#1#2#3!#4!#5!#6!{% + \@PackageError{bitset}{% + Negative index in range [#3..#4]\MessageBreak % hash-ok + for \string\bitset + \ifx#1\BitSet@Clear + Clear% + \else + \ifx#1\BitSet@Set + Set% + \else + Flip% + \fi + \fi + Range on bit set `#2'.\MessageBreak + Using [#5..#6] as error recovery% hash-ok + }\@ehc + \BitSet@@Range#1{#2}#5!#6!% +} +\def\BitSet@@@Range#1!#2!#3#4{% + \ifnum#1<#2 % + #3{#4}{#1}% + \BitSet@AfterFi{% + \expandafter\expandafter\expandafter\BitSet@@@Range + \IntCalcInc#1!!#2!#3{#4}% + }% + \BitSet@Fi +} +\def\bitsetGet#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@Get + \intcalcNum{#2}!{#1}% +} +\def\BitSet@Get#1!#2{% + \ifnum#1<0 % + \BitSet@AfterFi{% + 0 \BitSetError:NegativeIndex% + }% + \else + \BitSet@IfUndefined{#2}{0}{% + \expandafter\expandafter\expandafter\BitSet@@Get + \csname BS@#2\expandafter\endcsname + \expandafter!\expandafter=% + \expandafter{\expandafter}\expandafter{\expandafter}% + \romannumeral\intcalcNum{#1}000!% + }% + \expandafter\BitSet@Space + \BitSet@Fi +} +\def\BitSet@@Get#1#2=#3#4#5{% + #3#4% + \ifx#5!% + \ifx#1!% + 0% + \else + #1% + \fi + \else + \ifx#1!% + 0% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@@Get#2=% + \fi + \BitSet@Fi +} +\def\bitsetNextClearBit#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@NextClearBit + \intcalcNum{#2}!{#1} % +} +\def\BitSet@NextClearBit#1!#2{% + \ifnum#1<0 % + \BitSet@NextClearBit0!{#2}% + \BitSet@AfterFi{% + \expandafter\BitSet@Space + \expandafter\BitSetError:NegativeIndex\romannumeral0% + }% + \else + \bitsetIsEmpty{#2}{#1}{% + \expandafter\BitSet@Skip + \number#1\expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!!!!!!!!=% + {\BitSet@@NextClearBit#1!}% + }% + \BitSet@Fi +} +\def\BitSet@@NextClearBit#1!#2{% + \ifx#2!% + #1% + \else + \ifx#20% + #1% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@NextClearBit + \IntCalcInc#1!!% + }% + \fi + \BitSet@Fi +} +\def\bitsetNextSetBit#1#2{% + \number + \expandafter\expandafter\expandafter\BitSet@NextSetBit + \intcalcNum{#2}!{#1} % +} +\def\BitSet@NextSetBit#1!#2{% + \ifnum#1<0 % + \BitSet@NextSetBit0!{#2}% + \BitSet@AfterFi{% + \expandafter\BitSet@Space + \expandafter\BitSetError:NegativeIndex\romannumeral0% + }% + \else + \bitsetIsEmpty{#2}{-1}{% + \expandafter\BitSet@Skip + \number#1\expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!!!!!!!!!=% + {\BitSet@@NextSetBit#1!}% + }% + \BitSet@Fi +} +\def\BitSet@@NextSetBit#1!#2{% + \ifx#2!% + -1% + \else + \ifx#21% + #1% + \BitSet@AfterFiFi\BitSet@Cleanup + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@@NextSetBit + \IntCalcInc#1!!% + }% + \fi + \BitSet@Fi +} +\def\BitSet@Cleanup#1!{} +\def\BitSet@Skip#1!#2{% + \ifx#2!% + \BitSet@AfterFi{% + \BitSet@SkipContinue% + }% + \else + \ifcase#1 % + \BitSet@AfterFiFi{% + \BitSet@SkipContinue#2% + }% + \or + \BitSet@AfterFiFi\BitSet@SkipContinue + \or + \BitSet@AfterFiFi{% + \expandafter\BitSet@SkipContinue\BitSet@Gobble + }% + \else + \ifnum#1>8 % + \BitSet@AfterFiFiFi{% + \expandafter\BitSet@Skip + \number\IntCalcSub#1!8!\expandafter!% + \BitSet@GobbleSeven + }% + \else + \BitSet@AfterFiFiFi{% + \expandafter\expandafter\expandafter\BitSet@Skip + \IntCalcDec#1!!% + }% + \fi + \fi + \BitSet@Fi +} +\def\BitSet@SkipContinue#1!#2=#3{% + #3#1!% +} +\def\BitSet@GobbleSeven#1#2#3#4#5#6#7{} +\def\bitsetGetSetBitList#1{% + \romannumeral0% + \bitsetIsEmpty{#1}{ }{% + \expandafter\BitSet@GetSetBitList + \number\BitSet@NextSetBit0!{#1}!{#1}{}!% + }% +} +\def\BitSet@GetSetBitList#1!#2#3#4!{% + \ifnum#1<0 % + \BitSet@AfterFi{ #4}% + \else + \BitSet@AfterFi{% + \expandafter\BitSet@GetSetBitList\number + \expandafter\expandafter\expandafter\BitSet@NextSetBit + \IntCalcInc#1!!{#2}!{#2},#4#3#1!% + }% + \BitSet@Fi +} +\def\bitsetSize#1{% + \number + \BitSet@IfUndefined{#1}{0 }{% + \expandafter\expandafter\expandafter\BitSet@Size + \expandafter\expandafter\expandafter1% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname!0!% + }% +} +\def\BitSet@Size#1!#2#3!#4!{% + \ifx#21% + \ifx\\#3\\% + \BitSet@AfterFiFi{#1 }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Size + \IntCalcInc#1!!#3!#1!% + }% + \fi + \else + \ifx\\#3\\% + \BitSet@AfterFiFi{#4 }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Size + \IntCalcInc#1!!#3!#4!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetCardinality#1{% + \number + \BitSet@IfUndefined{#1}{0 }{% + \expandafter\expandafter\expandafter\BitSet@Cardinality + \expandafter\expandafter\expandafter0% + \expandafter\expandafter\expandafter!% + \csname BS@#1\endcsname!% + }% +} +\def\BitSet@Cardinality#1!#2#3!{% + \ifx#21% + \ifx\\#3\\% + \BitSet@AfterFiFi{\IntCalcInc#1! }% + \else + \BitSet@AfterFiFi{% + \expandafter\expandafter\expandafter\BitSet@Cardinality + \IntCalcInc#1!!#3!% + }% + \fi + \else + \ifx\\#3\\% + \BitSet@AfterFiFi{#1 }% + \else + \BitSet@AfterFiFi{% + \BitSet@Cardinality#1!#3!% + }% + \fi + \fi + \BitSet@Fi +} +\def\bitsetIsDefined#1{% + \BitSet@IfUndefined{#1}% + \BitSet@SecondOfTwo + \BitSet@FirstOfTwo +} +\def\bitsetIsEmpty#1{% + \BitSet@IfUndefined{#1}\BitSet@FirstOfTwo{% + \expandafter\ifx\csname BS@#1\endcsname\BitSet@Zero + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi + }% +} +\def\BitSet@Zero{0} +\def\bitsetQuery#1#2{% + \ifnum\bitsetGet{#1}{#2}=1 % + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi +} +\def\bitsetEquals#1#2{% + \BitSet@IfUndefined{#1}{% + \BitSet@IfUndefined{#2}\BitSet@FirstOfTwo\BitSet@SecondOfTwo + }{% + \BitSet@IfUndefined{#2}\BitSet@SecondOfTwo{% + \expandafter\ifx\csname BS@#1\expandafter\endcsname + \csname BS@#2\endcsname + \expandafter\BitSet@FirstOfTwo + \else + \expandafter\BitSet@SecondOfTwo + \fi + }% + }% +} +\def\bitsetIntersects#1#2{% + \bitsetIsEmpty{#1}\BitSet@SecondOfTwo{% + \bitsetIsEmpty{#2}\BitSet@SecondOfTwo{% + \expandafter\expandafter\expandafter\BitSet@Intersects + \csname BS@#1\expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter\expandafter!% + \csname BS@#2\endcsname!% + }% + }% +} +\def\BitSet@Intersects#1#2!#3#4!{% + \ifnum#1#3=11 % + \BitSet@AfterFi\BitSet@FirstOfTwo + \else + \ifx\\#2\\% + \BitSet@AfterFiFi\BitSet@SecondOfTwo + \else + \ifx\\#4\\% + \BitSet@AfterFiFiFi\BitSet@SecondOfTwo + \else + \BitSet@AfterFiFiFi{% + \BitSet@Intersects#2!#4!% + }% + \fi + \fi + \BitSet@Fi +} +\BitSet@AtEnd +\endinput +%% +%% End of file `bitset.sty'. diff --git a/Master/texmf-dist/tex/generic/oberdiek/engord.sty b/Master/texmf-dist/tex/generic/oberdiek/engord.sty index 57d5b2c2c99..334a7c4bc17 100644 --- a/Master/texmf-dist/tex/generic/oberdiek/engord.sty +++ b/Master/texmf-dist/tex/generic/oberdiek/engord.sty @@ -80,7 +80,7 @@ \fi \expandafter\x\csname ver@engord.sty\endcsname \ProvidesPackage{engord}% - [2007/09/09 v1.5 Provides the ifpdf switch (HO)] + [2007/09/20 v1.6 Provides English ordinal numbers (HO)] \expandafter\edef\csname EO@AtEnd\endcsname{% \catcode64 \the\catcode64\relax } diff --git a/Master/texmf-dist/tex/generic/oberdiek/intcalc.sty b/Master/texmf-dist/tex/generic/oberdiek/intcalc.sty index e92da6bba91..8e1e5d1e860 100644 --- a/Master/texmf-dist/tex/generic/oberdiek/intcalc.sty +++ b/Master/texmf-dist/tex/generic/oberdiek/intcalc.sty @@ -80,14 +80,14 @@ \fi \expandafter\x\csname ver@intcalc.sty\endcsname \ProvidesPackage{intcalc}% - [2007/09/09 v1.0 Expandable integer calculations (HO)] -\expandafter\edef\csname IntCalc@AtEnd\endcsname{% + [2007/09/27 v1.1 Expandable integer calculations (HO)] +\expandafter\edef\csname InCa@AtEnd\endcsname{% \catcode64 \the\catcode64\relax } \catcode64 11 % @ \def\TMP@EnsureCode#1#2{% - \edef\IntCalc@AtEnd{% - \IntCalc@AtEnd + \edef\InCa@AtEnd{% + \InCa@AtEnd \catcode#1 \the\catcode#1\relax }% \catcode#1 #2\relax @@ -105,20 +105,19 @@ \TMP@EnsureCode{62}{12}% > \TMP@EnsureCode{63}{14}% ? (comment!) \begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname IntCalc@TestMode\endcsname\relax +\expandafter\ifx\csname InCa@TestMode\endcsname\relax \else \catcode63=9 % ? (ignore) \fi -? \let\IntCalc@@TestMode\IntCalc@TestMode -\def\IntCalc@Space{ } -\def\IntCalc@Abs#1#2!{% +? \let\InCa@@TestMode\InCa@TestMode +\def\InCa@Abs#1#2!{% \ifx#1-% #2% \else #1#2% \fi } -\def\IntCalc@Sgn#1#2!{% +\def\InCa@Sgn#1#2!{% \ifx#1-% -1% \else @@ -129,21 +128,21 @@ \fi \fi } -\def\IntCalc@Min#1!#2!{% +\def\InCa@Min#1!#2!{% \ifnum#1<#2 % #1% \else #2% \fi } -\def\IntCalc@Max#1!#2!{% +\def\InCa@Max#1!#2!{% \ifnum#1>#2 % #1% \else #2% \fi } -\def\IntCalc@Cmp#1!#2!{% +\def\InCa@Cmp#1!#2!{% \ifnum#1=#2 % 0% \else @@ -153,7 +152,7 @@ 1% \fi } -\def\IntCalc@Fac#1!{% +\def\InCa@Fac#1!{% \ifcase#1 1% 0! \or 1% 1! \or 2% 2! @@ -178,27 +177,30 @@ \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname numexpr\endcsname\relax \else + \def\intcalcNum#1{% + \the\numexpr#1\relax + }% \def\intcalcInv#1{% - \number-\the\numexpr#1\relax\IntCalc@Space + \number-\intcalcNum{#1} % }% \def\intcalcAbs#1{% - \number\expandafter\IntCalc@Abs\the\numexpr#1! % + \number\expandafter\InCa@Abs\the\numexpr#1! % }% \def\intcalcSgn#1{% - \number\expandafter\IntCalc@Sgn\the\numexpr#1! % + \number\expandafter\InCa@Sgn\the\numexpr#1! % }% \def\intcalcMin#1#2{% - \number\expandafter\IntCalc@Min + \number\expandafter\InCa@Min \the\numexpr#1\expandafter!% \the\numexpr#2! % }% \def\intcalcMax#1#2{% - \number\expandafter\IntCalc@Max + \number\expandafter\InCa@Max \the\numexpr#1\expandafter!% \the\numexpr#2! % }% \def\intcalcCmp#1#2{% - \number\expandafter\IntCalc@Cmp + \number\expandafter\InCa@Cmp \the\numexpr#1\expandafter!\the\numexpr#2! % }% \def\intcalcInc#1{% @@ -207,28 +209,40 @@ \def\intcalcDec#1{% \the\numexpr#1-1\relax }% + \def\IntCalcInc#1!{% + \the\numexpr#1+1\relax + }% + \def\IntCalcDec#1!{% + \the\numexpr#1-1\relax + }% \def\intcalcAdd#1#2{% \the\numexpr#1+(#2)\relax }% \def\intcalcSub#1#2{% \the\numexpr#1-(#2)\relax }% - \def\intcalcShl#1{% - \number\expandafter\IntCalc@Shl\the\numexpr#1! % + + \def\IntCalcAdd#1!#2!{% + \the\numexpr#1+#2\relax }% - \def\IntCalc@Shl#1#2!{% - \ifx#1-% - 0\IntCalcError:ShlNegativeNumber% - \else - \the\numexpr#1#2*2\relax - \fi + \def\IntCalcSub#1!#2!{% + \the\numexpr#1-#2\relax + }% + \def\intcalcShl#1{% + \the\numexpr(#1)*2\relax }% \def\intcalcShr#1{% - \number\expandafter\IntCalc@Shr\the\numexpr#1! % + \number\expandafter\InCa@Shr\the\numexpr#1! % + }% + \def\IntCalcShl#1!{% + \the\numexpr#1*2\relax + }% + \def\IntCalcShr#1!{% + \the\numexpr\ifodd#1 (#1-1)\else#1\fi/2\relax }% - \def\IntCalc@Shr#1#2!{% + \def\InCa@Shr#1#2!{% \ifx#1-% - 0\IntCalcError:ShrNegativeNumber% + -\InCa@Shr#2!% \else \ifodd#1#2 % \the\numexpr(#1#2-1)/2\relax @@ -240,21 +254,24 @@ \def\intcalcMul#1#2{% \the\numexpr(#1)*(#2)\relax }% + \def\IntCalcMul#1!#2!{% + \the\numexpr#1*#2\relax + }% \def\intcalcSqr#1{% - \number\expandafter\IntCalc@Sqr\the\numexpr#1! % + \number\expandafter\InCa@Sqr\the\numexpr#1! % }% - \def\IntCalc@Sqr#1!{% + \def\InCa@Sqr#1!{% \the\numexpr#1*#1\relax }% \def\intcalcFac#1{% - \number\expandafter\IntCalc@Fac\the\numexpr#1! % + \number\expandafter\InCa@Fac\the\numexpr#1! % }% \def\intcalcPow#1#2{% - \number\expandafter\IntCalc@Pow + \number\expandafter\InCa@Pow \the\numexpr#1\expandafter!% \the\numexpr#2! % }% - \def\IntCalc@Pow#1#2!#3#4!{% + \def\InCa@Pow#1#2!#3#4!{% \ifcase#3#4 % power = 0 1% \or % power = 1 @@ -279,23 +296,23 @@ \ifx#3-% power < 0 0% \else % power > 2 - \IntCalc@PowRec#1#2!#3#4!1!% + \InCa@PowRec#1#2!#3#4!1!% \fi \fi \fi \fi }% - \def\IntCalc@PowRec#1!#2!#3!{% + \def\InCa@PowRec#1!#2!#3!{% \ifnum#2=\@ne \the\numexpr#1*#3\relax \else \ifodd#2 % - \expandafter\IntCalc@PowRec + \expandafter\InCa@PowRec \the\numexpr#1*#1\expandafter!% \the\numexpr(#2-1)/2\expandafter!% \the\numexpr#1*#3\expandafter\expandafter\expandafter!% \else - \expandafter\IntCalc@PowRec + \expandafter\InCa@PowRec \the\numexpr#1*#1\expandafter!% \the\numexpr(#2-1)/2\expandafter!% \number#3\expandafter\expandafter\expandafter!% @@ -303,18 +320,18 @@ \fi }% \def\intcalcDiv#1#2{% - \number\expandafter\IntCalc@Div + \number\expandafter\InCa@Div \the\numexpr#1\expandafter!% \the\numexpr#2! % }% - \def\IntCalc@Div#1!#2!{% + \def\InCa@Div#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@@Div + \expandafter\InCa@@Div \romannumeral 0% \ifnum#1<\z@ \expandafter-\number-#1% @@ -332,23 +349,39 @@ \fi \fi }% - \def\IntCalc@@Div#1#2!#3#4!{% + \def\InCa@Temp#1{% + \def\IntCalcDiv##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \the\numexpr(##1-(##2-1)/2)/##2\relax + \fi + \fi + #1% + }% + }% + \InCa@Temp{ }% + \def\InCa@@Div#1#2!#3#4!{% #1#3% \the\numexpr(#2-(#4-1)/2)/#4\relax }% \def\intcalcMod#1#2{% - \number\expandafter\IntCalc@Mod + \number\expandafter\InCa@Mod \the\numexpr#1\expandafter!% \the\numexpr#2! % }% - \def\IntCalc@Mod#1!#2!{% + \def\InCa@Mod#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@@Mod + \expandafter\InCa@@Mod \romannumeral 0% \ifnum#1<\z@ \expandafter-\number-#1% @@ -366,96 +399,121 @@ \fi \fi }% - \def\IntCalc@@Mod#1#2!#3#4!{% + \def\InCa@Temp#1{% + \def\IntCalcMod##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \the\numexpr##1-(##1-(##2-1)/2)/##2*##2\relax + \fi + \fi + #1% + }% + }% + \InCa@Temp{ }% + \def\InCa@@Mod#1#2!#3#4!{% \if#3+% \if#1+% - \the\numexpr#2-\IntCalc@@Div+#2!+#4!*#4\relax + \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax \else - \expandafter\IntCalc@ModX - \the\numexpr-#2+\IntCalc@@Div+#2!+#4!*#4!#4!% + \expandafter\InCa@ModX + \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!% \fi \else -% \if#1+% - \expandafter\IntCalc@ModX - \the\numexpr-#2+\IntCalc@@Div+#2!+#4!*#4!#4!% + \expandafter\InCa@ModX + \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!% \else - \the\numexpr#2-\IntCalc@@Div+#2!+#4!*#4\relax + \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax \fi \fi }% - \def\IntCalc@ModX#1!#2!{% + \def\InCa@ModX#1!#2!{% \ifcase#1 % 0% \else \the\numexpr#1+#2\relax \fi }% - \IntCalc@AtEnd + \InCa@AtEnd \expandafter\endinput \fi +\def\intcalcNum#1{% + \number\expandafter\InCa@FirstOfOne\number#1! % +} \def\intcalcInv#1{% - \number\expandafter\IntCalc@Inv\number-#1! % + \number\expandafter\InCa@FirstOfOne\number-#1! % } -\def\IntCalc@Inv#1!{#1} +\def\InCa@FirstOfOne#1!{#1} \def\intcalcAbs#1{% - \number\expandafter\IntCalc@Abs\number#1! % + \number\expandafter\InCa@Abs\number#1! % } \def\intcalcSgn#1{% - \number\expandafter\IntCalc@Sgn\number#1! % + \number\expandafter\InCa@Sgn\number#1! % } \def\intcalcMin#1#2{% - \number\expandafter\IntCalc@Min + \number\expandafter\InCa@Min \number\number#1\expandafter!\number#2! % } \def\intcalcMax#1#2{% - \number\expandafter\IntCalc@Max + \number\expandafter\InCa@Max \number\number#1\expandafter!\number#2! % } \def\intcalcCmp#1#2{% - \number\expandafter\IntCalc@Cmp + \number\expandafter\InCa@Cmp \number\number#1\expandafter!\number#2! % }% \def\intcalcInc#1{% - \number\expandafter\IntCalc@IncSwitch\number#1! % + \number\expandafter\InCa@IncSwitch\number#1! % } -\def\IntCalc@IncSwitch#1#2!{% +\def\InCa@IncSwitch#1#2!{% \ifx#1-% -% - \csname IntCalc@Empty% - \IntCalc@Dec#2!% + \csname InCa@Empty% + \InCa@Dec#2!% \else - \csname IntCalc@Empty% - \IntCalc@Inc#1#2!% + \csname InCa@Empty% + \InCa@Inc#1#2!% \fi } \def\intcalcDec#1{% - \number\expandafter\IntCalc@DecSwitch\number#1! % + \number\expandafter\InCa@DecSwitch\number#1! % } -\def\IntCalc@DecSwitch#1#2!{% +\def\InCa@DecSwitch#1#2!{% \ifx#1-% -% - \csname IntCalc@Empty% - \expandafter\IntCalc@Inc#2!% + \csname InCa@Empty% + \expandafter\InCa@Inc#2!% \else \ifx#10% -1% \else - \csname IntCalc@Empty% - \IntCalc@Dec#1#2!% + \csname InCa@Empty% + \InCa@Dec#1#2!% \fi \fi } -\def\IntCalc@Inc#1#2{% +\def\IntCalcInc#1!{% + \number\csname InCa@Empty\InCa@Inc#1! % +} +\def\IntCalcDec#1!{% + \number\csname InCa@Empty\InCa@Dec#1! % +} +\def\InCa@Inc#1#2{% \ifx#2!% - \csname IntCalc@IncDigit#1\endcsname1% + \csname InCa@IncDigit#1\endcsname1% \else - \csname IntCalc@IncDigit#1% - \expandafter\IntCalc@Inc\expandafter#2% + \csname InCa@IncDigit#1% + \expandafter\InCa@Inc\expandafter#2% \fi } -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@IncDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@IncDigit#1\endcsname##1{% \endcsname 0% \ifcase##1 % @@ -465,16 +523,16 @@ \fi }% } -\IntCalc@Temp 01 -\IntCalc@Temp 12 -\IntCalc@Temp 23 -\IntCalc@Temp 34 -\IntCalc@Temp 45 -\IntCalc@Temp 56 -\IntCalc@Temp 67 -\IntCalc@Temp 78 -\IntCalc@Temp 89 -\expandafter\def\csname IntCalc@IncDigit9\endcsname#1{% +\InCa@Temp 01 +\InCa@Temp 12 +\InCa@Temp 23 +\InCa@Temp 34 +\InCa@Temp 45 +\InCa@Temp 56 +\InCa@Temp 67 +\InCa@Temp 78 +\InCa@Temp 89 +\expandafter\def\csname InCa@IncDigit9\endcsname#1{% \expandafter\endcsname \ifcase#1 % 09% @@ -482,16 +540,16 @@ 10% \fi } -\def\IntCalc@Dec#1#2{% +\def\InCa@Dec#1#2{% \ifx#2!% - \csname IntCalc@DecDigit#1\endcsname1% + \csname InCa@DecDigit#1\endcsname1% \else - \csname IntCalc@DecDigit#1% - \expandafter\IntCalc@Dec\expandafter#2% + \csname InCa@DecDigit#1% + \expandafter\InCa@Dec\expandafter#2% \fi } -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@DecDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@DecDigit#1\endcsname##1{% \endcsname 0% \ifcase##1 % @@ -501,16 +559,16 @@ \fi }% } -\IntCalc@Temp 98 -\IntCalc@Temp 87 -\IntCalc@Temp 76 -\IntCalc@Temp 65 -\IntCalc@Temp 54 -\IntCalc@Temp 43 -\IntCalc@Temp 32 -\IntCalc@Temp 21 -\IntCalc@Temp 10 -\expandafter\def\csname IntCalc@DecDigit0\endcsname#1{% +\InCa@Temp 98 +\InCa@Temp 87 +\InCa@Temp 76 +\InCa@Temp 65 +\InCa@Temp 54 +\InCa@Temp 43 +\InCa@Temp 32 +\InCa@Temp 21 +\InCa@Temp 10 +\expandafter\def\csname InCa@DecDigit0\endcsname#1{% \expandafter\endcsname \ifcase#1 % 00% @@ -520,140 +578,149 @@ } \def\intcalcAdd#1#2{% \number - \expandafter\IntCalc@AddSwitch + \expandafter\InCa@AddSwitch \number\number#1\expandafter!% - \number#2!% - \IntCalc@Space + \number#2! % } \def\intcalcSub#1#2{% \number - \expandafter\IntCalc@AddSwitch + \expandafter\InCa@AddSwitch \number\number#1\expandafter!% - \number-\number#2!% - \IntCalc@Space + \number-\number#2! % } -\def\IntCalc@AddSwitch#1!#2!{% +\def\InCa@AddSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ -% \ifnum#1<#2 % - \expandafter\IntCalc@Add\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Add\number-#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Add\number-#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Add\number-#2\expandafter!% + \@gobble#1!% \fi \else \ifnum-#1>#2 % -% - \expandafter\IntCalc@Sub\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Sub\@gobble#1!#2!% \else - \expandafter\IntCalc@Sub\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Sub\number#2\expandafter!% + \@gobble#1!% \fi \fi \else \ifnum#2<\z@ \ifnum#1>-#2 % - \expandafter\IntCalc@Sub\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Sub\number#1\expandafter!% + \@gobble#2!% \else -% - \expandafter\IntCalc@Sub\IntCalc@Gobble#2!#1!% + \expandafter\InCa@Sub\@gobble#2!#1!% \fi \else \ifnum#1>#2 % - \IntCalc@Add#1!#2!% + \InCa@Add#1!#2!% \else - \IntCalc@Add#2!#1!% + \InCa@Add#2!#1!% \fi \fi \fi } -\def\IntCalc@Add#1!#2!{% +\def\IntCalcAdd#1!#2!{% + \number\InCa@Add#1!#2! % +} +\def\IntCalcSub#1!#2!{% + \number\InCa@Sub#1!#2! % +} +\begingroup + \def\x#1{\endgroup + \let\InCa@Space= #1% + }% +\x{ } +\def\InCa@Add#1!#2!{% \ifcase#2 % #1% \else - \IntCalc@@Add#1!#2!000000000\IntCalc@Space + \InCa@@Add#1!#2!000000000\InCa@Space \fi } -\def\IntCalc@Sub#1!#2!{% +\def\InCa@Sub#1!#2!{% \ifnum#1=#2 % 0% \else - \IntCalc@@Sub#1!#2!000000000\IntCalc@Space + \InCa@@Sub#1!#2!000000000\InCa@Space \fi } -\def\IntCalc@@Add#1!#2#3!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty +\def\InCa@@Add#1!#2#3!{% + \ifx\InCa@Empty#3\InCa@Empty \@ReturnAfterElseFi{% - \IntCalc@@@Add!!#1!#2% + \InCa@@@Add!!#1!#2% }% \else \@ReturnAfterFi{% - \IntCalc@@Add#1!#3!#2% + \InCa@@Add#1!#3!#2% }% \fi } -\def\IntCalc@@Sub#1!#2#3!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty +\def\InCa@@Sub#1!#2#3!{% + \ifx\InCa@Empty#3\InCa@Empty \@ReturnAfterElseFi{% - \IntCalc@@@Sub!!#1!#2% + \InCa@@@Sub!!#1!#2% }% \else \@ReturnAfterFi{% - \IntCalc@@Sub#1!#3!#2% + \InCa@@Sub#1!#3!#2% }% \fi } -\def\IntCalc@@@Add#1!#2!#3#4!#5{% - \ifx\IntCalc@Empty#4\IntCalc@Empty - \csname IntCalc@Empty% +\def\InCa@@@Add#1!#2!#3#4!#5{% + \ifx\InCa@Empty#4\InCa@Empty + \csname InCa@Empty% \@ReturnAfterElseFi{% - \IntCalc@ProcessAdd#1#3!#5#2% + \InCa@ProcessAdd#1#3!#5#2% }% \else \@ReturnAfterFi{% - \IntCalc@@@Add#1#3!#5#2!#4!% + \InCa@@@Add#1#3!#5#2!#4!% }% \fi } -\def\IntCalc@@@Sub#1!#2!#3#4!#5{% - \ifx\IntCalc@Empty#4\IntCalc@Empty - \csname IntCalc@Gobble% +\def\InCa@@@Sub#1!#2!#3#4!#5{% + \ifx\InCa@Empty#4\InCa@Empty + \csname @gobble% \@ReturnAfterElseFi{% - \IntCalc@ProcessSub#1#3!#5#2% + \InCa@ProcessSub#1#3!#5#2% }% \else \@ReturnAfterFi{% - \IntCalc@@@Sub#1#3!#5#2!#4!% + \InCa@@@Sub#1#3!#5#2!#4!% }% \fi } -\def\IntCalc@ProcessAdd#1#2!#3#4{% - \ifx\IntCalc@Empty#2\IntCalc@Empty - \csname IntCalc@AddDigit#1\endcsname#3% +\def\InCa@ProcessAdd#1#2!#3#4{% + \ifx\InCa@Empty#2\InCa@Empty + \csname InCa@AddDigit#1\endcsname#3% \romannumeral0#4% \else - \csname IntCalc@AddDigit#1\csname IntCalc@DigitCarry#3% + \csname InCa@AddDigit#1\csname InCa@DigitCarry#3% \@ReturnAfterFi{% - \IntCalc@ProcessAdd#2!#4% + \InCa@ProcessAdd#2!#4% }% \fi } -\def\IntCalc@ProcessSub#1#2!#3#4{% - \ifx\IntCalc@Empty#2\IntCalc@Empty - \csname IntCalc@SubDigit#1\endcsname#3% +\def\InCa@ProcessSub#1#2!#3#4{% + \ifx\InCa@Empty#2\InCa@Empty + \csname InCa@SubDigit#1\endcsname#3% \romannumeral0#4% \else - \csname IntCalc@SubDigit#1\csname IntCalc@DigitCarry#3% + \csname InCa@SubDigit#1\csname InCa@DigitCarry#3% \@ReturnAfterFi{% - \IntCalc@ProcessSub#2!#4% + \InCa@ProcessSub#2!#4% }% \fi } -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@DigitCarry#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@DigitCarry#1\endcsname##1{% \ifcase##1 % \endcsname#1% \else @@ -661,25 +728,25 @@ \fi }% } -\IntCalc@Temp 01 -\IntCalc@Temp 12 -\IntCalc@Temp 23 -\IntCalc@Temp 34 -\IntCalc@Temp 45 -\IntCalc@Temp 56 -\IntCalc@Temp 67 -\IntCalc@Temp 78 -\IntCalc@Temp 89 -\IntCalc@Temp 9{{10}} -\expandafter\def\csname IntCalc@AddDigit0\endcsname#1{% +\InCa@Temp 01 +\InCa@Temp 12 +\InCa@Temp 23 +\InCa@Temp 34 +\InCa@Temp 45 +\InCa@Temp 56 +\InCa@Temp 67 +\InCa@Temp 78 +\InCa@Temp 89 +\InCa@Temp 9{{10}} +\expandafter\def\csname InCa@AddDigit0\endcsname#1{% \ifnum#1>9 % \endcsname10% \else \endcsname0#1% \fi } -\def\IntCalc@Temp#1#2#3{% - \expandafter\def\csname IntCalc@AddDigit#1\endcsname##1{% +\def\InCa@Temp#1#2#3{% + \expandafter\def\csname InCa@AddDigit#1\endcsname##1{% \ifnum##1>#2 % \endcsname 1% \else @@ -691,7 +758,7 @@ \fi }% } -\IntCalc@Temp 18{% +\InCa@Temp 18{% \or 2% 1 \or 3% 2 \or 4% 3 @@ -702,7 +769,7 @@ \or 9% 8 \or 0% 9 }% -\IntCalc@Temp 27{% +\InCa@Temp 27{% \or 3% 1 \or 4% 2 \or 5% 3 @@ -713,7 +780,7 @@ \or 0% 8 \or 1% 9 }% -\IntCalc@Temp 36{% +\InCa@Temp 36{% \or 4% 1 \or 5% 2 \or 6% 3 @@ -724,7 +791,7 @@ \or 1% 8 \or 2% 9 }% -\IntCalc@Temp 45{% +\InCa@Temp 45{% \or 5% 1 \or 6% 2 \or 7% 3 @@ -735,7 +802,7 @@ \or 2% 8 \or 3% 9 }% -\IntCalc@Temp 54{% +\InCa@Temp 54{% \or 6% 1 \or 7% 2 \or 8% 3 @@ -746,7 +813,7 @@ \or 3% 8 \or 4% 9 }% -\IntCalc@Temp 63{% +\InCa@Temp 63{% \or 7% 1 \or 8% 2 \or 9% 3 @@ -757,7 +824,7 @@ \or 4% 8 \or 5% 9 }% -\IntCalc@Temp 72{% +\InCa@Temp 72{% \or 8% 1 \or 9% 2 \or 0% 3 @@ -768,7 +835,7 @@ \or 5% 8 \or 6% 9 }% -\IntCalc@Temp 81{% +\InCa@Temp 81{% \or 9% 1 \or 0% 2 \or 1% 3 @@ -779,7 +846,7 @@ \or 6% 8 \or 7% 9 }% -\IntCalc@Temp 90{% +\InCa@Temp 90{% \or 0% 1 \or 1% 2 \or 2% 3 @@ -790,8 +857,8 @@ \or 7% 8 \or 8% 9 }% -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@SubDigit#1\endcsname##1{% +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@SubDigit#1\endcsname##1{% \ifnum##1>#1 % \endcsname 1% \else @@ -803,7 +870,7 @@ \fi }% } -\IntCalc@Temp 0{% +\InCa@Temp 0{% \or 9% 1 \or 8% 2 \or 7% 3 @@ -814,7 +881,7 @@ \or 2% 8 \or 1% 9 } -\IntCalc@Temp 1{% +\InCa@Temp 1{% \or 0% 1 \or 9% 2 \or 8% 3 @@ -825,7 +892,7 @@ \or 3% 8 \or 2% 9 } -\IntCalc@Temp 2{% +\InCa@Temp 2{% \or 1% 1 \or 0% 2 \or 9% 3 @@ -836,7 +903,7 @@ \or 4% 8 \or 3% 9 } -\IntCalc@Temp 3{% +\InCa@Temp 3{% \or 2% 1 \or 1% 2 \or 0% 3 @@ -847,7 +914,7 @@ \or 5% 8 \or 4% 9 } -\IntCalc@Temp 4{% +\InCa@Temp 4{% \or 3% 1 \or 2% 2 \or 1% 3 @@ -858,7 +925,7 @@ \or 6% 8 \or 5% 9 } -\IntCalc@Temp 5{% +\InCa@Temp 5{% \or 4% 1 \or 3% 2 \or 2% 3 @@ -869,7 +936,7 @@ \or 7% 8 \or 6% 9 } -\IntCalc@Temp 6{% +\InCa@Temp 6{% \or 5% 1 \or 4% 2 \or 3% 3 @@ -880,7 +947,7 @@ \or 8% 8 \or 7% 9 } -\IntCalc@Temp 7{% +\InCa@Temp 7{% \or 6% 1 \or 5% 2 \or 4% 3 @@ -891,7 +958,7 @@ \or 9% 8 \or 8% 9 } -\IntCalc@Temp 8{% +\InCa@Temp 8{% \or 7% 1 \or 6% 2 \or 5% 3 @@ -902,7 +969,7 @@ \or 0% 8 \or 9% 9 } -\IntCalc@Temp 9{% +\InCa@Temp 9{% \or 8% 1 \or 7% 2 \or 6% 3 @@ -914,31 +981,37 @@ \or 0% 9 } \def\intcalcShl#1{% - \number\expandafter\IntCalc@ShlSwitch\number#1! % + \number\expandafter\InCa@ShlSwitch\number#1! % } -\def\IntCalc@ShlSwitch#1!{% - \ifnum#1<\z@ - 0\IntCalcError:ShlNegativeNumber% +\def\InCa@ShlSwitch#1#2!{% + \ifx#1-% + -\csname InCa@Empty% + \InCa@Shl#2!% \else - \csname IntCalc@Empty% - \IntCalc@Shl#1!% + \csname InCa@Empty% + \InCa@Shl#1#2!% \fi } -\def\IntCalc@Shl#1#2{% +\def\IntCalcShl#1!{% + \number + \csname InCa@Empty% + \InCa@Shl#1! % +} +\def\InCa@Shl#1#2{% \ifx#2!% - \csname IntCalc@ShlDigit#1\endcsname0% + \csname InCa@ShlDigit#1\endcsname0% \else - \csname IntCalc@ShlDigit#1% + \csname InCa@ShlDigit#1% \@ReturnAfterFi{% - \IntCalc@Shl#2% + \InCa@Shl#2% }% \fi } -\expandafter\def\csname IntCalc@ShlDigit0\endcsname{% +\expandafter\def\csname InCa@ShlDigit0\endcsname{% \endcsname0% } -\def\IntCalc@Temp#1#2#3#4#5{% - \expandafter\def\csname IntCalc@ShlDigit#1\endcsname##1{% +\def\InCa@Temp#1#2#3#4#5{% + \expandafter\def\csname InCa@ShlDigit#1\endcsname##1{% \expandafter\endcsname \ifcase##1 % #2#3% @@ -947,41 +1020,44 @@ \fi }% } -\IntCalc@Temp 10203 -\IntCalc@Temp 20405 -\IntCalc@Temp 30607 -\IntCalc@Temp 40809 -\IntCalc@Temp 51011 -\IntCalc@Temp 61213 -\IntCalc@Temp 71415 -\IntCalc@Temp 81617 -\IntCalc@Temp 91819 +\InCa@Temp 10203 +\InCa@Temp 20405 +\InCa@Temp 30607 +\InCa@Temp 40809 +\InCa@Temp 51011 +\InCa@Temp 61213 +\InCa@Temp 71415 +\InCa@Temp 81617 +\InCa@Temp 91819 \def\intcalcShr#1{% - \number\expandafter\IntCalc@ShrSwitch\number#1! % + \number\expandafter\InCa@ShrSwitch\number#1! % } -\def\IntCalc@ShrSwitch#1!{% - \ifnum#1<\z@ - 0\IntCalcError:ShrNegativeNumber% +\def\InCa@ShrSwitch#1#2!{% + \ifx#1-% + -\InCa@Shr#2!% \else - \IntCalc@Shr#1!% + \InCa@Shr#1#2!% \fi } -\def\IntCalc@Shr#1#2{% - \IntCalc@ShrDigit#1!% +\def\IntCalcShr#1!{% + \number\InCa@Shr#1! % +} +\def\InCa@Shr#1#2{% + \InCa@ShrDigit#1!% \ifx#2!% \else \@ReturnAfterFi{% \ifodd#1 % \@ReturnAfterElseFi{% - \IntCalc@Shr{1#2}% + \InCa@Shr{1#2}% }% \else - \expandafter\IntCalc@Shr\expandafter#2% + \expandafter\InCa@Shr\expandafter#2% \fi }% \fi } -\def\IntCalc@ShrDigit#1!{% +\def\InCa@ShrDigit#1!{% \ifcase#1 0% 0 \or 0% 1 \or 1% 2 @@ -1004,57 +1080,60 @@ \or 9% 19 \fi } -\def\IntCalc@Tim#1#2{% - \number - \ifcase#2 % 0 - 0% - \or % 1 - #1% - \else % 2-9 - \csname IntCalc@Empty% - \IntCalc@ProcessTim#2#1!% - \fi - \IntCalc@Space +\def\InCa@Temp#1{% + \def\InCa@Tim##1##2{% + \number + \ifcase##2 % 0 + 0% + \or % 1 + ##1% + \else % 2-9 + \csname InCa@Empty% + \InCa@ProcessTim##2##1!% + \fi + #1% + }% } -\def\IntCalc@ProcessTim#1#2#3{% +\InCa@Temp{ } +\def\InCa@ProcessTim#1#2#3{% \ifx#3!% - \csname IntCalc@TimDigit#2\endcsname#10% + \csname InCa@TimDigit#2\endcsname#10% \else - \csname IntCalc@TimDigit#2\csname IntCalc@Param#1% + \csname InCa@TimDigit#2\csname InCa@Param#1% \@ReturnAfterFi{% - \IntCalc@ProcessTim#1#3% + \InCa@ProcessTim#1#3% }% \fi } -\def\IntCalc@Temp#1{% - \expandafter\def\csname IntCalc@Param#1\endcsname{% +\def\InCa@Temp#1{% + \expandafter\def\csname InCa@Param#1\endcsname{% \endcsname#1% }% } -\IntCalc@Temp 0% -\IntCalc@Temp 1% -\IntCalc@Temp 2% -\IntCalc@Temp 3% -\IntCalc@Temp 4% -\IntCalc@Temp 5% -\IntCalc@Temp 6% -\IntCalc@Temp 7% -\IntCalc@Temp 8% -\IntCalc@Temp 9% -\expandafter\def\csname IntCalc@TimDigit0\endcsname#1#2{% +\InCa@Temp 0% +\InCa@Temp 1% +\InCa@Temp 2% +\InCa@Temp 3% +\InCa@Temp 4% +\InCa@Temp 5% +\InCa@Temp 6% +\InCa@Temp 7% +\InCa@Temp 8% +\InCa@Temp 9% +\expandafter\def\csname InCa@TimDigit0\endcsname#1#2{% \endcsname 0#2% } -\expandafter\def\csname IntCalc@TimDigit1\endcsname#1#2{% +\expandafter\def\csname InCa@TimDigit1\endcsname#1#2{% \ifcase#2 % \endcsname 0#1% \else - \csname IntCalc@AddDigit#1\endcsname #2% + \csname InCa@AddDigit#1\endcsname #2% \fi } -\def\IntCalc@Temp#1#2{% - \expandafter\def\csname IntCalc@TimDigit#1\endcsname##1{% - \expandafter\IntCalc@TimDigitCarry +\def\InCa@Temp#1#2{% + \expandafter\def\csname InCa@TimDigit#1\endcsname##1{% + \expandafter\InCa@TimDigitCarry \number \ifcase##1 0% 0 #2% @@ -1062,7 +1141,7 @@ !% }% } -\IntCalc@Temp 2{% +\InCa@Temp 2{% \or 2% 1 \or 4% 2 \or 6% 3 @@ -1073,7 +1152,7 @@ \or 16% 8 \or 18% 9 } -\IntCalc@Temp 3{% +\InCa@Temp 3{% \or 3% 1 \or 6% 2 \or 9% 3 @@ -1084,7 +1163,7 @@ \or 24% 8 \or 27% 9 } -\IntCalc@Temp 4{% +\InCa@Temp 4{% \or 4% 1 \or 8% 2 \or 12% 3 @@ -1095,7 +1174,7 @@ \or 32% 8 \or 36% 9 } -\IntCalc@Temp 5{% +\InCa@Temp 5{% \or 5% 1 \or 10% 2 \or 15% 3 @@ -1106,7 +1185,7 @@ \or 40% 8 \or 45% 9 } -\IntCalc@Temp 6{% +\InCa@Temp 6{% \or 6% 1 \or 12% 2 \or 18% 3 @@ -1117,7 +1196,7 @@ \or 48% 8 \or 54% 9 } -\IntCalc@Temp 7{% +\InCa@Temp 7{% \or 7% 1 \or 14% 2 \or 21% 3 @@ -1128,7 +1207,7 @@ \or 56% 8 \or 63% 9 } -\IntCalc@Temp 8{% +\InCa@Temp 8{% \or 8% 1 \or 16% 2 \or 24% 3 @@ -1139,7 +1218,7 @@ \or 64% 8 \or 72% 9 } -\IntCalc@Temp 9{% +\InCa@Temp 9{% \or 9% 1 \or 18% 2 \or 27% 3 @@ -1150,126 +1229,128 @@ \or 72% 8 \or 81% 9 } -\def\IntCalc@TimDigitCarry#1!{% +\def\InCa@TimDigitCarry#1!{% \ifnum#1<10 % - \csname IntCalc@AddDigit#1\expandafter\endcsname + \csname InCa@AddDigit#1\expandafter\endcsname \else \@ReturnAfterFi{% - \IntCalc@@TimDigitCarry#1!% + \InCa@@TimDigitCarry#1!% }% \fi } -\def\IntCalc@@TimDigitCarry#1#2!#3{% - \csname IntCalc@DigitCarry#1% - \csname IntCalc@AddDigit#2\endcsname #3% +\def\InCa@@TimDigitCarry#1#2!#3{% + \csname InCa@DigitCarry#1% + \csname InCa@AddDigit#2\endcsname #3% } \def\intcalcMul#1#2{% \number - \expandafter\IntCalc@MulSwitch + \expandafter\InCa@MulSwitch \number\number#1\expandafter!% - \number#2!% - \IntCalc@Space + \number#2! % } -\def\IntCalc@MulSwitch#1!#2!{% +\def\InCa@MulSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ \ifnum#1<#2 % - \expandafter\IntCalc@Mul\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Mul\number-#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Mul\number-#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Mul\number-#2\expandafter!% + \@gobble#1!% \fi \else -% \ifnum-#1>#2 % - \expandafter\IntCalc@Mul\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Mul\@gobble#1!#2!% \else - \expandafter\IntCalc@Mul\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Mul\number#2\expandafter!% + \@gobble#1!% \fi \fi \else \ifnum#2<\z@ -% \ifnum#1>-#2 % - \expandafter\IntCalc@Mul\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@Mul\number#1\expandafter!% + \@gobble#2!% \else - \expandafter\IntCalc@Mul\IntCalc@Gobble#2!#1!% + \expandafter\InCa@Mul\@gobble#2!#1!% \fi \else \ifnum#1>#2 % - \IntCalc@Mul#1!#2!% + \InCa@Mul#1!#2!% \else - \IntCalc@Mul#2!#1!% + \InCa@Mul#2!#1!% \fi \fi \fi } -\def\IntCalc@Mul#1!#2!{% +\def\IntCalcMul#1!#2!{% + \number\InCa@Mul#1!#2! % +} +\def\InCa@Mul#1!#2!{% \ifcase#2 % 0% \or #1% \or - \csname IntCalc@Empty% - \expandafter\IntCalc@Shl#1!% + \csname InCa@Empty% + \expandafter\InCa@Shl#1!% \else \ifnum#2<10 % - \IntCalc@Tim{#1}#2% + \InCa@Tim{#1}#2% \else - \IntCalc@ProcessMul!#2!#1!% + \InCa@ProcessMul!#2!#1!% \fi \fi } -\def\IntCalc@ProcessMul#1!#2#3!#4!{% - \ifx\IntCalc@Empty#3\IntCalc@Empty - \expandafter\IntCalc@Add\number +\def\InCa@ProcessMul#1!#2#3!#4!{% + \ifx\InCa@Empty#3\InCa@Empty + \expandafter\InCa@Add\number #10\expandafter\expandafter\expandafter!% - \IntCalc@Tim{#4}#2!% + \InCa@Tim{#4}#2!% \else - \ifx\IntCalc@Empty#1\IntCalc@Empty - \expandafter\expandafter\expandafter\IntCalc@ProcessMul - \IntCalc@Tim{#4}#2!% + \ifx\InCa@Empty#1\InCa@Empty + \expandafter\expandafter\expandafter\InCa@ProcessMul + \InCa@Tim{#4}#2!% #3!#4!% \else - \expandafter\IntCalc@ProcessMul\number - \expandafter\IntCalc@Add\number% + \expandafter\InCa@ProcessMul\number + \expandafter\InCa@Add\number% #10\expandafter\expandafter\expandafter!% - \IntCalc@Tim{#4}#2!!% + \InCa@Tim{#4}#2!!% #3!#4!% \fi \fi } \def\intcalcSqr#1{% - \number\expandafter\IntCalc@Sqr\number#1! % + \number\expandafter\InCa@Sqr\number#1! % } -\def\IntCalc@Sqr#1#2!{% +\def\InCa@Sqr#1#2!{% \ifx#1-% - \IntCalc@Mul#2!#2!% + \InCa@Mul#2!#2!% \else - \IntCalc@Mul#1#2!#1#2!% + \InCa@Mul#1#2!#1#2!% \fi } \def\intcalcFac#1{% - \number\expandafter\IntCalc@Fac\number#1! % + \number\expandafter\InCa@Fac\number#1! % } \def\intcalcPow#1#2{% - \number\expandafter\IntCalc@Pow + \number\expandafter\InCa@Pow \number\number#1\expandafter!% \number#2! % } -\def\IntCalc@Pow#1#2!#3#4!{% +\def\InCa@Pow#1#2!#3#4!{% \ifcase#3#4 % power = 0 1% \or % power = 1 #1#2% \or % power = 2 \ifx#1-% - \IntCalc@Mul#2!#2!% + \InCa@Mul#2!#2!% \else - \IntCalc@Mul#1#2!#1#2!% + \InCa@Mul#1#2!#1#2!% \fi \else \ifcase#1#2 % basis = 0, power <> 0 @@ -1293,32 +1374,32 @@ \ifodd#3#4 % -% \fi - \IntCalc@PowRec#2!#3#4!1!% + \InCa@PowRec#2!#3#4!1!% \else - \IntCalc@PowRec#1#2!#3#4!1!% + \InCa@PowRec#1#2!#3#4!1!% \fi \fi \fi \fi \fi } -\def\IntCalc@PowRec#1!#2!#3!{% +\def\InCa@PowRec#1!#2!#3!{% \ifnum#2=\@ne \ifnum#1>#3 % - \IntCalc@Mul#1!#3!% + \InCa@Mul#1!#3!% \else - \IntCalc@Mul#3!#1!% + \InCa@Mul#3!#1!% \fi \else - \expandafter\IntCalc@PowRec - \number\IntCalc@Mul#1!#1!\expandafter!% + \expandafter\InCa@PowRec + \number\InCa@Mul#1!#1!\expandafter!% \number\intcalcShr{#2}\expandafter!% \number \ifodd#2 % \ifnum#1>#3 % - \IntCalc@Mul#1!#3!% + \InCa@Mul#1!#3!% \else - \IntCalc@Mul#3!#1!% + \InCa@Mul#3!#1!% \fi \else #3% @@ -1327,52 +1408,68 @@ \fi } \def\intcalcDiv#1#2{% - \number\expandafter\IntCalc@Div + \number\expandafter\InCa@Div \number\number#1\expandafter!% \number#2! % } -\def\IntCalc@Div#1!#2!{% +\def\InCa@Div#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifcase#1 % 0% \else - \expandafter\IntCalc@DivSwitch + \expandafter\InCa@DivSwitch \number#1\expandafter!% \number#2!% \fi \fi } -\def\IntCalc@DivSwitch#1!#2!{% +\def\InCa@Temp#1{% + \def\IntCalcDiv##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \InCa@@Div##1!##2!% + \fi + \fi + #1% + }% +} +\InCa@Temp{ }% +\def\InCa@DivSwitch#1!#2!{% \ifnum#1<\z@ \ifnum#2<\z@ - \expandafter\IntCalc@@Div\number-#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@@Div\number-#1\expandafter!% + \@gobble#2!% \else -% - \expandafter\IntCalc@@Div\IntCalc@Gobble#1!#2!% + \expandafter\InCa@@Div\@gobble#1!#2!% \fi \else \ifnum#2<\z@ -% - \expandafter\IntCalc@@Div\number#1\expandafter!% - \IntCalc@Gobble#2!% + \expandafter\InCa@@Div\number#1\expandafter!% + \@gobble#2!% \else - \IntCalc@@Div#1!#2!% + \InCa@@Div#1!#2!% \fi \fi } -\def\IntCalc@@Div#1!#2!{% +\def\InCa@@Div#1!#2!{% \ifnum#1>#2 % \ifcase#2 % 0 already catched ? \IntCalcError:ThisCannotHappen% \or % 1 #1% \or % 2 - \IntCalc@Shr#1!% + \InCa@Shr#1!% \else - \IntCalc@DivStart!#1!#2!#2!% + \InCa@DivStart!#1!#2!#2!% \fi \else \ifnum#1=#2 % @@ -1382,55 +1479,55 @@ \fi \fi } -\def\IntCalc@DivStart#1!#2#3!#4#5{% +\def\InCa@DivStart#1!#2#3!#4#5{% \ifx#5!% \@ReturnAfterElseFi{% - \IntCalc@DivStartI{#1#2}#3=!% + \InCa@DivStartI{#1#2}#3=!% }% \else \@ReturnAfterFi{% - \IntCalc@DivStart{#1#2}!#3!#5% + \InCa@DivStart{#1#2}!#3!#5% }% \fi } -\def\IntCalc@DivStartI#1!#2!{% - \expandafter\IntCalc@DivStartII +\def\InCa@DivStartI#1!#2!{% + \expandafter\InCa@DivStartII \number#2\expandafter\expandafter\expandafter!% \intcalcShl{#2}!% #1!% } -\def\IntCalc@DivStartII#1!#2!{% - \expandafter\IntCalc@DivStartIII +\def\InCa@DivStartII#1!#2!{% + \expandafter\InCa@DivStartIII \number#1\expandafter!% \number#2\expandafter\expandafter\expandafter!% \intcalcShl{#2}!% } -\def\IntCalc@DivStartIII#1!#2!#3!{% - \expandafter\IntCalc@DivStartIV +\def\InCa@DivStartIII#1!#2!#3!{% + \expandafter\InCa@DivStartIV \number#1\expandafter!% \number#2\expandafter!% \number#3\expandafter!% - \number\IntCalc@Add#3!#2!\expandafter\expandafter\expandafter!% + \number\InCa@Add#3!#2!\expandafter\expandafter\expandafter!% \intcalcShl{#3}!% } -\def\IntCalc@DivStartIV#1!#2!#3!#4!#5!#6!{% - \IntCalc@ProcessDiv#6!#1!#2!#3!#4!#5!/% +\def\InCa@DivStartIV#1!#2!#3!#4!#5!#6!{% + \InCa@ProcessDiv#6!#1!#2!#3!#4!#5!/% } -\def\IntCalc@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9/{% +\def\InCa@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9/{% #9% \ifnum#1<#4 % 0 0% \ifx#2=% \else - \IntCalc@ProcessDiv{#1#2}#3!#4!#5!#6!#7!#8!% + \InCa@ProcessDiv{#1#2}#3!#4!#5!#6!#7!#8!% \fi \else % 1-9 \ifnum#1<#5 % 1 1% \ifx#2=% \else - \expandafter\IntCalc@ProcessDiv\expandafter{% - \number\IntCalc@Sub#1!#4!% + \expandafter\InCa@ProcessDiv\expandafter{% + \number\InCa@Sub#1!#4!% #2% }#3!#4!#5!#6!#7!#8!% \fi @@ -1438,14 +1535,14 @@ \ifnum#1<#7 % 2 3 4 5 \ifnum#1<#6 % 2 3 \@ReturnAfterElseFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#5!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#5!!% 23% }% \else % 4 5 \@ReturnAfterFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#6!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#6!!% 45% }% \fi @@ -1453,14 +1550,14 @@ \else % 6 7 8 9 \ifnum#1<#8 % 6 7 \@ReturnAfterElseFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#7!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#7!!% 67% }% \else % 8 9 \@ReturnAfterFi{% - \expandafter\IntCalc@@ProcessDiv - \number\IntCalc@Sub#1!#8!!% + \expandafter\InCa@@ProcessDiv + \number\InCa@Sub#1!#8!!% 89% }% \fi @@ -1469,19 +1566,19 @@ \fi \fi \ifx#2=% - \expandafter\IntCalc@Gobble + \expandafter\@gobble \fi /% } -\def\IntCalc@@ProcessDiv#1!#2#3#4#5!#6!{% +\def\InCa@@ProcessDiv#1!#2#3#4#5!#6!{% \ifnum#1<#6 % #2% \@ReturnAfterElseFi{% \ifx#4=% - \expandafter\IntCalc@CleanupIV + \expandafter\InCa@CleanupIV \else \@ReturnAfterFi{% - \IntCalc@ProcessDiv{#1#4}#5!#6!% + \InCa@ProcessDiv{#1#4}#5!#6!% }% \fi }% @@ -1489,11 +1586,11 @@ #3% \@ReturnAfterFi{% \ifx#4=% - \expandafter\IntCalc@CleanupIV + \expandafter\InCa@CleanupIV \else \@ReturnAfterFi{% - \expandafter\IntCalc@ProcessDiv\expandafter{% - \number\IntCalc@Sub#1!#6!\IntCalc@Space + \expandafter\InCa@ProcessDiv\expandafter{% + \number\InCa@Sub#1!#6! % #4% }#5!#6!% }% @@ -1501,19 +1598,19 @@ }% \fi } -\def\IntCalc@CleanupIV#1!#2!#3!#4!{} +\def\InCa@CleanupIV#1!#2!#3!#4!{} \def\intcalcMod#1#2{% - \number\expandafter\IntCalc@Mod + \number\expandafter\InCa@Mod \number\number#1\expandafter!% \number#2! % } -\def\IntCalc@Mod#1!#2!{% +\def\InCa@Mod#1!#2!{% \ifcase#2 % 0\IntCalcError:DivisionByZero% \else \ifnum#2<\z@ -% - \expandafter\IntCalc@Mod + \expandafter\InCa@Mod \number-#1\expandafter!% \number-#2!% \else @@ -1525,43 +1622,66 @@ \or % 1 0% \or % 2 - \ifodd#1 % - 1% - \else - 0% - \fi + \ifodd#1 1\else 0\fi \else \ifnum#1<\z@ - \expandafter\IntCalc@ModShift + \expandafter\InCa@ModShift \number-% - \expandafter\IntCalc@Sub - \number\IntCalc@Gobble#1\expandafter!% + \expandafter\InCa@Sub + \number\@gobble#1\expandafter!% \number\intcalcMul{#2}{% - \expandafter\IntCalc@Div\IntCalc@Gobble#1!#2!% + \expandafter\InCa@Div\@gobble#1!#2!% }!% !#2!% \else - \expandafter\IntCalc@Sub\number#1\expandafter!% - \number\intcalcMul{#2}{\IntCalc@Div#1!#2!}!% + \expandafter\InCa@Sub\number#1\expandafter!% + \number\intcalcMul{#2}{\InCa@Div#1!#2!}!% \fi \fi \fi \fi \fi } -\def\IntCalc@ModShift#1!#2!{% +\def\InCa@Temp#1{% + \def\IntCalcMod##1!##2!{% + \number + \ifcase##2 % + 0\IntCalcError:DivisionByZero% + \else + \ifcase##1 % + 0% + \else + \ifcase##2 % 0 already catched +? \IntCalcError:ThisCannotHappen + \or % 1 + 0% + \or % 2 + \ifodd ##1 1\else 0\fi + \else + \expandafter\InCa@Sub\number##1\expandafter!% + \number\intcalcMul{##2}{\InCa@Div##1!##2!}!% + \fi + \fi + \fi + #1% + }% +} +\InCa@Temp{ }% +\def\InCa@ModShift#1!#2!{% \ifnum#1<\z@ - \expandafter\IntCalc@Sub\number#2\expandafter!% - \IntCalc@Gobble#1!% + \expandafter\InCa@Sub\number#2\expandafter!% + \@gobble#1!% \else #1% \fi } -\def\IntCalc@Empty{} -\def\IntCalc@Gobble#1{} +\def\InCa@Empty{} +\expandafter\ifx\csname @gobble\endcsname\relax + \long\def\@gobble#1{}% +\fi \long\def\@ReturnAfterFi#1\fi{\fi#1}% \long\def\@ReturnAfterElseFi#1\else#2\fi{\fi#1}% -\IntCalc@AtEnd +\InCa@AtEnd \endinput diff --git a/Master/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty b/Master/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty index a93b927516e..a6b3ae92413 100644 --- a/Master/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +++ b/Master/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty @@ -25,7 +25,8 @@ %% This work consists of the main source file kvsetkeys.dtx %% and the derived files %% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, -%% kvsetkeys-example.tex, kvsetkeys-test1.tex. +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex. %% \begingroup \catcode44 12 % , @@ -79,7 +80,7 @@ \fi \expandafter\x\csname ver@kvsetkeys.sty\endcsname \ProvidesPackage{kvsetkeys}% - [2007/09/09 v1.2 Key value parser with default handler support (HO)] + [2007/09/29 v1.3 Key value parser with default handler support (HO)] \expandafter\edef\csname KVS@AtEnd\endcsname{% \catcode64 \the\catcode64\relax } @@ -91,6 +92,8 @@ }% \catcode#1 #2\relax } +\TMP@EnsureCode{36}{3}% $ +\TMP@EnsureCode{38}{4}% & \TMP@EnsureCode{39}{12}% ' \TMP@EnsureCode{44}{12}% , \TMP@EnsureCode{46}{12}% . @@ -99,199 +102,231 @@ \TMP@EnsureCode{94}{7}% ^ (superscript) \TMP@EnsureCode{96}{12}% ` \TMP@EnsureCode{126}{13}% ~ (active) -\def\KVS@empty{} -\long\def\@ReturnAfterFi#1\fi{\fi#1} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input infwarerr.sty\relax + \input etexcmds.sty\relax +\else + \RequirePackage{infwarerr}[2007/09/09]% + \RequirePackage{etexcmds}[2007/09/09]% +\fi +\begingroup\expandafter\endgroup +\ifcase0\ifetex@unexpanded + \expandafter\ifx\csname ifcsname\endcsname\relax + \else + \expandafter\ifx\csname unless\endcsname\relax + \else + 1% + \fi + \fi + \fi + \catcode`\$=9 % ignore + \catcode`\&=14 % comment +\else % e-TeX + \catcode`\$=14 % comment + \catcode`\&=9 % ignore +\fi +\def\KVS@Empty{} +\long\def\KVS@FirstOfTwo#1#2{#1} +\long\def\KVS@SecondOfTwo#1#2{#2} +\def\KVS@IfEmpty#1{% +& \edef\KVS@Temp{\etex@unexpanded{#1}}% +$ \begingroup +$ \toks@{#1}% +$ \edef\KVS@Temp{\the\toks@}% +$ \expandafter\endgroup + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo + \else + \expandafter\KVS@SecondOfTwo + \fi +} \def\kv@normalize#1{% \begingroup - \toks@{,#1}% - \KVS@comma - \KVS@equal - \KVS@spaceA - \KVS@spaceB{ }% - \KVS@spaceC - \KVS@spaceD{ }% - \xdef\kv@global{\the\toks@}% + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma{ }% + \KVS@CommaSpace + \KVS@CommaComma + \KVS@Equals + \KVS@SpaceEquals{ }% + \KVS@EqualsSpace{ }% + \xdef\KVS@Global{\the\toks@}% + \endgroup + \let\kv@list\KVS@Global +} +\def\comma@normalize#1{% + \begingroup + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma{ }% + \KVS@CommaSpace + \KVS@CommaComma + \xdef\KVS@Global{\the\toks@}% \endgroup - \let\kv@list\kv@global + \let\comma@list\KVS@Global } \begingroup \lccode`\,=`\,% \lccode`\~=`\,% \lowercase{\endgroup - \def\KVS@comma{% + \def\KVS@Comma{% \toks@\expandafter{\expandafter}\expandafter - \KVS@@comma\the\toks@~\KVS@nil + \KVS@@Comma\the\toks@~\KVS@Nil }% - \def\KVS@@comma#1~#2\KVS@nil{% - \toks@\expandafter{\the\toks@#1,}% - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@comma#2\KVS@nil - }% - \fi + \def\KVS@@Comma#1~#2\KVS@Nil{% + \toks@\expandafter{\the\toks@#1}% + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Comma,#2\KVS@Nil + }% + }% +} +\def\KVS@SpaceComma#1{% + \toks@\expandafter{\the\toks@#1,}% + \expandafter\KVS@@SpaceComma\the\toks@\KVS@Nil +} +\def\KVS@@SpaceComma#1 ,#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \toks@{#1,#2}% + \expandafter\KVS@@SpaceComma\the\toks@\KVS@Nil + }% +} +\def\KVS@CommaSpace{% + \toks@\expandafter{\the\toks@, }% + \expandafter\KVS@@CommaSpace\the\toks@\KVS@Nil +} +\def\KVS@@CommaSpace#1, #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \toks@{#1,#2}% + \expandafter\KVS@@CommaSpace\the\toks@\KVS@Nil + }% +} +\def\KVS@CommaComma{% + \toks@\expandafter{\the\toks@,}% + \expandafter\KVS@@CommaComma\the\toks@\KVS@Nil +} +\def\KVS@@CommaComma#1,,#2\KVS@Nil{% + \toks@{#1,#2}% + \KVS@IfEmpty{#2}{% + }{% + \expandafter\KVS@@CommaComma\the\toks@\KVS@Nil }% } \begingroup \lccode`\==`\=% \lccode`\~=`\=% \lowercase{\endgroup - \def\KVS@equal{% + \def\KVS@Equals{% \toks@\expandafter{\expandafter}\expandafter - \KVS@@equal\the\toks@~\KVS@nil + \KVS@@Equals\the\toks@~\KVS@Nil }% - \def\KVS@@equal#1~#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% + \def\KVS@@Equals#1~#2\KVS@Nil{% + \edef\KVS@Temp{\the\toks@}% + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@equal#2\KVS@nil - }% + \expandafter\KVS@SecondOfTwo \fi - }% -} -\def\KVS@spaceA{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceA\the\toks@= \KVS@nil -} -\def\KVS@@spaceA#1= #2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% - \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceA#2\KVS@nil + {% + \toks@{#1}% + }{% + \toks@\expandafter{\the\toks@=#1}% }% - \fi -} -\def\KVS@spaceB#1{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceB\the\toks@#1,\KVS@nil -} -\def\KVS@@spaceB#1 ,#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty - \toks@{#1}% - \else - \toks@\expandafter{\the\toks@,#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceB#2\KVS@nil + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Equals#2\KVS@Nil }% - \fi + }% } -\def\KVS@spaceC{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceC\the\toks@, \KVS@nil +\def\KVS@SpaceEquals#1{% + \toks@\expandafter{\the\toks@#1=}% + \expandafter\KVS@@SpaceEquals\the\toks@\KVS@Nil } -\def\KVS@@spaceC#1, #2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty +\def\KVS@@SpaceEquals#1 =#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% \toks@{#1}% - \else - \toks@\expandafter{\the\toks@,#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceC#2\KVS@nil - }% - \fi + }{% + \toks@{#1=#2}% + \expandafter\KVS@@SpaceEquals\the\toks@\KVS@Nil + }% } -\def\KVS@spaceD#1{% - \toks@\expandafter{\expandafter}\expandafter - \KVS@@spaceD\the\toks@#1=\KVS@nil +\def\KVS@EqualsSpace{% + \toks@\expandafter{\the\toks@= }% + \expandafter\KVS@@EqualsSpace\the\toks@\KVS@Nil } -\def\KVS@@spaceD#1 =#2\KVS@nil{% - \edef\x{\the\toks@}% - \ifx\x\KVS@empty +\def\KVS@@EqualsSpace#1= #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% \toks@{#1}% - \else - \toks@\expandafter{\the\toks@=#1}% - \fi - \toks2{#2}% - \edef\x{\the\toks2}% - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@@spaceD#2\KVS@nil - }% - \fi + }{% + \toks@{#1=#2}% + \expandafter\KVS@@EqualsSpace\the\toks@\KVS@Nil + }% } \def\kv@parse#1{% \kv@normalize{#1}% \expandafter\kv@parse@normalized\expandafter{\kv@list}% } \def\kv@parse@normalized#1#2{% - \KVS@parse#1,\KVS@nil{#2}% + \KVS@Parse#1,\KVS@Nil{#2}% } -\def\KVS@parse#1,#2\KVS@nil#3{% - \begingroup - \toks@{#1}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty - \else - \KVS@process#1=\KVS@nil{#3}% - \fi - \begingroup - \toks@{#2}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty - \else - \@ReturnAfterFi{% - \KVS@parse#2\KVS@nil{#3}% - }% - \fi +\def\KVS@Parse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \KVS@Process#1=\KVS@Nil{#3}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@Parse#2\KVS@Nil{#3}% + }% } -\def\KVS@process#1=#2\KVS@nil#3{% +\def\KVS@Process#1=#2\KVS@Nil#3{% \def\kv@key{#1}% - \begingroup - \toks@{#2}% - \edef\x{\the\toks@}% - \expandafter\endgroup - \ifx\x\KVS@empty + \KVS@IfEmpty{#2}{% \let\kv@value\relax #3{#1}{}% - \else - \KVS@@process{#1}#2\KVS@nil{#3}% - \fi + }{% + \KVS@@Process{#1}#2\KVS@Nil{#3}% + }% } -\def\KVS@@process#1#2=\KVS@nil#3{% - \begingroup - \toks@{#2}% - \xdef\KVS@global{\the\toks@}% - \endgroup - \let\kv@value\KVS@global +\def\KVS@@Process#1#2=\KVS@Nil#3{% +& \edef\kv@value{\etex@unexpanded{#2}}% +$ \begingroup +$ \toks@{#2}% +$ \xdef\KVS@Global{\the\toks@}% +$ \endgroup +$ \let\kv@value\KVS@Global #3{#1}{#2}% } +\def\comma@parse#1{% + \comma@normalize{#1}% + \expandafter\comma@parse@normalized\expandafter{\comma@list}% +} +\def\comma@parse@normalized#1#2{% + \KVS@CommaParse#1,\KVS@Nil{#2}% +} +\def\KVS@CommaParse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \def\comma@entry{#1}% + #3{#1}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@CommaParse#2\KVS@Nil{#3}% + }% +} \def\kv@processor@default#1#2#3{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KV@#1@#2\endcsname\relax - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KVS@#1@handler\endcsname\relax +& \unless\ifcsname KV@#1@#2\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2\endcsname\relax +& \unless\ifcsname KVS@#1@handler\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax \kv@error@unknownkey{#1}{#2}% \else \csname KVS@#1@handler\endcsname{#2}{#3}% @@ -299,8 +334,9 @@ \fi \else \ifx\kv@value\relax - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax +& \unless\ifcsname KV@#1@#2@default\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax \kv@error@novalue{#1}{#2}% \else \csname KV@#1@#2@default\endcsname @@ -312,17 +348,11 @@ \fi } \def\kv@set@family@handler#1{% - \KVS@set@family@handler{#1}\@nil + \KVS@SetFamilyHandler{#1}\@nil } -\def\KVS@set@family@handler#1\@nil#{% +\def\KVS@SetFamilyHandler#1\@nil#{% \expandafter\def\csname KVS@#1@handler\endcsname##1##2% } -\begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname RequirePackage\endcsname\relax - \input infwarerr.sty\relax -\else - \RequirePackage{infwarerr}[2007/09/09]% -\fi \def\kv@error@novalue{% \kv@error@generic{No value specified for}% } diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipdfm.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipdfm.def index 56c649103b8..da8d136f996 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipdfm.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipdfm.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvipdfm.def}% - [2007/07/13 v1.1 bookmark driver for dvipdfm (HO)]% + [2007/09/25 v1.2 bookmark driver for dvipdfm (HO)]% \newcount\BKM@id \BKM@id=\z@ \def\BKM@0{000} diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvips.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvips.def index 533f4a50e19..e3fa652e968 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvips.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvips.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvips.def}% - [2007/07/13 v1.1 bookmark driver for dvips (HO)]% + [2007/09/25 v1.2 bookmark driver for dvips (HO)]% \def\BKM@PSHeaderFile#1{% \special{header=#1}% } @@ -39,17 +39,22 @@ \BKM@PSHeaderFile\BKM@filename \AtEndDocument{\BKM@pdfmark@out} \def\BKM@pdfmark@out{% - \newwrite\BKM@file - \immediate\openout\BKM@file=\BKM@filename\relax - \BKM@write{\@percentchar!}% - \BKM@write{/pdfmark where{pop}}% - \BKM@write{% - {% - /globaldict where{pop globaldict}{userdict}ifelse% - /pdfmark/cleartomark load put% + \if@filesw + \newwrite\BKM@file + \immediate\openout\BKM@file=\BKM@filename\relax + \BKM@write{\@percentchar!}% + \BKM@write{/pdfmark where{pop}}% + \BKM@write{% + {% + /globaldict where{pop globaldict}{userdict}ifelse% + /pdfmark/cleartomark load put% + }% }% - }% - \BKM@write{ifelse}% + \BKM@write{ifelse}% + \else + \let\BKM@write\@gobble + \let\BKM@DO@entry\@gobbletwo + \fi } \def\BKM@write#{% \immediate\write\BKM@file diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipsone.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipsone.def index 1d900bf7b0a..9b23387b57f 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipsone.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-dvipsone.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-dvipsone.def}% - [2007/07/13 v1.1 bookmark driver for dvipsone (HO)]% + [2007/09/25 v1.2 bookmark driver for dvipsone (HO)]% \def\BKM@PSHeaderFile#1{% \special{header=#1}% } @@ -39,17 +39,22 @@ \BKM@PSHeaderFile\BKM@filename \AtEndDocument{\BKM@pdfmark@out} \def\BKM@pdfmark@out{% - \newwrite\BKM@file - \immediate\openout\BKM@file=\BKM@filename\relax - \BKM@write{\@percentchar!}% - \BKM@write{/pdfmark where{pop}}% - \BKM@write{% - {% - /globaldict where{pop globaldict}{userdict}ifelse% - /pdfmark/cleartomark load put% + \if@filesw + \newwrite\BKM@file + \immediate\openout\BKM@file=\BKM@filename\relax + \BKM@write{\@percentchar!}% + \BKM@write{/pdfmark where{pop}}% + \BKM@write{% + {% + /globaldict where{pop globaldict}{userdict}ifelse% + /pdfmark/cleartomark load put% + }% }% - }% - \BKM@write{ifelse}% + \BKM@write{ifelse}% + \else + \let\BKM@write\@gobble + \let\BKM@DO@entry\@gobbletwo + \fi } \def\BKM@write#{% \immediate\write\BKM@file diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-pdftex.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-pdftex.def index 160ce654360..866be76905d 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-pdftex.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-pdftex.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-pdftex.def}% - [2007/07/13 v1.1 bookmark driver for pdfTeX (HO)]% + [2007/09/25 v1.2 bookmark driver for pdfTeX (HO)]% \def\BKM@DO@entry#1#2{% \begingroup \setkeys{BKM@DO}{#1}% diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-textures.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-textures.def index abfac6a82d3..68ad286b627 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-textures.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-textures.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-textures.def}% - [2007/07/13 v1.1 bookmark driver for textures (HO)]% + [2007/09/25 v1.2 bookmark driver for textures (HO)]% \def\BKM@PSHeaderFile#1{% \special{prePostScriptfile #1}% } @@ -39,17 +39,22 @@ \BKM@PSHeaderFile\BKM@filename \AtEndDocument{\BKM@pdfmark@out} \def\BKM@pdfmark@out{% - \newwrite\BKM@file - \immediate\openout\BKM@file=\BKM@filename\relax - \BKM@write{\@percentchar!}% - \BKM@write{/pdfmark where{pop}}% - \BKM@write{% - {% - /globaldict where{pop globaldict}{userdict}ifelse% - /pdfmark/cleartomark load put% + \if@filesw + \newwrite\BKM@file + \immediate\openout\BKM@file=\BKM@filename\relax + \BKM@write{\@percentchar!}% + \BKM@write{/pdfmark where{pop}}% + \BKM@write{% + {% + /globaldict where{pop globaldict}{userdict}ifelse% + /pdfmark/cleartomark load put% + }% }% - }% - \BKM@write{ifelse}% + \BKM@write{ifelse}% + \else + \let\BKM@write\@gobble + \let\BKM@DO@entry\@gobbletwo + \fi } \def\BKM@write#{% \immediate\write\BKM@file diff --git a/Master/texmf-dist/tex/latex/oberdiek/bkm-vtex.def b/Master/texmf-dist/tex/latex/oberdiek/bkm-vtex.def index bf49901d77b..b19043bd457 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bkm-vtex.def +++ b/Master/texmf-dist/tex/latex/oberdiek/bkm-vtex.def @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{bkm-vtex.def}% - [2007/07/13 v1.1 bookmark driver for VTeX (HO)]% + [2007/09/25 v1.2 bookmark driver for VTeX (HO)]% \ifvtexpdf \else \PackageWarningNoLine{bookmark}{% diff --git a/Master/texmf-dist/tex/latex/oberdiek/bookmark.sty b/Master/texmf-dist/tex/latex/oberdiek/bookmark.sty index 7a4ef80f920..64417add9b8 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/bookmark.sty +++ b/Master/texmf-dist/tex/latex/oberdiek/bookmark.sty @@ -31,7 +31,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{bookmark}% - [2007/07/13 v1.1 PDF bookmarks (HO)]% + [2007/09/25 v1.2 PDF bookmarks (HO)]% \newif\ifBKM@WithFlags \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname numexpr\endcsname\relax diff --git a/Master/texmf-dist/tex/latex/oberdiek/epstopdf.sty b/Master/texmf-dist/tex/latex/oberdiek/epstopdf.sty index aade325323e..20306f5a163 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/epstopdf.sty +++ b/Master/texmf-dist/tex/latex/oberdiek/epstopdf.sty @@ -25,7 +25,8 @@ %% %% This work consists of the main source file epstopdf.dtx %% and the derived files -%% epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv. +%% epstopdf.sty, epstopdf.pdf, epstopdf.ins, epstopdf.drv, +%% epstopdf-test1.tex. %% \begingroup \catcode44 12 % , @@ -79,44 +80,53 @@ \fi \expandafter\x\csname ver@epstopdf.sty\endcsname \ProvidesPackage{epstopdf}% - [2007/04/26 v1.4 Conversion with epstopdf on the fly (HO)] -\@ifundefined{PackageWarning}{% - \def\PackageWarning#1#2{% - \begingroup - \newlinechar=10 % - \def\MessageBreak{% - ^^J(#1)\@spaces\@spaces\@spaces\@spaces - }% - \immediate\write16{^^JPackage #1 Warning: #2\on@line.^^J}% - \endgroup - }% -}{} -\@ifundefined{PackageWarningNoLine}{% - \def\PackageWarningNoLine#1#2{% - \PackageWarning{#1}{#2\@gobble}% + [2007/10/02 v1.5 Conversion with epstopdf on the fly (HO)] +\expandafter\edef\csname ETE@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\ETE@AtEnd{% + \ETE@AtEnd + \catcode#1 \the\catcode#1\relax }% -}{} -\@ifundefined{on@line}{% - \def\on@line{ on input line \the\inputlineno}% -}{} -\@ifundefined{@spaces}{% - \def\@spaces{\space\space\space\space}% -}{} + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{12}% : +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{96}{12}% ` +\RequirePackage{infwarerr}[2007/09/09] +\RequirePackage{grfext}\relax +\RequirePackage{kvoptions}[2006/10/02] \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname Gin@setfile\endcsname\relax - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% No graphics package \string`graphic{s,x}\string' found% }% + \newcommand*{\epstopdfsetup}[1]{}% + \ETE@AtEnd \expandafter\endinput \fi \begingroup \def\x{pdftex.def}% \ifx\Gin@driver\x \else - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% Graphics driver file \string`pdftex.def\string' not found% }% - \expandafter\endgroup\expandafter\endinput + \endgroup + \newcommand*{\epstopdfsetup}[1]{}% + \ETE@AtEnd + \expandafter\endinput \fi \endgroup \begingroup @@ -124,33 +134,182 @@ \else \ifnum\pdfshellescape>0 % \else - \PackageWarningNoLine{epstopdf}{% + \@PackageWarningNoLine{epstopdf}{% Shell escape feature is not enabled% }% \fi \fi \endgroup -\let\ETEorg@Gin@setfile\Gin@setfile +\SetupKeyvalOptions{family=ETE,prefix=ETE@} +\DeclareBoolOption{update} +\DeclareBoolOption{verbose} +\newif\ifETE@prepend +\DeclareVoidOption{prepend}{\ETE@prependtrue} +\DeclareVoidOption{append}{\ETE@prependfalse} +\DeclareStringOption{outdir} +\ProcessKeyvalOptions* +\newcommand*{\epstopdfsetup}{\setkeys{ETE}} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname pdffilemoddate\endcsname\relax + \def\ETE@Make#1#2{% + \ifETE@update + \ETE@WarnModDate + \fi + \@firstofone + }% + \def\ETE@WarnModDate{% + \@PackageWarningNoLine{epstopdf}{% + \string\pdffilemoddate\space is not available,\MessageBreak + option `update' will be ignored% + }% + \global\let\ETE@WarnModDate\relax + }% + \def\ETE@FileInfo#1#2{#1 file: <#2>}% +\else + \def\ETE@Make#1#2{% + \ifETE@update + \ifnum\pdfstrcmp{\pdffilemoddate{#1}}{\pdffilemoddate{#2}}>0 % + \expandafter\expandafter\expandafter\@firstofone + \else + \@PackageInfoNoLine{epstopdf}{% + Output file is already uptodate% + }% + \expandafter\expandafter\expandafter\@gobble + \fi + \else + \expandafter\@firstofone + \fi + }% + \def\ETE@FileInfo#1#2{% + #1 file: <#2>% + \expandafter\ETE@Date\pdffilemoddate{#2}\@nil + \expandafter\ETE@Size\pdffilesize{#2}\@nil + }% + \def\ETE@Date#1\@nil{% + \ifx\\#1\\% + \else + \ETE@@Date#1\@nil + \fi + }% + \def\ETE@@Date#1:#2#3#4#5#6#7#8#9{% + \MessageBreak + \@spaces\space\space\space date: #2#3#4#5-#6#7-#8#9 % + \ETE@@Time + }% + \def\ETE@@Time#1#2#3#4#5#6#7\@nil{% + #1#2:#3#4:#5#6% + }% + \def\ETE@Size#1\@nil{% + \ifx\\#1\\% + \else + \MessageBreak + \@spaces\space\space\space size: #1 bytes% + \fi + }% +\fi +\expandafter\ifx\csname ETE@OrgGin@setfile\endcsname\relax + \let\ETE@OrgGin@setfile\Gin@setfile +\else + \@PackageError{epstopdf}{% + Command \string\ETE@OrgGin@setfile\space + already defined.\MessageBreak + }{% + Probably some package has included the code of this package% + \MessageBreak + instead of using \string\RequirePackage{epstopdf}.% + \MessageBreak + \@ehc + }% +\fi \def\Gin@setfile#1#2#3{% \if`\@car #3\relax\@nil - \immediate\write18{\@cdr #3\@empty\@nil}% - \ETEorg@Gin@setfile{#1}{#2}{\Gin@base #2}% + \begingroup + \def\GraphicsType{#1}% + \def\GraphicsRead{#2}% + \ifx\Gin@ext\relax + \def\SourceFile{\Gin@base\Gin@eext}% + \else + \def\SourceFile{\Gin@base\Gin@ext}% + \fi + \let\OutputDirectory\ETE@outdir + \ifx\OutputDirectory\@empty + \def\OutputFile{\Gin@base#2}% + \else + \begingroup + \filename@parse{\Gin@base#2}% + \edef\x{\endgroup + \def\noexpand\OutputFile{% + \OutputDirectory\filename@base#2% + }% + }% + \x + \fi + \edef\CommandLine{\@cdr#3\@empty\@nil}% + \ifETE@verbose + \@PackageInfo{epstopdf}{% + \ETE@FileInfo{Source}\SourceFile\MessageBreak + \ETE@FileInfo{Output}\OutputFile\MessageBreak + Command: <\CommandLine>\MessageBreak + \string\includegraphics + }% + \fi + \ETE@Make\SourceFile\OutputFile{% + \immediate\write18{\CommandLine}% + \ifETE@verbose + \@PackageInfoNoLine{epstopdf}{% + \ETE@FileInfo{Result}\OutputFile + }% + \fi + }% + \edef\x{\endgroup + \ifx\OutputDirectory\@empty + \else + \def\noexpand\Gin@base{% + \OutputDirectory\noexpand\filename@base + }% + \fi + \noexpand\ETE@OrgGin@setfile{% + \GraphicsType + }{% + \GraphicsRead + }{% + \OutputFile + }% + }% + \x \else - \ETEorg@Gin@setfile{#1}{#2}{#3}% + \ETE@OrgGin@setfile{#1}{#2}{#3}% \fi } -\@ifundefined{Gin@extensions}{% - \def\Gin@extensions{.eps}% -}{% - \expandafter\ifx\expandafter\indent\Gin@extensions\indent - \def\Gin@extensions{.eps}% +\expandafter\ifx\csname Gin@rule@.eps\endcsname\relax +\else + \@PackageInfo{epstopdf}{Overwriting graphics rule for `.eps'}% +\fi +\@namedef{Gin@rule@.eps}#1{{pdf}{.pdf}{`\ETE@epstopdf{#1}}} +\def\ETE@epstopdf#1{% + epstopdf % + \ifx\OutputDirectory\@empty \else - \expandafter\def\expandafter\Gin@extensions\expandafter{% - \Gin@extensions,.eps% - }% + --outfile=\OutputFile\space \fi + #1% +} +\ifETE@prepend + \expandafter\PrependGraphicsExtensions +\else + \expandafter\AppendGraphicsExtensions +\fi +{.eps} +\let\ETE@prepend\@undefined +\DeclareVoidOption{prepend}{% + \PrependGraphicsExtensions{.eps}% +} +\let\ETE@append\@undefined +\DeclareVoidOption{append}{% + \AppendGraphicsExtensions{.eps}% } -\@namedef{Gin@rule@.eps}#1{{pdf}{.pdf}{`epstopdf #1}} +\InputIfFileExists{epstopdf.cfg}{}{} +\ETE@AtEnd \endinput %% %% End of file `epstopdf.sty'. diff --git a/Master/texmf-dist/tex/latex/oberdiek/flags.sty b/Master/texmf-dist/tex/latex/oberdiek/flags.sty index 39de0fd1a91..0df21541f6b 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/flags.sty +++ b/Master/texmf-dist/tex/latex/oberdiek/flags.sty @@ -28,7 +28,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{flags}% - [2007/03/07 v0.3 Flag setting in bit fields (HO)]% + [2007/09/30 v0.4 Flag setting in bit fields (HO)]% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname numexpr\endcsname\relax \PackageError{flags}{% diff --git a/Master/texmf-dist/tex/latex/oberdiek/grfext.sty b/Master/texmf-dist/tex/latex/oberdiek/grfext.sty new file mode 100644 index 00000000000..41817c91c0c --- /dev/null +++ b/Master/texmf-dist/tex/latex/oberdiek/grfext.sty @@ -0,0 +1,214 @@ +%% +%% This is file `grfext.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% grfext.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file grfext.dtx +%% and the derived files +%% grfext.sty, grfext.pdf, grfext.ins, grfext.drv, +%% grfext-test1.tex, grfext-test2.tex. +%% +\begingroup + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\let\expandafter\x\csname ver@grfext.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{grfext}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@grfext.sty\endcsname +\ProvidesPackage{grfext}% + [2007/09/30 v1.0 Managing graphics extensions (HO)] +\expandafter\edef\csname grfext@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\grfext@AtEnd{% + \grfext@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\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}% ] +\@ifundefined{@expandtwoargs}{% + \def\@expandtwoargs#1#2#3{% + \edef\reserved@a{\noexpand#1{#2}{#3}}% + \reserved@a + }% +}{} +\newcommand*{\AppendGraphicsExtensions}{% + \@ifundefined{Gin@extensions}{% + \let\Gin@extensions\@empty + }{}% + \@ifstar{\grfext@Append\grfext@Check}{\grfext@Append\grfext@@Add}% +}% +\def\grfext@Append#1#2{% + \let\grfext@Print\@gobble + \edef\grfext@next{% + \noexpand\grfext@Add\noexpand#1{% + \zap@space#2 \@empty + }{\noexpand\Gin@extensions,}{}% + }% + \grfext@next + \let\grfext@Print\grfext@@Print + \grfext@Print\AppendGraphicsExtensions +} +\newcommand*{\PrependGraphicsExtensions}{% + \@ifundefined{Gin@extensions}{% + \let\Gin@extensions\@empty + }{}% + \@ifstar{\grfext@Prepend\grfext@Check}{\grfext@Prepend\grfext@@Add}% +}% +\def\grfext@Prepend#1#2{% + \let\grfext@Print\@gobble + \edef\grfext@next{% + \noexpand\grfext@Add\noexpand#1{% + \zap@space#2 \@empty + }{}{,\noexpand\Gin@extensions}% + }% + \grfext@next + \let\grfext@Print\grfext@@Print + \grfext@Print\PrependGraphicsExtensions +} +\def\grfext@Add#1#2{% + #1{#2}% +} +\def\grfext@@Add#1#2#3{% + \RemoveGraphicsExtensions{#1}% + \ifx\Gin@extensions\@empty + \def\Gin@extensions{#1}% + \else + \edef\Gin@extensions{#2#1#3}% + \fi +} +\def\grfext@Check#1{% + \let\grfext@tmp\@empty + \@for\grfext@ext:=#1\do{% + \@ifundefined{Gin@rule@\grfext@ext}{% + }{% + \ifx\grfext@tmp\@empty + \let\grfext@tmp\grfext@ext + \else + \edef\grfext@tmp{\grfext@tmp,\grfext@ext}% + \fi + }% + }% + \ifx\grfext@tmp\@empty + \def\grfext@next##1##2{}% + \else + \edef\grfext@next{% + \noexpand\grfext@@Add{\grfext@tmp}% + }% + \fi + \grfext@next +} +\newcommand*{\RemoveGraphicsExtensions}[1]{% + \@ifundefined{Gin@extensions}{% + \def\Gin@extensions{}% + }{% + \edef\grfext@tmp{\zap@space#1 \@empty}% + \@for\grfext@ext:=\grfext@tmp\do{% + \def\grfext@next{% + \let\grfext@tmp\Gin@extensions + \@expandtwoargs + \@removeelement\grfext@ext\Gin@extensions\Gin@extensions + \ifx\grfext@tmp\Gin@extensions + \let\grfext@next\relax + \fi + \grfext@next + }% + \grfext@next + }% + }% + \grfext@Print\RemoveGraphicsExtensions +} +\RequirePackage{infwarerr}[2007/09/09] +\def\PrintGraphicsExtensions{% + \grfext@Print\PrintGraphicsExtensions +} +\def\grfext@Print#1{% + \@PackageInfo{grfext}{% + Graphics extension search list:\MessageBreak + \@ifundefined{Gin@extensions}{% + <unavailable>% + }{% + [\Gin@extensions]% + }\MessageBreak + \string#1% + }% +} +\let\grfext@@Print\grfext@Print +\grfext@AtEnd +\endinput +%% +%% End of file `grfext.sty'. diff --git a/Master/texmf-dist/tex/latex/oberdiek/kvoptions.sty b/Master/texmf-dist/tex/latex/oberdiek/kvoptions.sty index 070ced9c61d..1a222383f32 100644 --- a/Master/texmf-dist/tex/latex/oberdiek/kvoptions.sty +++ b/Master/texmf-dist/tex/latex/oberdiek/kvoptions.sty @@ -26,30 +26,119 @@ %% This work consists of the main source file kvoptions.dtx %% and the derived files %% kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, -%% example-mycolorsetup.sty. +%% example-mycolorsetup.sty, kvoptions-test1.tex. %% %% No we don't need the option 'color'. -%% With color support option 'emphcolor' will dynamically change -%% the color of \emph statements. -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{kvoptions} - [2007/06/11 v2.7 Connects package keyval with LaTeX options (HO)]% -\RequirePackage{keyval} +%% With color support option 'emphcolor' will dynamically +%% change the color of \emph statements. \begingroup - \edef\x{\endgroup - \noexpand\AtEndOfPackage{% - \catcode\@ne=\the\catcode\@ne\relax - \catcode\tw@=\the\catcode\tw@\relax + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\let\expandafter\x\csname ver@kvoptions.sty\endcsname + \ifcase 0% + \ifx\x\relax % plain + \else + \ifx\x\empty % LaTeX + \else + 1% + \fi + \fi + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{kvoptions}{The package is already loaded}% + \endgroup + \expandafter\endinput + \fi +\endgroup +\begingroup + \catcode40 12 % ( + \catcode41 12 % ) + \catcode44 12 % , + \catcode45 12 % - + \catcode46 12 % . + \catcode47 12 % / + \catcode58 12 % : + \catcode64 11 % @ + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@kvoptions.sty\endcsname +\ProvidesPackage{kvoptions}% + [2007/10/02 v2.8 Connects package keyval with LaTeX options (HO)] +\expandafter\edef\csname KVO@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\KVO@AtEnd{% + \KVO@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{1}{14}% ^^A (comment) +\TMP@EnsureCode{2}{14}% ^^A (comment) +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{42}{12}% * +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{58}{12}% : +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{94}{7}% ^ (superscript) +\TMP@EnsureCode{96}{12}% ` +\@ifundefined{define@key}{% + \RequirePackage{keyval}\relax +}{} +\@ifundefined{@onelevel@sanitize}{% + \def\@onelevel@sanitize#1{% + \edef#1{\expandafter\strip@prefix\meaning#1}% }% -\x -\catcode\@ne=14 % -\catcode\tw@=14 % +}{} +\@ifundefined{strip@prefix}{% + \def\strip@prefix#1>{}% +}{} +\@ifundefined{@x@protect}{% + \def\@x@protect#1\fi#2#3{% + \fi\protect#1% + }% + \let\@typeset@protect\relax +}{} +\@ifundefined{@currname}{% + \def\@currname{}% +}{} +\@ifundefined{@currext}{% + \def\@currext{}% +}{} \DeclareOption{debugshow}{\catcode\@ne=9 } \DeclareOption{patch}{\catcode\tw@=9 } \ProcessOptions\relax \define@key{KVO}{family}{% - \expandafter\edef\csname KVO@family@\@currname.\@currext\endcsname{#1}% + \expandafter\edef\csname KVO@family@% + \@currname.\@currext\endcsname{#1}% } \def\KVO@family{% \@ifundefined{KVO@family@\@currname.\@currext}{% @@ -59,7 +148,8 @@ }% } \define@key{KVO}{prefix}{% - \expandafter\edef\csname KVO@prefix@\@currname.\@currext\endcsname{#1}% + \expandafter\edef\csname KVO@prefix@% + \@currname.\@currext\endcsname{#1}% } \def\KVO@prefix{% \@ifundefined{KVO@prefix@\@currname.\@currext}{% @@ -75,7 +165,8 @@ \KVO@ifdefinable{if\KVO@prefix#2}{% \KVO@ifdefinable{\KVO@prefix#2true}{% \KVO@ifdefinable{\KVO@prefix#2false}{% - \expandafter\newif\csname if\KVO@prefix#2\endcsname + \csname newif\expandafter\endcsname + \csname if\KVO@prefix#2\endcsname \@ifundefined{\KVO@prefix#2#1}{% \PackageWarning{kvoptions}{% Initialization of option `#2' failed,\MessageBreak @@ -111,8 +202,10 @@ You are inside % \ifx\@currext\@clsextension class\else package\fi\space `\@currname.\@currext'.\MessageBreak - `\KVO@family' is used as familiy for the keyval options.\MessageBreak - `\KVO@prefix' serves as prefix for internal switch macros.\MessageBreak + `\KVO@family' is used as familiy % + for the keyval options.\MessageBreak + `\KVO@prefix' serves as prefix % + for internal switch macros.\MessageBreak \MessageBreak \@ehc }% @@ -410,7 +503,8 @@ \ifx\@classoptionslist\relax \else \@for\KVO@CurrentOption:=\@classoptionslist\do{% - \@ifundefined{KV@#1@\expandafter\KVO@getkey\KVO@CurrentOption=\@nil}{% + \@ifundefined{KV@#1@\expandafter\KVO@getkey + \KVO@CurrentOption=\@nil}{% }{% \edef\KVO@temp{% ^^B \etex@unexpanded\expandafter{% @@ -522,8 +616,15 @@ \def\KVO@setcurrentvalue#1=#2\@nil{% \KV@@sp@def\CurrentOptionValue{#2}% } -^^B\@gobble - \endinput +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname documentclass\endcsname\relax + \def\ProcessKeyvalOptions{% + \@ifstar{}\@gobble + }% + \catcode\tw@=14 % +\fi +^^B\@gobbletwo +\KVO@AtEnd\endinput \PackageInfo{kvoptions}{Patching LaTeX's option system} \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname eTeXversion\endcsname\relax @@ -691,11 +792,15 @@ } \def\KVO@ExecuteOptions#1#2{% \let#1\CurrentOption - \edef\CurrentOption@SaveLevel{\the\numexpr\CurrentOption@SaveLevel+1}% + \edef\CurrentOption@SaveLevel{% + \the\numexpr\CurrentOption@SaveLevel+1% + }% \@for\CurrentOption:=#2\do{% \csname ds@\CurrentOption\endcsname }% - \edef\CurrentOption@SaveLevel{\the\numexpr\CurrentOption@SaveLevel-1}% + \edef\CurrentOption@SaveLevel{% + \the\numexpr\CurrentOption@SaveLevel-1% + }% \let\CurrentOption#1% } \def\KVO@fileswith@pti@ns#1[#2]#3[#4]{% @@ -724,7 +829,8 @@ \else \ifx\relax##1\relax \else - \KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]\@pkgextension + \KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]% + \@pkgextension \fi \expandafter\reserved@b \fi @@ -936,6 +1042,7 @@ \else \let\@fileswith@pti@ns\KVO@fileswith@pti@ns \fi +KVO@AtEnd \endinput %% %% End of file `kvoptions.sty'. |