summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils/gmbase.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-14 23:19:42 +0000
committerKarl Berry <karl@freefriends.org>2011-10-14 23:19:42 +0000
commit156a2b3e555456a90baac12411ebd5fcc7b9ef02 (patch)
tree3cf17f72769c1e200486df29e8d3b593feee7637 /Master/texmf-dist/tex/latex/gmutils/gmbase.sty
parent000e5fcea9de9a48217705874f01a84133ddb70d (diff)
gmutils (14oct11)
git-svn-id: svn://tug.org/texlive/trunk@24287 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils/gmbase.sty')
-rw-r--r--Master/texmf-dist/tex/latex/gmutils/gmbase.sty272
1 files changed, 221 insertions, 51 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmbase.sty b/Master/texmf-dist/tex/latex/gmutils/gmbase.sty
index ecc0542281f..23bd9ebb16a 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.297 2011/02/02 18:13:11 natror Exp natror $
+%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $
%% This is file “gmbase.sty” generated with the DocStrip utility.
%%
%%
@@ -13,7 +13,7 @@
%%
%% Copyright ©
%% by Grzegorz ‘Natror’ Murzynowski
-%% natror (at) o2 (dot) pl
+%% natror (at) gmail (dot) com
%%
%% This program is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
@@ -23,19 +23,21 @@
%%
%%
%%
-%% For the documentation please refer to the file(s)
+%% For documentation please refer to the file(s)
%% gmutils.{gmd,pdf}.
%%
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmbase}
- [2010/10/24 v0.993 some tricky low-level macros (GM)]
+ [2011/10/12 v0.996 some low-level macros (GM)]
%%
%%
%% ^^A\typeout{\unexpanded{#4}}%%
+\RequirePackage {expl3, xparse} % because it's used anyway: by
+
\ifx\XeTeXversion\relax
\let\XeTeXversion\@undefined% If someone earlier used
\fi
@@ -88,7 +90,7 @@
\strip@bslash{#1}%
}
-\long\def\@xanxcs#1{%
+\long\def\@xanxcs #1{%
\ifcat\@nx~\@nx#1%
\@nx#1%
\else
@@ -96,6 +98,10 @@
\fi
}
+\long\def\@xanxcssimple #1{%
+ \@xa\@nx\csname #1\endcsname
+}
+
\long\def\@xaucs#1{%
\unexpanded\@xa\@xa\@xa{\csname #1\endcsname}%
}
@@ -113,6 +119,23 @@
\def\lpdef{\long\protected\def}
\let\pldef\lpdef
+\long\def\gmu@ifdefinable
+#1% a \CS
+{%
+ \ifx #1\@undefined
+ \@xa \@firstoftwo
+ \else
+ \@xa\@secondoftwo
+ \fi
+ {\@firstoftwo}%
+ {\ifx #1\relax
+ \@xa\@firstoftwo
+ \else
+ \@xa \@secondoftwo
+ \fi
+ }%
+}
+
\def\pedef{\protected\edef}
\def\pxdef{\protected\xdef}
@@ -134,7 +157,8 @@
\long\def\gmu@gobdef#1#{% \UnDef
\def\gmu@tempa{}% it's a~junk |\def|-assignment
% to absorb possible prefixes.
- \@gobble}
+ \@gobble
+}
\def\pprovide{\protected\provide}
@@ -148,15 +172,27 @@
\fi
}
+\newcommand\newdef % sort of newcommand that accepts prefixes.
+[1]%
+{%
+ \gmu@ifdefinable #1%
+ {\pdef #1}
+ {%
+ \PackageError {gmbase} {\@nx#1 already defined.}{}%
+ \gmu@gobdef
+ }%
+}
+
+\protected\newdef \pnew {%
+ \protected\newdef
+}
-\long\def\gmu@if#1#2{%
- \ifnum\strcmp{incsname}{\detokenize{#1}}=\z@
- \@xa\@xa\@xa\ifincsname
- \@gobble\fi % this |\fi| balances the conditional when false
- \else
- \csname if#1\@xa\endcsname
+
+\long\def\gmu@if #1#2{%
+ \csname if#1\endcsname #2%
+ \@xa\@firstoftwo
+ \else\@xa\@secondoftwo
\fi
- #2\@xa\@firstoftwo\else\@xa\@secondoftwo\fi
}
\long\def\gmu@notif#1#2{%
@@ -167,15 +203,21 @@
\def\gmu@ifsw #1{\gmu@if {#1}{}}
\def\gmu@notsw #1{\gmu@notif {#1}{}}
+\def \gmu@ifincsname
+{%
+ \ifincsname
+ \@xa\@firstoftwo
+ \else
+ \@xa\@secondoftwo
+ \fi
+}
+
\long\def\gmu@unless #1#2{%
- \ifnum\strcmp{incsname}{\detokenize{#1}}=\z@
- \@xa\@xa\@xa\unless \@xa\@xa\@xa\ifincsname
- \@gobble\fi % this |\fi| balances the conditional when it's not
- % |\ifincsname|
+ \@xa\unless \csname if#1\endcsname #2%
+ \@xa\@firstoftwo
\else
- \@xa\unless \csname if#1\@xa\endcsname
+ \@xa\@secondoftwo
\fi
- #2\@xa\@firstoftwo\else\@xa\@secondoftwo\fi
}
@@ -314,16 +356,16 @@
\def\fooatletter{\foone\makeatletter}
\newcommand*\@emptify[1]{\let#1=\@empty}
-\@ifdefinable\emptify{\let\emptify\@emptify}
+\gmu@ifdefinable\emptify{\let\emptify\@emptify}
\newcommand*\g@emptify{\global\@emptify}
-\@ifdefinable\gemptify{\let\gemptify\g@emptify}
+\gmu@ifdefinable\gemptify{\let\gemptify\g@emptify}
\newcommand\@relaxen[1]{\let#1=\relax}
-\@ifdefinable\relaxen{\let\relaxen\@relaxen}
+\gmu@ifdefinable\relaxen{\let\relaxen\@relaxen}
\newcommand*\g@relaxen{\global\@relaxen}
-\@ifdefinable\grelaxen{\let\grelaxen\g@relaxen}
+\gmu@ifdefinable\grelaxen{\let\grelaxen\g@relaxen}
\long\def\gmu@ifempty#1{%\
\ifnum\strcmp{\detokenize{#1}}{}=\z@
@@ -343,18 +385,17 @@
\fi
}
-\long\pdef\IfAmong#1\among#2{%\label{IfAmong}\
- % \begin{enumargs}
- % \item the token(s) whose presence we check,
- % \item the list of tokens in which we search |#1|,
- % \item the ‘if found’ stuff,
- % \item the ‘if not found’ stuff.
- % \end{enumargs}
+\long\pdef\IfAmong
+#1% the token(s) whose presence we check,
+\among % delimiter of |#1|
+#2% the list of tokens in which we search |#1|,
+{%\label{IfAmong}
% \chgs{2008/12/05 v0.98 split from \cs{IfAmong}}
%
\long\def\gmu@among@##1#1##2\gmu@among@{%
\gmu@ifempty{##2}\@secondoftwo\@firstoftwo}%
- \gmu@among@#2#1\gmu@among@}
+ \gmu@among@#2#1\gmu@among@
+}
\newif\ifgmu@ifquant
@@ -618,11 +659,6 @@
% applied to |#1|. Therefore it turns true for |#1| being e.g.\ primitive
% \TeX's skip registers and |#2|==|\skip|.
{%
- \PackageInfo{gmbase}{^^J%
- Checking whether ***\string#1*** is a ***\string #2***^^J
- If the next message you get is an error^^J%
- ***missing number treated as 0***,^^J
- then it's probably not^^J}%
\@tempswafalse
%
\gmu@CASE x{\defNoHash#2}%
@@ -1235,7 +1271,7 @@
\ifincsname\xiiunder
\else
\ifmmode\subs
- \else\_%
+ \else\xiiunder %
\fi
\fi}}}% We define it as \inverb|\_| not just as
\foone{\catcode`\!=0
@@ -1284,6 +1320,10 @@
\edef#1{\unexpanded{#2}}%
}
+\long\pdef\xdefU#1#2{%
+ \xdef#1{\unexpanded{#2}}%
+}
+
\long\pdef\@ifnextcat#1#2#3{%
\edefU\reserved@d{#1}%
\edefU\reserved@a{#2}%
@@ -1398,14 +1438,17 @@
\@ifnextnotgroup{#2}{#1}}
\pdef\ignoreactiveM{%
- \@ifnextgroup{}{\gmu@checkM}}
+ \@ifnextgroup{}{\gmu@checkM}%
+}
\foone\obeylines{% we know it's a~single token since we use this macro
% only in \incmd\@ifnextgroup's ‘else’.
\long\pdef\gmu@checkM#1{%
\ifx
#1\@xa\ignoreactiveM%
- \else\@xa#1\fi}}
+ \else\@xa#1\fi %
+ }%
+}
\let\gmu@reserveda\*%
\def\*{%
@@ -1524,7 +1567,7 @@
\afterassignment\gmu@ifna@resa
\let\gmu@drain=
}%
- {% else we perform |\gmu@ifnextany|
+ {% else we perform |\gmu@ifnextanyIS|
\gmu@ifxany{\@let@token}{#1}{%
\gmu@ifnextStrXany {#1}{#2}{#3}%
}%
@@ -1900,10 +1943,12 @@
\def\@ifXeTeX{% two-argument command
\ifdefined\XeTeXversion
\unless\ifx\XeTeXversion\relax\afterfifi\@firstoftwo\else\afterfifi\@secondoftwo\fi
- \else\afterfi\@secondoftwo\fi}
+ \else\afterfi\@secondoftwo\fi
+}
+
-\def\XeTeXifprefix{% to be used as prefix to an |\if›…| test.
- \@ifXeTeX{}{\unless}}
+\newif\ifgmuXeTeX
+\@ifXeTeX{\gmuXeTeXtrue}{}%
\@ifXeTeX{%
@@ -2346,7 +2391,7 @@
\@xa\@firstoftwo
\else\@xa\@secondoftwo
\fi
-}
+}% of |\gmu@ifskip|.
\def\gmu@ifbox
#1% a box register number (e.g.~|\copy\z@|)
@@ -2438,10 +2483,7 @@
#2% parameters string
#3% definition's body
{%
- \def#1#2{%
- \gmu@if {incsname}{}%
- {\string#1}{#3}%
- }%
+ \def#1#2{\gmu@ifincsname {\string#1}{#3}}%
}
@@ -2475,12 +2517,25 @@
{%
\gmu@CountTokens{#2}%
\gmu@if {num}{\c@gmu@TokensCount=\@ne}%
- {\gmu@if x{#2 }%
- \@secondoftwo\@firstoftwo}%
+ {\gmu@if x{#2 }% if |#2| is single token of blank space then we
+ % don't consider it single since it can't be an
+ % argument to a macro if without braces.
+ \@secondoftwo\@firstoftwo
+ }%
\@secondoftwo
{#1#2}{#1{{#2}}}%
}% of |\gmu@passbraced|
+\long\def\gmu@passbracedNotSp
+#1% the stuff to be put before |#2|
+#2% the stuff we check and pass unbraced if single or braced otherwise
+{%
+ \gmu@CountTokens{#2}%
+ \gmu@if {num}{\c@gmu@TokensCount=\@ne}%
+ {#1{#2}}%
+ {#1{{#2}}}%
+}% of |\gmu@passbracedNotSp|
+
\long\def\MeaningOrUnex#1{%
\gmu@if {singletoken}{{#1}}%
{\meaning#1}{\unexpanded{#1}}%
@@ -2500,6 +2555,8 @@
\@iwru{»\unexpanded{#1}« is »\MeaningOrUnex{#1}«}%
}
+\pldef\@iwruU #1{\@iwru{\unexpanded{#1}}}
+
\pldef\@iwruif#1{%
\gmu@if {gmu@debug@msgs}{}
{\@iwru{#1}}{}%
@@ -2621,7 +2678,7 @@
{%
\ifnum
\gmu@ifQUANT@iter
- 0% for the General Quantifier 0 terminates calculation (a
+ 0% for the General Quantifier 0 terminates calculation (when a
% counter-example has just been found)
1% To make any calculation sense we assume 1 at the beginning
#1
@@ -2649,6 +2706,11 @@
\long\def\@sN #1 {\csname #1\endcsname}
\long\def\@sdN #1 {\csname \detokenize{#1}\endcsname}
+
+\pdef\clap #1{\hbox to \z@{\hss #1\hss}}
+
+\pdef\hsizecline #1{\hbox to\hsize{\hss #1\hss}}
+
\long\def\gmu@extreme
#1% kind of test (|num| or |dim|)
#2% inequality sign: |<| for minimum, |>| for maximum.
@@ -2875,6 +2937,114 @@
\def\hrule@zero{\hrule height\z@ width\z@ depth\z@}
+\pdef \protected@nil {}
+\let\protected@empty\protected@nil
+
+\ifgmuXeTeX
+
+ % 2011/02/03, 12.53 definitions of the macros for combinig
+
+ \def\gmu@nobound
+ #1% a~char
+ #2% bound number
+ {%
+ \gmu@unless {}
+ {0%
+ \gmu@if {num}{#2=\@ne }{0}{}%
+ \gmu@if {num}{#2=13 } {0}{}%
+ 1}
+ {}
+ {%
+ \leavevmode
+ \kern -\glyphbound #1 1%
+ }%
+ #1%
+ \gmu@unless {}
+ {0%
+ \gmu@if {num}{#2=\thr@@ }{0}{}%
+ \gmu@if {num}{#2=13 }{0}{}%
+ 1}
+ {}
+ {%
+ \kern -\glyphbound #1 3%
+ }%
+ }
+
+ \def\glyphbound
+ #1% char (name)
+ #2% number of the bound
+ {%
+ \XeTeXglyphbounds #2 \XeTeXglyphindex "#1"
+ }
+
+ \def\gmu@halfcomb
+ #1% the “basic” char
+ #2% the accent char
+ #3% emergency [\pk{fontspec}] font spec
+ {%
+ #1\kern-\gmu@halfwd #1%
+ \clap{%
+ \gmu@unless {fontchar}{\font `#2 }
+ {#3}{}%
+ #2}%
+ \kern\gmu@halfwd #1%
+ }
+
+ \def\gmu@halfwd#1{0,45\fontcharwd\font`#1 }
+
+ \def\gmu@llapcomb
+ #1% the “basic” char
+ #2% the accent char
+ #3% emergency [\pk{fontspec}] font spec
+ {%
+ \gmu@nobound #13%
+ \llap{%
+ \gmu@unless {fontchar}{\font `#2 }
+ {#3}{}%
+ #2}%
+ \kern \XeTeXglyphbounds 3 \XeTeXglyphindex "#1"
+ }
+
+\fi % of if \XeTeX
+
+\pdef\@rmfromreset
+#1% counter to be freed, e.g., |figure|,
+#2% counter from whose power we free |#1|, e.g., |chapter|.
+{%
+ {%
+ \def\@elt ##1{%
+ \gmu@ifdetokens{#1}{##1}%
+ {}% then we remove the element, otherwise
+ {\@nx\@elt {##1}}%
+ }%
+ %
+ \Name\xdef{cl@#2}{\csname cl@#2\endcsname}%
+ }%
+}
+
+
+\long\def \gmu@iflist {%
+ % |#1| (implicit) what if in a list environment
+ % |#2| (implicit) what if not in a list env.
+ \ifnum \@listdepth>\z@
+ \@xa\@firstoftwo
+ \else
+ \@xa\@secondoftwo
+ \fi
+}
+
+\foone {\@makeother \^^I }{%
+ \def\xiitab{^^I}%
+}
+
+\foone {\catcode 9=\active } {%
+ % Totally perverse, but seems to be useful with DocStrip.
+ \def\gmu@maketabtab {%
+ \def ^^I{\xiitab}%
+ }%
+}
+
+
\endinput
%%
%% End of file `gmbase.sty'.