summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/bidi/biditools.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-09-27 23:11:27 +0000
committerKarl Berry <karl@freefriends.org>2017-09-27 23:11:27 +0000
commitdb56c4feabb30fa1c384abcac1ee691025ebbb2b (patch)
treee0147ec674f69186f61aaab08d17c227692763ff /Master/texmf-dist/tex/xelatex/bidi/biditools.sty
parent5727b466108fe7f0d34dbcc3daddfab7a18dfe6d (diff)
bidi (26sep17)
git-svn-id: svn://tug.org/texlive/trunk@45419 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/bidi/biditools.sty')
-rw-r--r--Master/texmf-dist/tex/xelatex/bidi/biditools.sty210
1 files changed, 208 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/xelatex/bidi/biditools.sty b/Master/texmf-dist/tex/xelatex/bidi/biditools.sty
index 904ff08180a..04247c28d40 100644
--- a/Master/texmf-dist/tex/xelatex/bidi/biditools.sty
+++ b/Master/texmf-dist/tex/xelatex/bidi/biditools.sty
@@ -17,7 +17,7 @@
%% by Vafa Khalighi.
%%
%%
-%% \CheckSum{48388}
+%% \CheckSum{49112}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -35,7 +35,7 @@
%% Right brace \} Tilde \~}
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{biditools}[2017/09/19 v1.0 Programming tools for bidi package]
+\ProvidesPackage{biditools}[2017/09/26 v1.1 Programming tools for bidi package]
\providecommand{\@bidi@saveprimitive}[2]{\begingroup\escapechar`\\\relax
\edef\@tempa{\string#1}\edef\@tempb{\meaning#1}%
\ifx\@tempa\@tempb \global\let#2#1%
@@ -732,6 +732,212 @@ ill-advised in the old versions of bidi package.%
Patching '\string\end' failed!\MessageBreak
'\string\bidi@AfterEndEnvironment' will not work\@gobble}}
+\chardef\bidi@backslash`\\
+\def\bidics#1{\texttt{\char\bidi@backslash#1}}
+
+\newcount\bidi@tempcountb
+\newtoks\bidi@temptoksa
+\newtoks\bidi@temptoksb
+
+\def\bidi@storecatcode#1%
+ {\escapechar\m@ne
+ \bidi@csarg\edef{bidi@restorecatcode\string#1}%
+ {\catcode`\string#1=
+ \the\catcode\expandafter`\string#1}%
+ \catcode\expandafter`\string#1=12\relax
+ \escapechar`\\\relax}
+\def\bidi@restorecatcode#1%
+ {\escapechar\m@ne
+ \csname bidi@restorecatcode\string#1\endcsname
+ \escapechar`\\\relax}
+
+\def\bidi@csname#1{\expandafter\noexpand\csname#1\endcsname}
+
+\def\bidi@csarg#1#2{\expandafter#1\csname#2\endcsname}
+
+\def\bidi@pickescape#1{\ifnum`#1=\escapechar\else#1\fi}
+
+\def\bidi@EqualString#1#2{00\fi\def\bidi@eqs@a{#1}\def\bidi@eqs@b{#2}%
+ \ifx\bidi@eqs@a\bidi@eqs@b}
+
+\def\bidi@EqualStringX#1#2{00\fi
+ \csname if\@bidi@EqualStringX#1&$#2&$\endcsname}
+\def\@bidi@EqualStringX#1#2$#3#4${\ifx#1#3%
+ \ifx#1&true\else\bidi@hop@ES\@bidi@EqualStringX#2$#4$\fi
+ \else false\fi}
+\def\bidi@hop@ES#1\fi#2\fi{\fi\fi#1}
+
+{\catcode0=12 \catcode255=12 \catcode127=12
+\gdef\bidi@StringBeforeNC#1#2{00\fi
+ \bidi@CharsBefore#1^^@^^?#2^^ff^^?}
+\gdef\bidi@CharsBeforeNC#1#2^^?#3#4^^?{%
+ \ifcat#1\relax\def\bidi@next{\bidi@CharsBefore#2^^@^^?#3#4^^ff^^?}%
+ \else\ifcat#3\relax\def\bidi@next{\bidi@CharsBefore#1#2^^@^^?#4^^ff^^?}%
+ \else\ifnum\lccode`#1<\lccode`#3
+ \def\bidi@next{\csname iftrue\endcsname}%
+ \else\ifnum\lccode`#1>\lccode`#3
+ \def\bidi@next{\csname iffalse\endcsname}%
+ \else\def\bidi@next{\bidi@CharsBefore#2^^?#4^^?}%
+ \fi \fi \fi \fi
+ \bidi@next}
+\gdef\bidi@StringBefore#1#2{00\fi
+ \bidi@CharsBefore#1^^@^^?#2^^ff^^?}
+\gdef\bidi@CharsBefore#1#2^^?#3#4^^?{%
+ \ifnum`#1<`#3
+ \def\bidi@next{\csname iftrue\endcsname}%
+ \else\ifnum`#1>`#3
+ \def\bidi@next{\csname iffalse\endcsname}%
+ \else\def\bidi@next{\bidi@CharsBefore#2^^?#4^^?}%
+ \fi\fi
+ \bidi@next}
+}
+
+\def\bidi@empty{}
+\def\bidi@ifempty#1{00\fi\expandafter\ifx\csname bidi@#1@null\endcsname\bidi@@null}
+\def\bidi@ifEmptyX#1{\expandafter\ifx\csname bidi@#1@null\endcsname\bidi@@null}
+\def\bidi@IsEmptyList#1{00\fi\def\bidi@cs@a{#1}\ifx\cs@a\bidi@empty}
+
+\def\bidi@NextChar#1#2#3{00\fi
+ \let\bidi@nxt@ch#1\def\bidi@nxt@a{#2}\def\bidi@nxt@b{#3}%
+ \futurelet\bidi@nxt@c\@bidi@ifnxtc}
+\def\bidi@ifNextChar#1#2#3{%
+ \let\bidi@nxt@ch#1\def\bidi@nxt@a{#2}\def\bidi@nxt@b{#3}%
+ \futurelet\bidi@nxt@c\@bidi@ifnxtc}
+\def\@bidi@ifnxtc{\ifx\bidi@nxt@ch\bidi@nxt@c \expandafter\bidi@nxt@a
+ \else \expandafter\bidi@nxt@b \fi}
+
+\def\bidi@undefinedcs#1{00\fi\bidi@csarg\ifx{#1}\relax}
+
+\newcount\bidi@dummies
+\def\DefNewDummy#1{
+ \if\bidi@undefinedcs{#1}\bidi@csarg\edef{#1}{bidi@dum\the\bidi@dummies}
+ \advance\bidi@dummies\@ne
+ \else
+ \bidi@error{Attempt at second definition of `#1'}
+ \fi}
+
+\let\@bidi@fi\fi \let\endbidi@switch\relax \DefNewDummy{bidi@default}
+\def\bidi@switch@exit #1 \@bidi@fi #2 \endbidi@switch {\fi #1}
+\def\bidi@switch #1#2#3{\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1{#2}\bidi@switch@exit #3 \@bidi@fi
+ \bidi@switch {#1}
+}
+\def\bidi@oswitch #1 in: #2 #3; {\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1{#2}\bidi@switch@exit #3 \@bidi@fi
+ \bidi@switch #1 in:
+}
+\def\bidi@cswitch #1 in: #2 #3; {\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1#2\bidi@switch@exit #3 \@bidi@fi
+ \bidi@cswitch #1 in:
+}
+\def\bidi@bswitch #1 in: #2 #3; {\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1#2 \bidi@switch@exit #3 \@bidi@fi
+ \bidi@bswitch #1 in:
+}
+\def\bidi@mswitch #1 in: #2:#3; {\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1{#2}\bidi@switch@exit #3 \@bidi@fi
+ \bidi@mswitch #1 in:
+}
+\def\bidi@fswitch #1 in: #2:#3; {\bidi@csarg\ifx{#2}\bidi@default\bidi@switch@exit #3 \@bidi@fi
+ #1#2 \bidi@switch@exit #3 \@bidi@fi
+ \bidi@fswitch #1 in:
+}
+
+
+\def\bidi@w@w#1{\if\bidi@undefinedcs{#1}#1\else \the\csname#1\endcsname\fi}
+
+\def\@bidi@ww#1{\if\bidi@undefinedcs{#1}#1\else \csname#1\endcsname \fi}
+
+\newif\ifbidi@in@label
+\def\@bidi@w@w#1{\if\bidi@undefinedcs{#1}#1\else
+ \ifbidi@in@label\noexpand\protect\fi \bidi@csname{#1}\fi}
+\newtoks\bidi@are@these@correct
+\def\bidi@t@w@w#1{%
+ \if\bidi@undefinedcs{#1}#1%
+ \ifdefining\bidi@append@to@list\bidi@are@these@correct{#1 }\fi
+ \else
+ \ifin@label\noexpand\protect\fi \bidi@csname{#1}\fi}
+
+\newtoks\bidi@toks@lista \newtoks\bidi@toks@listb
+\long\def\@bidi@append@to@cslist#1#2#3{\begingroup\bidi@toks@lista=#2{#3}%
+ \global#1=\expandafter\expandafter\expandafter{\expandafter\the\expandafter#1\the\bidi@toks@lista}\endgroup}
+\long\def\@bidi@prepend@to@cslist#1#2#3{\begingroup\bidi@toks@lista=#2{#3}%
+ \global#1=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\bidi@toks@lista\the#1}\endgroup}
+\def\@bidi@append@to@list{\bidi@csarg\@bidi@append@to@cslist}
+\long\def\bidi@append@to@list#1#2{\@bidi@append@to@list{#1}{}{#2}}
+\def\bidi@append@list@to@list#1#2{%
+ \@bidi@append@to@list{#1}{\expandafter\expandafter\expandafter}{\expandafter\the\csname#2\endcsname}}
+\def\bidi@append@cslist@to@cslist#1#2{%
+ \@bidi@append@to@cslist{#1}\expandafter{\the#2}}
+\def\bidi@append@toks@cs@to@list#1#2{\@bidi@append@to@list{#1}\expandafter{\the#2}}
+
+\let\bidi@willbeunhskip\unhskip
+
+\def\NewList:#1 {\bidi@csarg\newtoks{#1}\global\csname#1\endcsname{}}
+\def\EmptyList:#1 {\global\csname#1\endcsname{}}
+\long\def\AppendToList:#1=#2 {\@bidi@append@to@list{#1}{}{#2}}
+\def\TheList:#1 {\let\bidi@oldwbuskip\bidi@willbeunhskip \let\bidi@willbeunhskip\@empty
+ \if\bidi@undefinedcs{#1}\bidi@error{List <#1> undefined}
+ \else\bidi@csarg\the{#1}\fi
+ \let\bidi@willbeunhskip\bidi@oldwbuskip}
+
+\def\bidi@del@tok@from@list#1#2{\begingroup
+ \long\def\bidi@cs@liste##1#2##2\bidi@tok@SM
+ {\bidi@toks@lista{##1}\bidi@toks@listb{##2}%
+ \edef\bidi@cs@listb{\global\bidi@csname{#1}=
+ {\the\bidi@toks@lista\the\bidi@toks@listb}}%
+ \bidi@cs@listb}%
+ \edef\bidi@cs@lista{\noexpand\bidi@cs@liste{}\expandafter\the\csname#1\endcsname\noexpand\bidi@tok@SM}%
+ \bidi@cs@lista \endgroup}
+\def\bidi@in@front@of@list#1{\bidi@csarg{\let\expandafter\bidi@cs@lista}{#1}%
+ \bidi@in@front@of@cslist\bidi@cs@lista}
+\long\def\bidi@in@front@of@cslist#1#2{\begingroup\bidi@toks@lista={#2}%
+ \global#1=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\bidi@toks@lista \the#1}%
+ \endgroup}
+\long\def\bidi@local@in@front@of@list#1#2{\bidi@toks@lista={#2}%
+ \csname#1\endcsname\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+ {\expandafter\expandafter\expandafter\the\expandafter\expandafter\expandafter\bidi@toks@lista
+ \expandafter\the\csname#1\endcsname}%
+ }
+\def\bidi@set@list#1{\bidi@csarg{\let\expandafter\bidi@cs@lista}{#1}%
+ \bidi@set@cslist\bidi@cs@lista}
+\long\def\bidi@set@cslist#1#2{\begingroup\bidi@toks@lista={#2}%
+ \global#1=\expandafter{\the\bidi@toks@lista}\endgroup}
+
+%%%%%%%%%%%%%%%% Stack macros
+\def\bidi@push@cs@onto@cs#1#2{\@bidi@prepend@to@cslist#1\expandafter{\expandafter\\\expandafter{\the#2}}}
+\def\bidi@push@onto#1{\bidi@csarg\bidi@push@onto@cs{#1}}
+\def\bidi@push@onto@cs#1#2{\@bidi@prepend@to@cslist#1{}{\\{#2}}}
+\def\bidi@local@push@onto#1#2{\let\\=\relax
+ \bidi@local@in@front@of@list{#1}{\\{#2}}}
+\def\bidi@pop@cs@into#1#2{\edef\bidi@cs@e
+ {\noexpand\@@bidi@popinto\noexpand#1\noexpand#2\the#2\noexpand\@@bidi@pop}\bidi@cs@e}
+\def\bidi@pop@into#1#2{\edef\bidi@cs@e
+ {\noexpand\@@bidi@popinto\bidi@csname{#1}\bidi@csname{#2}\bidi@csarg\the{#2}\noexpand\@@bidi@pop}\bidi@cs@e}
+\long\def\@@bidi@popinto#1#2\\#3#4\@@bidi@pop{#1{#3}#2{#4}}
+\def\bidi@copy@stacktop#1#2{%
+ \edef\bidi@cs@e{\noexpand\@bidi@copy@stacktop
+ {#1}\bidi@csarg\the{#2}\noexpand\@@bidi@pop}%
+ \bidi@cs@e}
+\def\@bidi@copy@stacktop#1\\#2#3\@@bidi@pop{\csname#1\endcsname#2\relax}
+\newcount\bidi@stack@length \newtoks\bidi@empty@stack \bidi@empty@stack{\\{}}
+\def\bidi@length@of@stack#1{\bidi@csarg\bidi@length@of@csstack{#1}}
+\def\bidi@length@of@csstack#1{\def\\##1{\advance\bidi@stack@length\@ne}%
+ \bidi@stack@length\m@ne \the#1}
+\def\bidi@invert@csstack#1{\bidi@length@of@csstack{#1}%
+ \bidi@tempcountb\z@ \bidi@temptoksa\bidi@empty@stack
+ \loop\ifnum\bidi@tempcountb<\bidi@stack@length
+ \bidi@pop@cs@into\bidi@temptoksb#1\advance\bidi@stack@length\m@ne
+ \bidi@push@cs@onto@cs\bidi@temptoksa\bidi@temptoksb
+ \repeat% copy b to a
+ #1\bidi@temptoksa \bidi@temptoksa\bidi@empty@toks}
+\def\bidi@x@stack@to@list#1{\bidi@length@of@stack{#1}%
+ \bidi@tempcountb\z@ \bidi@temptoksa\bidi@empty@toks
+ \loop\ifnum\bidi@tempcountb<\bidi@stack@length
+ \bidi@pop@into{bidi@temptoksb}{#1}\advance\bidi@stack@length\m@ne
+ \bidi@append@list@to@list{bidi@temptoksb}{bidi@temptoksa}\repeat
+ \csname#1\endcsname\bidi@temptoksa \bidi@temptoksa\bidi@empty@toks}
+
\def\bidi@looprepeat@csarg#1#2{\expandafter#1\csname#2\endcsname}
\def\bidi@looprepeat@csromannumeral#1{\csname #1\romannumeral\bidi@looprepeat@depth\endcsname}