From 5502acd4e4e09854fe760b61cf2b5086b2c7ef8c Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Thu, 4 Oct 2018 21:43:58 +0000
Subject: bidi (4oct18)

git-svn-id: svn://tug.org/texlive/trunk@48830 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/xelatex/bidi/bidi.dtx | 176 ++++++++++++-------------
 1 file changed, 85 insertions(+), 91 deletions(-)

(limited to 'Master/texmf-dist/source/xelatex/bidi/bidi.dtx')

diff --git a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
index 33b5734e3cd..ceee92003db 100644
--- a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
+++ b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
@@ -5,7 +5,7 @@
 %<*readme>
 ___________________
 The bidi package
-v34.2
+v34.4
 
 This package provides a convenient interface for typesetting
 bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -44,7 +44,7 @@ mailing list whenever I have time. You can subscribe to the mailing list at
   <http://tug.org/mailman/listinfo/persiantex>
   
   
-Current version release date: 2018/10/03
+Current version release date: 2018/10/04
 
 ___________________
 Vafa Khalighi
@@ -99,7 +99,7 @@ by Vafa Khalighi.
 \generate{\file{bidicode.sty}{\from{\jobname.dtx}{table,bidicode.sty}}}
 \generate{\file{bidiftnxtra.sty}{\from{\jobname.dtx}{table,bidiftnxtra.sty}}}
 \generate{\file{bidimoderncv.cls}{\from{\jobname.dtx}{table,bidimoderncv.cls}}}
-\generate{\file{bidi-perpagefootnote.sty}{\from{\jobname.dtx}{table,bidi-perpagefootnote.sty}}}
+\generate{\file{bidi-perpage.sty}{\from{\jobname.dtx}{table,bidi-perpage.sty}}}
 \generate{\file{biditools.sty}{\from{\jobname.dtx}{table,biditools.sty}}}
 \generate{\file{bidituftefloat.sty}{\from{\jobname.dtx}{table,bidituftefloat.sty}}}
 \generate{\file{bidituftesidenote.sty}{\from{\jobname.dtx}{table,bidituftesidenote.sty}}}
@@ -242,7 +242,7 @@ by Vafa Khalighi.
 \documentclass{ltxdoc}
 \input{bidi-doc-preamble.ltx}
 \hypersetup{%
-  pdftitle={Source documentation for version 34.2 of the bidi
+  pdftitle={Source documentation for version 34.4 of the bidi
                 package}%
 }
 \EnableCrossrefs
@@ -261,7 +261,7 @@ by Vafa Khalighi.
 % \GetFileInfo{\jobname.dtx}
 % \title{\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}\\
 %\LARGE Bidirectional typesetting in plain \TeX{} and \LaTeX, using \XeTeX{} engine\\[5pt]
-%\large Source documentation for \textcolor{blue!65!black}{version 34.2}}
+%\large Source documentation for \textcolor{blue!65!black}{version 34.4}}
 % \author{Vafa Khalighi\\
 %  \url{persian-tex@tug.org}}
 %\setcounter{page}{0}
@@ -272,7 +272,7 @@ by Vafa Khalighi.
 %\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
 %
 %\Large
-%Source documentation for \textcolor{blue!65!black}{version 34.2}}
+%Source documentation for \textcolor{blue!65!black}{version 34.4}}
 %
 %\vskip 0pt plus 3fill
 %\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -338,7 +338,7 @@ by Vafa Khalighi.
 %\iffalse
 %<*table>
 %\fi
-%% \CheckSum{50654}
+%% \CheckSum{50675}
 %% \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
@@ -1951,8 +1951,8 @@ by Vafa Khalighi.
 % \section{File \texttt{bidi.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\def\bididate{2018/10/03}
-\def\bidi@version{34.2}
+\def\bididate{2018/10/04}
+\def\bidi@version{34.4}
 \ProvidesPackage{bidi}[\bididate\space v\bidi@version\space
 Bidirectional typesetting in plain TeX and LaTeX]
 \edef\@bidi@info{****************************************************^^J%
@@ -2234,7 +2234,8 @@ Bidirectional typesetting in plain TeX and LaTeX]
 \newcommand*{\DigitsDotDashInterCharToks}{\if@nonlatin\char"200F \fi}
 \bidi@AtEndPreamble{%
   \if@bidi@perpage@footnote
-    \RequirePackage{bidi-perpagefootnote}%
+    \RequirePackage{bidi-perpage}%
+    \ResetCounterPerPage{footnote}%
   \fi
   \special{pdf:encrypt
     userpw (\bidi@pdfencrypt@userpassword)
@@ -2264,9 +2265,9 @@ Bidirectional typesetting in plain TeX and LaTeX]
 %\fi
 % \section{File \texttt{bidi.tex}}
 %    \begin{macrocode}
-\def\bididate{2018/10/03}
+\def\bididate{2018/10/04}
 \catcode`@=11
-\def\bidi@version{34.2}
+\def\bidi@version{34.4}
 \let \protect \relax
 \newlinechar`\^^J
 \edef\@bidi@info{****************************************************^^J%
@@ -3046,107 +3047,87 @@ Bidirectional typesetting in plain TeX and LaTeX]
 %    \end{macrocode}
 % \iffalse
 %</bidimoderncv.cls>
-%<*bidi-perpagefootnote.sty>
+%<*bidi-perpage.sty>
 %\fi
-% \section{File \texttt{bidi-perpagefootnote.sty}}
+% \section{File \texttt{bidi-perpage.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bidi-perpagefootnote}[2018/10/03 v0.2 Reset bidi footnotes counter on each page]
-\newif\if@bidi@reset@footnote@rerun
-\newcount\bidi@footnote@count 
-\bidi@footnote@count\z@
+\ProvidesPackage{bidi-perpage}[2018/10/04 v0.4 Reset counter(s) on every page]
 \newcount\bidi@page@count 
 \bidi@page@count\@ne
-\newcount\bidi@previous@page@count 
-\bidi@previous@page@count\z@
-\let\bidi@footnote\footnote
-\let\bidi@RTLfootnote\RTLfootnote
-\let\bidi@LTRfootnote\LTRfootnote
-\def\footnote{%
-  \@ifnextchar[%
-    \bidi@footnote
-    {%
-      \ifx\@mpfn\bidi@mpfn 
-        \bidi@reset@footnote@perpage 
-      \fi 
-      \bidi@footnote
-    }%
-}
-\def\RTLfootnote{%
-  \@ifnextchar[%
-    \bidi@RTLfootnote
-    {%
-      \ifx\@mpfn\bidi@mpfn 
-        \bidi@reset@footnote@perpage 
-      \fi 
-      \bidi@RTLfootnote
-    }%
-}
-\def\LTRfootnote{%
-  \@ifnextchar[%
-    \bidi@LTRfootnote
-    {%
-      \ifx\@mpfn\bidi@mpfn 
-        \bidi@reset@footnote@perpage 
-      \fi 
-      \bidi@LTRfootnote
+\newcommand*{\ResetCounterPerPage}[2][\z@]{%
+  \if@bidi@csundef{bidi@stepcounterhook@@#2}{%
+    \expandafter\gdef\csname bidi@stepcounterhook@@#2\endcsname{}%
+  }{}%
+  \if@bidi@csundef{if@bidi@reset@#2@rerun}{%
+    \expandafter\newif\csname if@bidi@reset@#2@rerun\endcsname
+  }{}%
+  \if@bidi@csundef{bidi@#2@count}{%
+    \expandafter\newcount\csname bidi@#2@count\endcsname
+  }{}%
+  \csname bidi@#2@count\endcsname\z@
+  \if@bidi@csundef{bidi@previous@page@@#2@count}{%
+    \expandafter\newcount\csname
+    bidi@previous@page@@#2@count\endcsname
+  }{}%
+  \csname bidi@previous@page@@#2@count\endcsname\z@  
+  \if@bidi@csundef{bidi@reset@#2@perpage}{%
+    \bidi@AfterEndDocumentCheckLabelsRerun{%
+      \csname if@bidi@reset@#2@rerun\endcsname
+        \PackageWarningNoLine{bidi-perpage}{%
+          Counter `#2' may not have been reset per page.
+          Rerun to reset counter `#2' per page%
+        }%
+      \fi
     }%
-}
-\let\bidi@footnotemark\footnotemark
-\def\footnotemark{%
-  \@ifnextchar[%
-    \bidi@footnotemark
-    {\bidi@reset@footnote@perpage \bidi@footnotemark}%
-}
-\let\bidi@mpfn\@mpfn
-\def\bidi@reset@footnote@perpage{%
-  \global\advance\bidi@footnote@count \@ne
-  \if@filesw
-    \edef\@tempa{%
-      \write\@auxout{%
-        \string\bidi@footnote@page
-        {\number\bidi@footnote@count}%
-        {\noexpand\number\noexpand\bidi@page@count}%
+  }{}%
+  \expandafter\gdef\csname bidi@reset@#2@perpage\endcsname{%
+    \global\advance\csname bidi@#2@count\endcsname\@ne
+    \if@filesw
+      \edef\@tempa{%
+        \write\@auxout{%
+          \string\bidi@counter@page{#2}%
+          {\number\csname bidi@#2@count\endcsname}%
+          {\noexpand\number\noexpand\bidi@page@count}%
+        }%
       }%
-    }%
-    \@tempa
-  \fi
-  \expandafter\ifx\csname bidi@footnote@@\number
-  \bidi@footnote@count\endcsname\relax
-    \global\c@footnote\z@
-    \global\@bidi@reset@footnote@reruntrue
+      \@tempa
+    \fi
+  \begingroup\expandafter\expandafter\expandafter\endgroup
+  \expandafter\ifx\csname bidi@#2@@\number\csname
+  bidi@#2@count\endcsname\endcsname\relax
+    \global\csname @bidi@reset@#2@reruntrue\endcsname
   \else
-    \global\@bidi@reset@footnote@rerunfalse
-    \expandafter\@tempcnta\csname bidi@footnote@@\number
-    \bidi@footnote@count\endcsname\relax
-    \ifnum\@tempcnta=\bidi@previous@page@count
+    \global\csname @bidi@reset@#2@rerunfalse\endcsname
+    \expandafter\@tempcnta\csname bidi@#2@@\number
+    \csname bidi@#2@count\endcsname\endcsname\relax
+    \ifnum\@tempcnta=\csname
+    bidi@previous@page@@#2@count\endcsname
     \else
-      \global\bidi@previous@page@count\@tempcnta
-      \global\c@footnote\z@
+      \global\csname
+      bidi@previous@page@@#2@count\endcsname\@tempcnta
+      \global\csname c@#2\endcsname#1\relax
     \fi
   \fi
+  }%
+  \expandafter\bidi@gappto\csname 
+  bidi@stepcounterhook@@#2\endcsname{%
+    \csname bidi@reset@#2@perpage\endcsname
+  }%
 }
-\def\bidi@footnote@page#1#2{\global\@namedef{bidi@footnote@@#1}{#2}}    
+\def\bidi@counter@page#1#2#3{\bidi@namegdef{bidi@#1@@#2}{#3}}    
 \bidi@AtEndOutputPage{%
   \global\advance\bidi@page@count\@ne
 }
-\bidi@AfterEndDocumentCheckLabelsRerun{%
-  \if@bidi@reset@footnote@rerun
-    \PackageWarningNoLine{bidi-perpagefootnote}{%
-      Footnote(s) number(s) may be wrong.
-      Rerun to get footnote(s) number(s) right%
-    }%
-  \fi
-}
 %    \end{macrocode}
 % \iffalse
-%</bidi-perpagefootnote.sty>
+%</bidi-perpage.sty>
 %<*biditools.sty>
 %\fi
 % \section{File \texttt{biditools.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{biditools}[2018/10/03 v1.5 Programming tools for bidi package]
+\ProvidesPackage{biditools}[2018/10/04 v1.6 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%
@@ -3920,6 +3901,19 @@ ill-advised in the old versions of bidi package.%
   {\bidi@warning{%
      Patching '\string\end' failed!\MessageBreak
      '\string\bidi@AfterEndEnvironment' will not work\@gobble}}
+
+\def\bidi@namedef#1{\expandafter\def\csname #1\endcsname} 
+\def\bidi@namegdef#1{\expandafter\gdef\csname #1\endcsname} 
+\def\bidi@nameedef#1{\expandafter\edef\csname #1\endcsname}   
+\def\bidi@namexdef#1{\expandafter\xdef\csname #1\endcsname}
+
+\bidi@pretocmd\stepcounter
+  {%
+    \if@bidi@csundef{bidi@stepcounterhook@@#1}{}{%
+      \csname bidi@stepcounterhook@@#1\endcsname
+    }%
+  }{}%
+  {\PackageWarning{biditools}{Patching `\string\stepcounter' failed}}
      
 \chardef\bidi@backslash`\\
 \def\bidics#1{\texttt{\char\bidi@backslash#1}}
-- 
cgit v1.2.3

