[latex3-commits] [git/LaTeX3-latex3-latex2e] master: Do not expand argument of \@startpbox while building the tabular preamble (sx/459285) (f6124d9)
Frank Mittelbach
frank.mittelbach at latex-project.org
Wed Nov 14 00:01:29 CET 2018
Repository : https://github.com/latex3/latex2e
On branch : master
Link : https://github.com/latex3/latex2e/commit/f6124d9ecb303f0b7d69967e941524c5f8e225a3
>---------------------------------------------------------------
commit f6124d9ecb303f0b7d69967e941524c5f8e225a3
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Wed Nov 14 00:01:29 2018 +0100
Do not expand argument of \@startpbox while building the tabular preamble (sx/459285)
>---------------------------------------------------------------
f6124d9ecb303f0b7d69967e941524c5f8e225a3
required/tools/array.dtx | 120 ++++++++++++++------
required/tools/changes.txt | 7 +-
required/tools/testfiles/sx411758.lvt | 2 +-
required/tools/testfiles/sx459285.lvt | 21 ++++
.../tools/testfiles/sx459285.tlg | 7 +-
5 files changed, 113 insertions(+), 44 deletions(-)
diff --git a/required/tools/array.dtx b/required/tools/array.dtx
index d766d78..f921a9a 100644
--- a/required/tools/array.dtx
+++ b/required/tools/array.dtx
@@ -32,7 +32,7 @@
%<+package>\DeclareCurrentRelease{}{2018-04-30}
%<+package>
%<+package>\ProvidesPackage{array}
-%<+package> [2018/09/13 v2.4i Tabular extension package (FMi)]
+%<+package> [2018/11/13 v2.4j Tabular extension package (FMi)]
%
% \fi
%
@@ -1283,6 +1283,10 @@
% \subsection{The macro \texttt{\textbackslash @mkpream}}
%
% \begin{macro}{\@mkpream}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
% \begin{macro}{\the at toks}
% \label{@mkpream}
% Now we can define the macro which builds up the preamble for the
@@ -1290,7 +1294,7 @@
% First we initialize =\@preamble=, =\@lastchclass=
% and the boolean variable =\if at firstamp=.
% \begin{macrocode}
-\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
+%\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
% \end{macrocode}
% During the build-up of the preamble we cannot directly use the
% =#= sign; this would lead to an error message in the next
@@ -1309,7 +1313,7 @@
% macros expand in many \textsf{tokens} which would delay the
% build-up of the preamble.
% \begin{macrocode}
- \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
+% \let\@sharp\relax\let\@startpbox\relax\let\@endpbox\relax
% \end{macrocode}
% Two more are needed to deal with the code that handles struts
% for extra space after a row from =\\[<space>]=
@@ -1318,27 +1322,27 @@
% \changes{v2.4e}{2016/10/07}{Fixing SX68732}
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
- \let\do at row@strut\relax
- \let\ar at align@mcell\relax
+% \let\do at row@strut\relax
+% \let\ar at align@mcell\relax
% \end{macrocode}
% Now we remove possible $*$-forms in the user preamble with the
% command =\@xexpast=. As we already know, this command saves
% its result in the macro =\@tempa=.
% \begin{macrocode}
- \@xexpast #1*0x\@@
+% \@xexpast #1*0x\@@
% \end{macrocode}
% Afterwards we initialize all registers and macros, that we need
% for the build-up of the preamble.
% Since we want to start with the \textsf{token} register $0$,
% =\count@= has to contain the value $-1$.
% \begin{macrocode}
- \count@\m at ne
- \let\the at toks\relax
+% \count@\m at ne
+% \let\the at toks\relax
% \end{macrocode}
% Then we call up =\prepnext at tok= in order to prepare the
% \textsf{token} register $0$ for use.
% \begin{macrocode}
- \prepnext at tok
+% \prepnext at tok
% \end{macrocode}
% To evaluate the user preamble (without stars) saved in
% =\@tempa= we use the \LaTeX--macro =\@tfor=.
@@ -1347,8 +1351,8 @@
% =\@tempa= and not the macro =\@tempa= to this
% \LaTeX--macro.
% \begin{macrocode}
- \expandafter \@tfor \expandafter \@nextchar
- \expandafter :\expandafter =\@tempa \do
+% \expandafter \@tfor \expandafter \@nextchar
+% \expandafter :\expandafter =\@tempa \do
% \end{macrocode}
% The body of this loop (the group after the =\do=)
% is executed for one \textsf{token} at a time, whereas
@@ -1359,15 +1363,15 @@
% the character number of this \textsf{token}.
% \changes{v2.0f}{1992/02/29}{\cs{@testpach} now without arg}
% \begin{macrocode}
- {\@testpach
+% {\@testpach
% \end{macrocode}
% Then we branch out depending on the value of =\@chclass= into
% different macros that extend the preamble respectively.
% \begin{macrocode}
- \ifcase \@chclass \@classz \or \@classi \or \@classii
- \or \save at decl \or \or \@classv \or \@classvi
- \or \@classvii \or \@classviii \or \@classix
- \or \@classx \fi
+% \ifcase \@chclass \@classz \or \@classi \or \@classii
+% \or \save at decl \or \or \@classv \or \@classvi
+% \or \@classvii \or \@classviii \or \@classix
+% \or \@classx \fi
% \end{macrocode}
% Two cases deserve our special attention: Since the current
% \textsf{token} cannot have the character class $4$ (start) we
@@ -1379,29 +1383,29 @@
% =\@lastchclass= to assure that this information will be available
% during the next run of the loop.
% \begin{macrocode}
- \@lastchclass\@chclass}%
+% \@lastchclass\@chclass}%
% \end{macrocode}
% After the loop has been finished space must still be added to
% the created preamble, depending on the last \textsf{token}.
% Depending on the value of =\@lastchclass= we perform
% the necessary operations.
% \begin{macrocode}
- \ifcase\@lastchclass
+% \ifcase\@lastchclass
% \end{macrocode}
% If the last class equals $0$ we add a
% =\hskip \col at sep=.
% \begin{macrocode}
- \@acol \or
+% \@acol \or
% \end{macrocode}
% If it equals $1$ we do not add any additional space so that the
% horizontal lines do not exceed the vertical ones.
% \begin{macrocode}
- \or
+% \or
% \end{macrocode}
% Class $2$ is treated like class $0$ because a =<{...}= can
% only directly follow after class $0$.
% \begin{macrocode}
- \@acol \or
+% \@acol \or
% \end{macrocode}
% Most of the other possibilities can only appear if the user
% preamble was defective. Class $3$ is not allowed since after a
@@ -1409,32 +1413,32 @@
% \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an
% error and ignore the declaration given by ={..}=.
% \begin{macrocode}
- \@preamerr \thr@@ \or
+% \@preamerr \thr@@ \or
% \end{macrocode}
% If =\@lastchclass= is $4$ the user preamble has been empty.
% To continue, we insert a =#= in the preamble.
% \begin{macrocode}
- \@preamerr \tw@ \@addtopreamble\@sharp \or
+% \@preamerr \tw@ \@addtopreamble\@sharp \or
% \end{macrocode}
% Class $5$ is allowed again. In this case
% (the user preamble ends with =@{..}=) we need not
% do anything.
% \begin{macrocode}
- \or
+% \or
% \end{macrocode}
% Any other case means that the arguments to =@=, \texttt{!},
% \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have
% been forgotten. So we report an error and ignore the last
% \textsf{token}.
% \begin{macrocode}
- \else \@preamerr \@ne \fi
+% \else \@preamerr \@ne \fi
% \end{macrocode}
% Now that the build-up of the preamble is almost finished we can
% insert the \textsf{token} registers and therefore redefine
% =\the at toks=. The actual insertion, though, is performed
% later.
% \begin{macrocode}
- \def\the at toks{\the\toks}}
+% \def\the at toks{\the\toks}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1689,6 +1693,11 @@
%
% \begin{macro}{\@classix}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% In case of class $9$ (\texttt{>}--\textsf{token}) we first check
% if the character class of the last
% \textsf{token} was $3$. In this case we have a
@@ -1697,28 +1706,33 @@
% So the declarations defined by the first =>{...}=
% are ignored.
% \begin{macrocode}
-\def\@classix{\ifnum \@lastchclass = \thr@@
- \@preamerr \thr@@ \fi
+%\def\@classix{\ifnum \@lastchclass = \thr@@
+% \@preamerr \thr@@ \fi
% \end{macrocode}
% Furthermore, we call up =\@class10= because afterwards always a
% new column is started by \texttt{c}, \texttt{l}, \texttt{r},
% \texttt{p}, \texttt{m} or \texttt{b}.
% \begin{macrocode}
- \@classx}
+% \@classx}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@classviii}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% If the current \textsf{token} is a \texttt{<} the last character
% class must be $0$. In this case it is not necessary to extend the
% preamble. Otherwise we output an error message, set =\@chclass=
% to $6$ and call =\@classvi=. By doing this we achieve that
% \texttt{<} is treated like \texttt{!}.
% \begin{macrocode}
-\def\@classviii{\ifnum \@lastchclass >\z@
- \@preamerr 4\@chclass 6 \@classvi \fi}
+%\def\@classviii{\ifnum \@lastchclass >\z@
+% \@preamerr 4\@chclass 6 \@classvi \fi}
% \end{macrocode}
% \end{macro}
%
@@ -1817,11 +1831,16 @@
%
%
% \begin{macro}{\@classv}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% If the current \textsf{token} is of class $5$ then it is an
% argument of a \texttt{@} \textsf{token}. It must be stored into a
% \textsf{token} register.
% \begin{macrocode}
-\def\@classv{\save at decl
+%\def\@classv{\save at decl
% \end{macrocode}
% We extend the preamble with a command which inserts this
% \textsf{token} register into the preamble when its construction
@@ -1832,11 +1851,11 @@
% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem
% `the`toks0`the`toks1.}
% \begin{macrocode}
- \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
+% \@addtopreamble{\d at llarbegin\the at toks\the\count@\relax\d at llarend}%
% \end{macrocode}
% Finally we must prepare the next \textsf{token} register.
% \begin{macrocode}
- \prepnext at tok}
+% \prepnext at tok}
% \end{macrocode}
% \end{macro}
%
@@ -2308,10 +2327,15 @@
% \end{macro}
%
% \begin{macro}{\@tabarray}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% This macro tests for a optional bracket and then calls up
% =\@array= or =\@array[c]= (as default).
% \begin{macrocode}
-\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
+%\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
% \end{macrocode}
% \end{macro}
%
@@ -2367,6 +2391,11 @@
% \end{macro}
%
% \begin{macro}{\endarray}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% When the processing of \textsf{array} is finished we have to
% close the =\halign=
% and afterwards the surrounding \textsf{box} selected by
@@ -2374,7 +2403,7 @@
% =\@preamble=
% because its replacement text isn't longer needed.
% \begin{macrocode}
-\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
+%\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
% \end{macrocode}
% \end{macro}
%
@@ -2676,6 +2705,7 @@
{\expandafter\@nextchar\the\toks\count@}}
% \end{macrocode}
% \end{macro}
+%
% \begin{macro}{\@mkpream}
% The main modification to "\@mkpream" is to replace the call to
% "\@xexpast" (which expanded $*$-forms) by a loop which expands
@@ -2684,7 +2714,23 @@
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
- \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
+ \let\@sharp\relax
+% \end{macrocode}
+%
+% \changes{v2.4j}{2018/11/13}{Do not expand argument of
+% \cs{@startpbox} while building the tabular preamble (sx/459285)}
+% The "\@startpbox" (which is called for "p", "t" or "b" columns)
+% receives a user supplied argument: the width of the
+% p-column. Normally that is something harmless like a length or a
+% simpl length expression, but with the calc package envolved it
+% could break under an "\edef" operation, wich is how the preamble
+% is build. We make used of "\unexpanded" here to prevent that. The
+% "\expandafter gymnastic is necessary to expand the "#1" at least
+% once (since it will get "\@nextchar" as its value and need its
+% content!
+% \begin{macrocode}
+ \def\@startpbox##1{\unexpanded\expandafter{\expandafter
+ \@startpbox\expandafter{##1}}}\let\@endpbox\relax
\let\do at row@strut\relax
\let\ar at align@mcell\relax
% \end{macrocode}
diff --git a/required/tools/changes.txt b/required/tools/changes.txt
index 12051d0..5205b69 100644
--- a/required/tools/changes.txt
+++ b/required/tools/changes.txt
@@ -5,6 +5,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
=======================================================================
+2018-11-13 <Frank.Mittelbach at latex-project.org>
+
+ * array.dtx: Do not expand argument of \@startpbox
+ while building the tabular preamble (sx/459285)
+
2018-11-09 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* multicol.dtx:
@@ -23,7 +28,7 @@ are not part of the distribution.
2018-09-13 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* array.dtx (section{The macros \@classz):
- Add group to prevent color leak (gh/72)
+ Add group to prevent color leak (github/72)
#########################
# 2018-04-01 PL 5 Release
diff --git a/required/tools/testfiles/sx411758.lvt b/required/tools/testfiles/sx411758.lvt
index 6f77e68..ec39a4f 100644
--- a/required/tools/testfiles/sx411758.lvt
+++ b/required/tools/testfiles/sx411758.lvt
@@ -1,4 +1,4 @@
-% Test file forhttps://tex.stackexchange.com/questions/411758/multicol-results-in-superimposed-text-under-some-conditions-how-can-i-avoid-thi/411910
+% Test file for https://tex.stackexchange.com/questions/411758/multicol-results-in-superimposed-text-under-some-conditions-how-can-i-avoid-thi/411910
\input{test2e}
diff --git a/required/tools/testfiles/sx459285.lvt b/required/tools/testfiles/sx459285.lvt
new file mode 100644
index 0000000..1292e1c
--- /dev/null
+++ b/required/tools/testfiles/sx459285.lvt
@@ -0,0 +1,21 @@
+% Test file for https://tex.stackexchange.com/questions/459285/is-there-an-incompatibility-between-the-packages-calc-and-siunitx-genericerro/459294#459294
+%
+% this was producing errors and shouldn't
+
+\input{test2e}
+
+\documentclass[11pt]{article}
+
+\usepackage{calc,array}
+
+\begin{document}
+\START
+
+\begin{tabular}{p{.5cm}p{\widthof{\textbf{AAAAAAAAA}}}lp{.5cm}}
+&\textbf{AAAAAAAAA}&XXXXXXXXXXXXXXXXXXXXXX\\
+&\textbf{BBBBB}&YYYYYYYYYYYYYYYYYYYYYYY\\
+\end{tabular}
+
+
+\end{document}
+
diff --git a/base/testfiles/tlb1596.tlg b/required/tools/testfiles/sx459285.tlg
similarity index 73%
copy from base/testfiles/tlb1596.tlg
copy to required/tools/testfiles/sx459285.tlg
index 8b627cb..a1d101b 100644
--- a/base/testfiles/tlb1596.tlg
+++ b/required/tools/testfiles/sx459285.tlg
@@ -1,13 +1,10 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
-Author: Michael Downes
-Format: LaTeX2e<1995/06/01>
-Main Class: article
LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <12> on input line ....
+(Font) <10.95> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <8> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
[1
-] (tlb1596.aux)
+] (sx459285.aux)
More information about the latex3-commits
mailing list