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 /Master/texmf-dist/tex/generic/oberdiek | |
parent | f020fc73ad0b6e33f65d5f0b84646131e0340f2f (diff) |
oberdiek update/new: bigintcalc bitset grfext
git-svn-id: svn://tug.org/texlive/trunk@5118 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/oberdiek')
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty | 1766 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/bitset.sty | 1395 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/engord.sty | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/intcalc.sty | 892 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty | 354 |
5 files changed, 3860 insertions, 549 deletions
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}% } |