diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils/gmbase.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/gmutils/gmbase.sty | 304 |
1 files changed, 230 insertions, 74 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmbase.sty b/Master/texmf-dist/tex/latex/gmutils/gmbase.sty index 9e0bba08753..ecc0542281f 100644 --- a/Master/texmf-dist/tex/latex/gmutils/gmbase.sty +++ b/Master/texmf-dist/tex/latex/gmutils/gmbase.sty @@ -2,7 +2,7 @@ %% \iffalse ^^A we skip the debug setting \IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} %% \fi -%% ^^A $Id: TheUltimateMaster.gmd,v 0.250 2010/10/24 14:42:35 natror Exp natror $ +%% ^^A $Id: TheUltimateMaster.gmd,v 0.297 2011/02/02 18:13:11 natror Exp natror $ %% This is file “gmbase.sty” generated with the DocStrip utility. %% %% @@ -44,6 +44,10 @@ \XeTeXinputencoding utf-8 % we use Unicode dashes later in this file. \fi% and if we are not in \XeTeX, we skip them thanks to \XeTeX-test. +\unless\ifdefined\strcmp + \let\strcmp\pdfstrcmp +\fi + \let\@xa\expandafter \let\@nx\noexpand @@ -68,14 +72,14 @@ {\string#1}% if |#1| is active {% \@xa\@xa\@xa\ifnum\@xa\@xa\@xa\escapechar - \@xa\@xa\@xa=\@xa\@xa\@xa`\@xa\gmu@firstandspace - \string#1\else\string#1\fi + \@xa\@xa\@xa=\@xa\@xa\@xa`\@xa\gmu@firstandspace + \string#1\@xa\@gobble + \else\@xa\@firstofone \fi + {\string#1}% }% if |#1| is not active }% of if |#1| not empty } - - \long\def\bslash@or@ac#1{% \ifcat\@nx~\@nx#1% \else @@ -144,6 +148,7 @@ \fi } + \long\def\gmu@if#1#2{% \ifnum\strcmp{incsname}{\detokenize{#1}}=\z@ \@xa\@xa\@xa\ifincsname @@ -286,6 +291,10 @@ \long\def\@allbutfirstof#1#2\@nil{#2} +\long\def\@firstthensecond #1#2{#1#2} % Note this macro strips braces + % if present. +\long\def\@secondthenfirst #1#2{#2#1} % Note as above. + \def\longafterfi{% @@ -347,8 +356,7 @@ \gmu@ifempty{##2}\@secondoftwo\@firstoftwo}% \gmu@among@#2#1\gmu@among@} -\newif\ifgmu@ifxquant -\newtoks\gmu@ifxa@toks +\newif\ifgmu@ifquant \long\pdef\gmu@ifxany #1% a single token to be |\ifx| ed with each of |#2| @@ -358,14 +366,14 @@ % we wrap the iteration over |#2|'s tokens in |\gmu@ifempty| because % we expect many empty |#2|'s in |\DeclareCommand|'s |\loop| % arguments (such as |Q| and |U|) - \gmu@ifxquantfalse + \gmu@ifquantfalse \let\gmu@ifxa@aasiter\@@gmu@ifxa@aasiter % \edef\gmu@ifxa@aas{% edef and unexpanded to protect agains % |#|\cat6 token(s) in |#1|. \unexpanded{% \ifx #1\gmu@ifxa@token - \gmu@ifxquanttrue + \gmu@ifquanttrue \let\gmu@ifxa@aas\gmu@ifxa@drainer \else \ifx \gmu@ifxa@Limit\gmu@ifxa@token @@ -376,8 +384,8 @@ }%of |\unexpanded| }% of |\gmu@ifxa@aas| % - \gmu@ifxa@aasiter #2\gmu@ifxa@Limit - \gmu@if {gmu@ifxquant}{}% + \gmu@ifxa@aasiter #2\gmu@ifa@PreLimit\gmu@ifxa@Limit + \gmu@if {gmu@ifquant}{}% }% of if |#2| nonempty } @@ -388,7 +396,8 @@ \gmu@ifxa@aasiter } -\gmu@DefSymbol\gmu@ifxa@Limit +\gmu@DefSymbol \gmu@ifa@PreLimit +\gmu@DefSymbol \gmu@ifxa@Limit \def\@@gmu@ifxa@aasiter{% \afterassignment\gmu@ifxa@aas @@ -401,6 +410,7 @@ \gmu@ifxany{#1}{#2}\@secondoftwo\@firstoftwo } + \long\def\gmu@foreach#1\gmu@foreach@delim#2{% % \long\def\gmu@forer##1{% @@ -570,7 +580,6 @@ \gmu@DefSymbol\defNoHash \gmu@DefSymbol\defHashy \gmu@DefSymbol\boolean -\gmu@DefSymbol\edim \def\gmu@geteschar{% % A macro that edefines detokenised char of the charcode |\escapechar| @@ -651,7 +660,7 @@ % }% of case Boolean % - \gmu@CASEstrany #2{\dimexpr \numexpr \glueexpr \edim}% + \gmu@CASEstrany #2{\dimexpr \numexpr \glueexpr }% {% case \eTeX\ expression \@tempswatrue \def\gmu@IfIs@resa{% if should be a macro expanding to @@ -1002,17 +1011,12 @@ \long\def\IfIsExpression #1% the stuff to be examined -#2% |\dimexpr|, |\glueexpr|, |\numexpr| or |\muexpr| or |\edim| (added +#2% |\dimexpr|, |\glueexpr|, |\numexpr| or |\muexpr| {% \ifx#2\numexpr\let\next\@tempcnta\fi \ifx#2\glueexpr\let\next\@tempskipa\fi \ifx#2\dimexpr\let\next\@tempdima\fi \ifx#2\muexpr\let\next\@tempmuskipa\fi - \gmu@if {strings} {#2\edim} % in case of special (not necessarily - % defined) \CS\ |\edim| we gobble the - % |=\edim| tokens and put |\dimexpr| - % before the tested token. - {\def\next##1##2{\@tempdima=\dimexpr}}{}% \afterassignment\gmu@testtopenalty \next=#2#1\penalty } @@ -1081,13 +1085,30 @@ \lpdef\addtotoks#1#2{% #1=\@xa{\the#1#2}} -\lpdef\prependtotoks#1#2{% +\newtoks\gmu@prependtoks@aux + +\lpdef\gmu@prependtotoks@ambig +#1% scope +#2% toks register +#3% text of prependement +{% \iffalse {\fi % hack to balance braces in definition \@XA{% - #1=\bgroup#2% - }\the#1}% actually this brace closes the text opened by |\bgroup|. + #1#2=\bgroup#3% + }% during execution, this brace closes the |\@XA|'s argument… + \the#2}% and this one closes the text opened by |\bgroup|, i.e., } +\lpdef\prependtotoks +#1% toks register +#2% text to be prepended +{\gmu@prependtotoks@ambig {}{#1}{#2}}% + +\lpdef\gprependtotoks +#1% toks register +#2% text to be prepended +{\gmu@prependtotoks@ambig \global{#1}{#2}}% + \long\def\addto@forlist #1% a comma-separated list #2% the element(s) added @@ -1404,7 +1425,7 @@ }% }% of if |\futurelet| detected a blank space % - \gmu@CASE {condsalt} % if any of the conditions below: + \gmu@CASE {AnyClause} % if any of the conditions below: {{ x {\@let@token\@undefined} x {\@let@token\relax}}} % it's arg of disjunction {\gmu@peep@hash{#1}}% @@ -1475,7 +1496,7 @@ #1% outer macro's tested list of tokens #2% “if found” branch #3% “if not found” branch -{\gmu@notif {condsalt} +{\gmu@notif {AnyClause} {{ x {\@let@token\@undefined} x {\@let@token\relax}}}% {#2}% % @@ -1898,6 +1919,8 @@ } {\def\textbullet{\ensuremath{\bullet}}} +\def\if@XeTeX {\@ifXeTeX {\iftrue}{\iffalse}} + \long\def\detoken@xa#1{\detokenize\@xa{#1}} @@ -1913,7 +1936,7 @@ \def\gmshowlists{% \tracingonline=1 - \showboxdepth=1000 \showboxbreadth=1000 \showlists} + \showboxdepth=1 \showboxbreadth=1000000 \showlists} \def\gmshowbox{% \tracingonline=1 @@ -1922,7 +1945,9 @@ \def\gmtracingoutput{% \tracingoutput\@ne \tracingonline=\@ne - \showboxdepth=10000 \showboxbreadth=10000 } + \showboxdepth=1 + \showboxbreadth=1000000 +} \newif\ifgmu@debug@msgs @@ -1940,6 +1965,7 @@ \tracingmacros\m@ne \tracingassigns=\m@ne \tracingcommands=\m@ne + \tracingoutput=\m@ne \gmu@debug@msgsfalse \let\let\let } @@ -2541,54 +2567,77 @@ }% } -\long\def\condsalt -#1% a sequence of conditionals' names without »if« followed by the condition -{% - \numexpr \condsalt@iter 0 #1 {}{}\gmu@delim % -} -\long\def\condsalt@iter -#1% expression so far -#2% the name of current conditional (without »if«) -#3% the condition for |#2| -#4% tail of switches +\long\def\gmu@ifQUANT@iter +#1% the (binary) value that terminates calculation: 0 for AND and 1 + % for OR (it has to be a single token due to |\expandafter| in line + % \ref{@xa-in-QUANT}) +#2% the (binary) value so far; +#3% the name of current conditional (without »if«) +#4% the condition for |#2| +#5% tail of condition(al)s \gmu@delim {% - \gmu@ifempty{#4}% - {#1\relax}% |\relax| to close the num expression - {\condsalt@iter - {#1+\csname if#2\endcsname #3 1\else 0\fi}% - #4\gmu@delim + \gmu@ifempty{#5}% + {#2}% + {% or else we check whether |#2| is terminating + \gmu@if {num}{#2=#1 }% with a space + {#1}% + {\@xa\gmu@ifQUANT@iter \@xa #1% \label{@xa-in-QUANT} + \the\numexpr %^^V 1 * % |\numexpr| is used here to get the full + % expansion in one step. No need of superposing with identity. + (\gmu@if {#3}{#4 } {1} {0}) +\z@\relax + #5\gmu@delim + }% }% -} - -\long\def\ifcondsalt #1{% - \ifnum \condsalt{#1}>\z@ -} +}% of |\gmu@ifQUANT@iter|. -\long\def\condsconj -#1% a sequence of conditionals' names without »if« followed by the condition +\long\def \ifAnyClause +#1{% + \ifnum + \gmu@ifQUANT@iter + 1% for the Existential Quantifier 1 terminates calculation (\emph{an(y)} + % example has just been found) + 0% To make any calculation sense we assume 0 at the beginning + % (i.e., “we haven't found an example yet”) + #1 + {false}{} {false} {}% the sentinel(s) + \gmu@delim % the delimiter + =\@ne % right side of |\Ѻifnum| +} + +\long\def\gmu@OR +#1% as above\\ {% - \numexpr \condsconj@iter 1 #1 {}{}\gmu@delim % + \ifAnyClause {#1}% + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi } -\long\def\condsconj@iter -#1% expression so far -#2% the name of current conditional (without »if«) -#3% the condition for |#2| -#4% tail of condition(al)s -\gmu@delim +\long\def\ifAllClauses +#1% a sequence of pairs \arg{conditionals' name without »if«}{the {% - \gmu@ifempty{#4}% - {#1\relax}% |\relax| to close the num expression - {\condsconj@iter - {#1*\csname if#2\endcsname #3 1\else 0\fi}% - #4\gmu@delim - }% -} - -\long\def\ifcondsconj #1{% - \ifnum \condsconj {#1}>\z@ + \ifnum + \gmu@ifQUANT@iter + 0% for the General Quantifier 0 terminates calculation (a + % counter-example has just been found) + 1% To make any calculation sense we assume 1 at the beginning + #1 + {true}{} {true} {}% the sentinel(s) + \gmu@delim % the delimiter + =\@ne % right side of |\Ѻifnum| +} + +\long\def\gmu@AND +#1% +{% + \ifAllClauses {#1}% + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi } \long\def\sName #1#2 {\@xa#1\csname #2\endcsname} @@ -2687,7 +2736,7 @@ }% } -\do {glue}{11} +\do {glue}{11} \do{skip}{11} \do{kern}{12} \do {penalty}{13} @@ -2701,24 +2750,131 @@ \relax } -\def\falseifdefined #1{% +\def\MakeFalseIfDefined #1{% \ifcsname if#1\endcsname \csn{#1false}% \fi } -\def\trueifdefined #1{% +\def\MakeTrueIfDefined #1{% \ifcsname if#1\endcsname \csn{#1true}% \fi } +\def\gmu@pageremain{\dimexpr + \ifdim\pagegoal=\maxdimen \textheight \else \pagegoal \fi + -\pagetotal + \relax +} + +\def\gmu@GobbleMinus #1{\if-#1\else#1\fi} + +\def\gmu@absExpr +#1% \eTeX's expression primitive, num or dim so far (2010/12/17, 11.46) +#2% expression of respective kind +{% + \@xa\gmu@GobbleMinus\the #1#2\endexpr +} + +\def\gmu@absdim {\gmu@absExpr \dimexpr } +\def\gmu@absnum {\gmu@absExpr \numexpr } + +\pdef\gmu@SetPagegoal #1{% + \gmu@if {dim} {\pagegoal=\maxdimen}% + {}% in this case we do nothing, as explained above + {\pagegoal = \dimexpr (#1)\relax}% +} + +\pdef\gmu@SetPagegoalGlobal #1{% + \gmu@if {dim} {\pagegoal=\maxdimen}% + {}% in this case we do nothing, as explained above + {\global\pagegoal = \dimexpr (#1)\relax}% +} + +\pdef\gmu@AdvancePagegoal #1{% the arg.\ should be a proper stuff for + % a sub-dimexpr (i.a., no spurious |\relax|es are allowed). + \gmu@SetPagegoal {\pagegoal +#1}% +} + +\def\pagegoalortextheight{% as in the name: + \dimexpr + \ifdim \pagegoal=\maxdimen + \textheight + \else \pagegoal + \fi + \relax +} + +\def\gmu@totalht #1{% the arg.\ should be a~box register. + \dimexpr \ht #1+\dp#1\relax +} + +\def\vbadness@M {% + \unless\ifnum\vbadness=\@M + \edef\gmu@VeryBadBadness {\the\vbadness }% + \vbadness\@M + \fi +} + +\def\vbadness@Restore {% + \ifdefined \gmu@VeryBadBadness + \vbadness \gmu@VeryBadBadness \relax + \else + \PackageError{gmbase}{You try to gm-restore \vbadness\space where + it is not gm-stored}{}% + \fi +} + +\relaxen\endexpr + +\relaxen\endrule + +\def\gmu@ifpageodd {% + \ifodd \c@page + \@xa\@firstoftwo + \else + \@xa\@secondoftwo + \fi +} + + +\gmu@DefSymbol\gmu@Fake + +\def\gmu@FakeLoaded +#1% extension +#2% name +{\ifcsname ver@#2.#1\endcsname + \@xa\ifx\csname ver@#2.#1\endcsname \relax + \@xa\@xa\@xa \@firstofone + \else + \@xa\@xa\@xa \@gobble + \fi + \else + \@xa\@firstofone + \fi + {\Name\def {ver@#2.#1}{\gmu@Fake }}% +} + +\def\gmu@FakeUnloaded +#1% extension +#2% name +{\ifcsname ver@#2.#1\endcsname + \@xa\ifx\csname ver@#2.#1\endcsname\gmu@Fake + \Name\let {ver@#2.#1}\@undefined + \fi + \fi +} + +\pdef\LoadPackagePolski {% + \gmu@FakeLoaded \@pkgextension {inputenc}% + \RequirePackage {polski}% + \gmu@FakeUnloaded \@pkgextension {inputenc}% +} + +\def\hrule@zero{\hrule height\z@ width\z@ depth\z@} + -%%% (For my GNU Emacs:) -%%% Local Variables: -%%% mode: doctex -%%% coding: utf-8 -%%% End: \endinput %% %% End of file `gmbase.sty'. |