diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xinttools.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xinttools.sty | 256 |
1 files changed, 208 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xinttools.sty b/Master/texmf-dist/tex/generic/xint/xinttools.sty index 11d8315c830..9b5e78d39b8 100644 --- a/Master/texmf-dist/tex/generic/xint/xinttools.sty +++ b/Master/texmf-dist/tex/generic/xint/xinttools.sty @@ -21,7 +21,7 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %%---------------------------------------------------------------- -%% The xint bundle (version 1.09kb of February 13, 2014) +%% The xint bundle (version 1.09m of February 26, 2014) %% xinttools: Expandable and non-expandable utilities %% Copyright (C) 2013-2014 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -152,7 +152,7 @@ \fi \XINT_providespackage \ProvidesPackage {xinttools}% - [2014/02/13 v1.09kb Expandable and non-expandable utilities (jfB)]% + [2014/02/26 v1.09m Expandable and non-expandable utilities (jfB)]% \long\def\xint_gobble_ {}% \long\def\xint_gobble_i #1{}% \long\def\xint_gobble_ii #1#2{}% @@ -163,12 +163,14 @@ \long\def\xint_gobble_vii #1#2#3#4#5#6#7{}% \long\def\xint_gobble_viii #1#2#3#4#5#6#7#8{}% \long\def\xint_firstofone #1{#1}% -\xint_firstofone{\let\XINT_sptoken= } %<- space here! \long\def\xint_firstoftwo #1#2{#1}% \long\def\xint_secondoftwo #1#2{#2}% +\long\def\xint_firstofone_thenstop #1{ #1}% \long\def\xint_firstoftwo_thenstop #1#2{ #1}% \long\def\xint_secondoftwo_thenstop #1#2{ #2}% \def\xint_minus_thenstop { -}% +\def\xint_gob_til_zero #10{}% no need to make it long, so far +\def\xint_UDzerominusfork #10-#2#3\krof {#2}% id. \long\def\xint_gob_til_R #1\R {}% \long\def\xint_gob_til_W #1\W {}% \long\def\xint_gob_til_Z #1\Z {}% @@ -178,9 +180,16 @@ \long\def\xint_gob_til_xint_relax #1\xint_relax {}% \long\def\xint_afterfi #1#2\fi {\fi #1}% \chardef\xint_c_ 0 -\chardef\xint_c_i 1 % 1.09k did not have it, but needed in \xintSeq +\chardef\xint_c_i 1 +\chardef\xint_c_ii 2 +\chardef\xint_c_iii 3 +\chardef\xint_c_iv 4 +\chardef\xint_c_v 5 +\chardef\xint_c_vi 6 +\chardef\xint_c_vii 7 \chardef\xint_c_viii 8 \newtoks\XINT_toks +\xint_firstofone{\let\XINT_sptoken= } %<- space here! \def\xintodef #1{\expandafter\def\expandafter#1\expandafter }% \ifdefined\odef\else\let\odef\xintodef\fi \def\xintgodef {\global\xintodef }% @@ -256,33 +265,33 @@ \long\def\xintlength #1% {% \XINT_length_loop - {0}#1\xint_relax\xint_relax\xint_relax\xint_relax + 0.#1\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye }% -\long\def\XINT_length_loop #1#2#3#4#5#6#7#8#9% +\long\def\XINT_length_loop #1.#2#3#4#5#6#7#8#9% {% \xint_gob_til_xint_relax #9\XINT_length_finish_a\xint_relax - \expandafter\XINT_length_loop\expandafter {\the\numexpr #1+8\relax}% + \expandafter\XINT_length_loop\the\numexpr #1+\xint_c_viii.% }% -\def\XINT_length_finish_a\xint_relax - \expandafter\XINT_length_loop\expandafter #1#2\xint_bye +\def\XINT_length_finish_a\xint_relax\expandafter\XINT_length_loop + \the\numexpr #1+\xint_c_viii.#2\xint_bye {% \XINT_length_finish_b #2\W\W\W\W\W\W\W\Z {#1}% }% \def\XINT_length_finish_b #1#2#3#4#5#6#7#8\Z {% \xint_gob_til_W - #1\XINT_length_finish_c 8% - #2\XINT_length_finish_c 7% - #3\XINT_length_finish_c 6% - #4\XINT_length_finish_c 5% - #5\XINT_length_finish_c 4% - #6\XINT_length_finish_c 3% - #7\XINT_length_finish_c 2% - \W\XINT_length_finish_c 1\Z + #1\XINT_length_finish_c \xint_c_ + #2\XINT_length_finish_c \xint_c_i + #3\XINT_length_finish_c \xint_c_ii + #4\XINT_length_finish_c \xint_c_iii + #5\XINT_length_finish_c \xint_c_iv + #6\XINT_length_finish_c \xint_c_v + #7\XINT_length_finish_c \xint_c_vi + \W\XINT_length_finish_c \xint_c_vii\Z }% \edef\XINT_length_finish_c #1#2\Z #3% - {\noexpand\expandafter\space\noexpand\the\numexpr #3-#1\relax}% + {\noexpand\expandafter\space\noexpand\the\numexpr #3+#1\relax}% \def\xintZapFirstSpaces {\romannumeral0\xintzapfirstspaces }% \long\edef\xintzapfirstspaces #1% {\noexpand\XINT_zapbsp_a \space #1\space\space\noexpand\xint_bye\xint_relax }% @@ -411,66 +420,217 @@ \long\def\XINT_lws_end\xint_bye\XINT_lws_loop_b #1#2#3{ #1}% \def\xintNthElt {\romannumeral0\xintnthelt }% \def\xintNthEltNoExpand {\romannumeral0\xintntheltnoexpand }% -\def\xintnthelt #1% +\def\xintnthelt #1#2% {% - \expandafter\XINT_nthelt_a\expandafter {\the\numexpr #1}% + \expandafter\XINT_nthelt_a\the\numexpr #1\expandafter.% + \expandafter{\romannumeral-`0#2}% }% \def\xintntheltnoexpand #1% {% - \expandafter\XINT_ntheltnoexpand_a\expandafter {\the\numexpr #1}% + \expandafter\XINT_nthelt_a\the\numexpr #1.% }% -\long\def\XINT_nthelt_a #1#2% +\def\XINT_nthelt_a #1#2.% {% - \ifnum #1<0 - \xint_afterfi{\expandafter\XINT_nthelt_c\expandafter - {\romannumeral0\xintrevwithbraces {#2}}{-#1}}% - \else - \xint_afterfi{\expandafter\XINT_nthelt_c\expandafter - {\romannumeral-`0#2}{#1}}% - \fi + \xint_UDzerominusfork + #1-{\XINT_nthelt_bzero}% + 0#1{\XINT_nthelt_bneg {#2}}% + 0-{\XINT_nthelt_bpos {#1#2}}% + \krof }% -\long\def\XINT_ntheltnoexpand_a #1#2% +\long\def\XINT_nthelt_bzero #1% {% - \ifnum #1<0 - \xint_afterfi{\expandafter\XINT_nthelt_c\expandafter - {\romannumeral0\xintrevwithbracesnoexpand {#2}}{-#1}}% - \else - \xint_afterfi{\expandafter\XINT_nthelt_c\expandafter - {#2}{#1}}% - \fi + \XINT_length_loop 0.#1\xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye }% -\long\def\XINT_nthelt_c #1#2% +\long\def\XINT_nthelt_bneg #1#2% {% - \ifnum #2>\xint_c_ - \expandafter\XINT_nthelt_loop_a - \else - \expandafter\XINT_length_loop - \fi {#2}#1\xint_relax\xint_relax\xint_relax\xint_relax + \expandafter\XINT_nthelt_loop_a\expandafter {\the\numexpr #1\expandafter}% + \romannumeral0\xintrevwithbracesnoexpand {#2}% + \xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye }% +\long\def\XINT_nthelt_bpos #1#2% +{% + \XINT_nthelt_loop_a {#1}#2\xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye +}% \def\XINT_nthelt_loop_a #1% {% \ifnum #1>\xint_c_viii \expandafter\XINT_nthelt_loop_b \else - \expandafter\XINT_nthelt_getit + \XINT_nthelt_getit \fi {#1}% }% \long\def\XINT_nthelt_loop_b #1#2#3#4#5#6#7#8#9% {% \xint_gob_til_xint_relax #9\XINT_nthelt_silentend\xint_relax - \expandafter\XINT_nthelt_loop_a\expandafter{\the\numexpr #1-8}% + \expandafter\XINT_nthelt_loop_a\expandafter{\the\numexpr #1-\xint_c_viii}% }% \def\XINT_nthelt_silentend #1\xint_bye { }% -\def\XINT_nthelt_getit #1% +\def\XINT_nthelt_getit\fi #1% {% - \expandafter\expandafter\expandafter\XINT_nthelt_finish - \csname xint_gobble_\romannumeral\numexpr#1-1\endcsname + \fi\expandafter\expandafter\expandafter\XINT_nthelt_finish + \csname xint_gobble_\romannumeral\numexpr#1-\xint_c_i\endcsname }% \long\edef\XINT_nthelt_finish #1#2\xint_bye {\noexpand\xint_gob_til_xint_relax #1\noexpand\expandafter\space \noexpand\xint_gobble_iii\xint_relax\space #1}% +\def\xintKeep {\romannumeral0\xintkeep }% +\def\xintKeepNoExpand {\romannumeral0\xintkeepnoexpand }% +\def\xintkeep #1#2% +{% + \expandafter\XINT_keep_a\the\numexpr #1\expandafter.% + \expandafter{\romannumeral-`0#2}% +}% +\def\xintkeepnoexpand #1% +{% + \expandafter\XINT_keep_a\the\numexpr #1.% +}% +\def\XINT_keep_a #1#2.% +{% + \xint_UDzerominusfork + #1-{\expandafter\space\xint_gobble_i }% + 0#1{\XINT_keep_bneg_a {#2}}% + 0-{\XINT_keep_bpos {#1#2}}% + \krof +}% +\long\def\XINT_keep_bneg_a #1#2% +{% + \expandafter\XINT_keep_bneg_b \the\numexpr \xintLength{#2}-#1.{#2}% +}% +\def\XINT_keep_bneg_b #1#2.% +{% + \xint_UDzerominusfork + #1-{\xint_firstofone_thenstop }% + 0#1{\xint_firstofone_thenstop }% + 0-{\XINT_trim_bpos {#1#2}}% + \krof +}% +\long\def\XINT_keep_bpos #1#2% +{% + \XINT_keep_loop_a {#1}{}#2\xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_bye +}% +\def\XINT_keep_loop_a #1% +{% + \ifnum #1>\xint_c_vi + \expandafter\XINT_keep_loop_b + \else + \XINT_keep_finish + \fi + {#1}% +}% +\long\def\XINT_keep_loop_b #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_xint_relax #9\XINT_keep_enda\xint_relax + \expandafter\XINT_keep_loop_c\expandafter{\the\numexpr #1-\xint_c_vii}% + {{#3}{#4}{#5}{#6}{#7}{#8}{#9}}{#2}% +}% +\long\def\XINT_keep_loop_c #1#2#3{\XINT_keep_loop_a {#1}{#3#2}}% +\long\def\XINT_keep_enda\xint_relax + \expandafter\XINT_keep_loop_c\expandafter #1#2#3#4\xint_bye +{% + \XINT_keep_endb #4\W\W\W\W\W\W\Z #2{#3}% +}% +\def\XINT_keep_endb #1#2#3#4#5#6#7\Z +{% + \xint_gob_til_W + #1\XINT_keep_endc_ + #2\XINT_keep_endc_i + #3\XINT_keep_endc_ii + #4\XINT_keep_endc_iii + #5\XINT_keep_endc_iv + #6\XINT_keep_endc_v + \W\XINT_keep_endc_vi\Z +}% +\long\def\XINT_keep_endc_ #1\Z #2#3#4#5#6#7#8#9{ #9}% +\long\def\XINT_keep_endc_i #1\Z #2#3#4#5#6#7#8#9{ #9{#2}}% +\long\def\XINT_keep_endc_ii #1\Z #2#3#4#5#6#7#8#9{ #9{#2}{#3}}% +\long\def\XINT_keep_endc_iii #1\Z #2#3#4#5#6#7#8#9{ #9{#2}{#3}{#4}}% +\long\def\XINT_keep_endc_iv #1\Z #2#3#4#5#6#7#8#9{ #9{#2}{#3}{#4}{#5}}% +\long\def\XINT_keep_endc_v #1\Z #2#3#4#5#6#7#8#9{ #9{#2}{#3}{#4}{#5}{#6}}% +\long\def\XINT_keep_endc_vi\Z #1#2#3#4#5#6#7#8{ #8{#1}{#2}{#3}{#4}{#5}{#6}}% +\long\def\XINT_keep_finish\fi #1#2#3#4#5#6#7#8#9\xint_bye +{% + \fi\XINT_keep_finish_loop_a {#1}{}{#3}{#4}{#5}{#6}{#7}{#8}\Z {#2}% +}% +\def\XINT_keep_finish_loop_a #1% +{% + \xint_gob_til_zero #1\XINT_keep_finish_z0% + \expandafter\XINT_keep_finish_loop_b\expandafter + {\the\numexpr #1-\xint_c_i}% +}% +\long\def\XINT_keep_finish_z0% + \expandafter\XINT_keep_finish_loop_b\expandafter #1#2#3\Z #4{ #4#2}% +\long\def\XINT_keep_finish_loop_b #1#2#3% +{% + \xint_gob_til_xint_relax #3\XINT_keep_finish_exit\xint_relax + \XINT_keep_finish_loop_c {#1}{#2}{#3}% +}% +\long\def\XINT_keep_finish_exit\xint_relax + \XINT_keep_finish_loop_c #1#2#3\Z #4{ #4#2}% +\long\def\XINT_keep_finish_loop_c #1#2#3% + {\XINT_keep_finish_loop_a {#1}{#2{#3}}}% +\def\xintTrim {\romannumeral0\xinttrim }% +\def\xintTrimNoExpand {\romannumeral0\xinttrimnoexpand }% +\def\xinttrim #1#2% +{% + \expandafter\XINT_trim_a\the\numexpr #1\expandafter.% + \expandafter{\romannumeral-`0#2}% +}% +\def\xinttrimnoexpand #1% +{% + \expandafter\XINT_trim_a\the\numexpr #1.% +}% +\def\XINT_trim_a #1#2.% +{% + \xint_UDzerominusfork + #1-{\xint_firstofone_thenstop }% + 0#1{\XINT_trim_bneg_a {#2}}% + 0-{\XINT_trim_bpos {#1#2}}% + \krof +}% +\long\def\XINT_trim_bneg_a #1#2% +{% + \expandafter\XINT_trim_bneg_b \the\numexpr \xintLength{#2}-#1.{#2}% +}% +\def\XINT_trim_bneg_b #1#2.% +{% + \xint_UDzerominusfork + #1-{\expandafter\space\xint_gobble_i }% + 0#1{\expandafter\space\xint_gobble_i }% + 0-{\XINT_keep_bpos {#1#2}}% + \krof +}% +\long\def\XINT_trim_bpos #1#2% +{% + \XINT_trim_loop_a {#1}#2\xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye +}% +\def\XINT_trim_loop_a #1% +{% + \ifnum #1>\xint_c_vii + \expandafter\XINT_trim_loop_b + \else + \XINT_trim_finish + \fi + {#1}% +}% +\long\def\XINT_trim_loop_b #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_xint_relax #9\XINT_trim_silentend\xint_relax + \expandafter\XINT_trim_loop_a\expandafter{\the\numexpr #1-\xint_c_viii}% +}% +\def\XINT_trim_silentend #1\xint_bye { }% +\def\XINT_trim_finish\fi #1% +{% + \fi\expandafter\expandafter\expandafter\XINT_trim_finish_a + \expandafter\expandafter\expandafter\space % avoids brace removal + \csname xint_gobble_\romannumeral\numexpr#1\endcsname +}% +\long\def\XINT_trim_finish_a #1\xint_relax #2\xint_bye {#1}% \def\xintApply {\romannumeral0\xintapply }% \def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }% \long\def\xintapply #1#2% |