[latex3-commits] [git/LaTeX3-latex3-latex2e] gh836: fix for #836 (54c51841)
Frank Mittelbach
frank.mittelbach at latex-project.org
Wed Jun 1 19:40:21 CEST 2022
Repository : https://github.com/latex3/latex2e
On branch : gh836
Link : https://github.com/latex3/latex2e/commit/54c51841891c7cb7647b3b9424d69eff863a5e7a
>---------------------------------------------------------------
commit 54c51841891c7cb7647b3b9424d69eff863a5e7a
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Wed Jun 1 19:40:21 2022 +0200
fix for #836
>---------------------------------------------------------------
54c51841891c7cb7647b3b9424d69eff863a5e7a
base/changes.txt | 6 ++++
base/ltmarks.dtx | 62 +++++++++++++++++++++++++++++-----
base/testfiles-ltmarks/github-0836.tlg | 16 ---------
base/testfiles-ltmarks/xmarks-001.tlg | 2 +-
base/update-ltmarks-test.sh | 4 ++-
5 files changed, 64 insertions(+), 26 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 59966cb8..7073b3be 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2022-06-01 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * ltmarks.dtx (subsection{Updating mark structures}):
+ Be more careful when unpackage a \vbox for mark detection, it might
+ contain infinite shrink glue (gh/836)
+
2022-05-27 David Carlisle <David.Carlisle at latex-project.org>
* ltfiles.dtx, ltoutenc.dtx:
diff --git a/base/ltmarks.dtx b/base/ltmarks.dtx
index e8971c9d..2a6270da 100644
--- a/base/ltmarks.dtx
+++ b/base/ltmarks.dtx
@@ -14,8 +14,8 @@
%%% From File: ltmarks.dtx
%
% \begin{macrocode}
-\def\ltmarksversion{v1.0c}
-\def\ltmarksdate{2022/05/06}
+\def\ltmarksversion{v1.0d}
+\def\ltmarksdate{2022/06/01}
% \end{macrocode}
%<*driver>
\documentclass{l3doc}
@@ -835,9 +835,16 @@
% and b) we don't see any marks because they are hidden one level
% down).
%
+% Another possible issue are packages or user code that place stray
+% \cs{vbox} directly into the main galley (and example is
+% \pkg{marginnote} that attaches its marginals in this way. If such
+% boxes end up as the last item on the page we should not unpack
+% them.
+%
% We therefore do an \tn{unskip} to get rid of that glue if present and
% also check if we have then a \cs{vbox} as the last item and if so
-% unpack that too. All this is temporary, just for getting the
+% unpack that too, but only under certain conditions, see
+% below. All this is temporary, just for getting the
% marks out, so it doesn't affect the final page production.
%
% In fact, we go one step further and set the box to a large
@@ -856,16 +863,49 @@
#2
\tex_unskip:D
\box_set_to_last:N \l_@@_box
- \box_if_vertical:NT \l_@@_box
- { \vbox_unpack:N \l_@@_box }
+% \end{macrocode}
+% After having removed the last box from the current list (if there
+% was one)
+% we check if the list is now empty. If not, the the last box is
+% definitely not the one from \cs{enlargethispage} and so we can
+% and should leave it alone. Otherwise we check if this last box is
+% a \cs{vbox}.
+% \changes{v1.0d}{2022/06/01}{Extend the logic for detecting the marks
+% in the box (gh/836)}
+% \begin{macrocode}
+ \int_compare:nNnT \tex_lastnodetype:D < 0
+ {
+ \box_if_vertical:NT \l__mark_box
+ {
+% \end{macrocode}
+% If it is we do a further test and reset the \cs{l_@@_box}
+% to check if it contains infinite shrinkable glue.
+% \begin{macrocode}
+ \vbox_set_to_ht:Nnn \l__mark_box { -.5\c_max_dim }
+ { \vbox_unpack:N \l__mark_box
+ \tex_kern:D \c_zero_dim % ensure that box
+ % is not empty
+ }
+% \end{macrocode}
+% If not, then we unpack it, if yes we still ignore it for the process of
+% mark extraction. We do not generate an error though, because in all
+% likelihood this is an ordinary box like a marginal that does
+% contain something like \cs{vss}.
+% \begin{macrocode}
+ \int_compare:nNnT \tex_badness:D > 0
+ { \vbox_unpack:N \l__mark_box }
+ }
+ }
% \end{macrocode}
% If it wasn't a vbox, it was either an hbox or there was no box.
% Given that we are only interested in the marks we don't need put
-% it back in that case. However, we have to make sure that the box
+% it back in that case. However, we have to make sure that the
+% outer box under construction
% is not totally empty (which it might have been from the start, or
% now), because \TeX{} does not report a badness for empty boxes
-% which means out test would incorrectly conclude that we have
-% infinite shrinking glue. A simple \tn{kern} is enough to avoid this.
+% and that means our test would incorrectly conclude that we have
+% infinite shrinking glue. A simple \tn{kern} is enough to avoid
+% this (the same was already done above).
% \begin{macrocode}
\tex_kern:D \c_zero_dim
}
@@ -1165,6 +1205,12 @@
%
% \subsection{Messages}
%
+% Mark errors are LaTeX kernel errors:
+% \changes{v1.0d}{2022/06/01}{Marks are kernel errors}
+% \begin{macrocode}
+\prop_gput:Nnn \g_msg_module_type_prop { mark } { LaTeX }
+% \end{macrocode}
+%
% \begin{macrocode}
\msg_new:nnnn { mark } { class-already-defined }
{ Mark~class~'#1'~already~defined }
diff --git a/base/testfiles-ltmarks/github-0836.tlg b/base/testfiles-ltmarks/github-0836.tlg
index 12551a83..3c32c577 100644
--- a/base/testfiles-ltmarks/github-0836.tlg
+++ b/base/testfiles-ltmarks/github-0836.tlg
@@ -29,14 +29,6 @@ Don't change this file in any respect.
\__hook_toplevel cmd/@opcol/before ...\@outputbox
}
l. ...\newpage
-! Package mark Error: Infinite shrinkage found in 'page'.
-For immediate help type H <return>.
- ...
-l. ...\newpage
-This is a coding error.
-The mark region 'page' contains some infinite negative glue allowing it to
-shrink to an arbitrary size. This makes it impossible to split the region
-apart to get at its marks. They are lost.
[1
]
> \box...=
@@ -100,12 +92,4 @@ Underfull \vbox (badness 10000) has occurred while \output is active
\__hook_toplevel cmd/@opcol/before ...\@outputbox
}
l. ...\break
-! Package mark Error: Infinite shrinkage found in 'page'.
-For immediate help type H <return>.
- ...
-l. ...\break
-This is a coding error.
-The mark region 'page' contains some infinite negative glue allowing it to
-shrink to an arbitrary size. This makes it impossible to split the region
-apart to get at its marks. They are lost.
[3]
diff --git a/base/testfiles-ltmarks/xmarks-001.tlg b/base/testfiles-ltmarks/xmarks-001.tlg
index 2d05ef67..e780b2fd 100644
--- a/base/testfiles-ltmarks/xmarks-001.tlg
+++ b/base/testfiles-ltmarks/xmarks-001.tlg
@@ -146,7 +146,7 @@ Marks: baz in OR (oneside):
column (first):||first baz|first baz|
column (second):||first baz|first baz|
[3]
-! Package mark Error: Unknown mark class 'unknown'.
+! LaTeX mark Error: Unknown mark class 'unknown'.
For immediate help type H <return>.
...
l. ...
diff --git a/base/update-ltmarks-test.sh b/base/update-ltmarks-test.sh
index 12374df2..e16e4b57 100644
--- a/base/update-ltmarks-test.sh
+++ b/base/update-ltmarks-test.sh
@@ -7,7 +7,9 @@ l3build save -cconfig-ltmarks \
xmarks-005 \
xmarks-006 \
xmarks-007 \
- xmarks-008
+ xmarks-008 \
+ github-0836
+
exit
More information about the latex3-commits
mailing list.