[latex3-commits] [git/LaTeX3-latex3-latex2e] gh327: Drop spaces after \verb or \verb* and do not misinterpret them as the delimiter (#327) (4f02ccd6)
Frank Mittelbach
frank.mittelbach at latex-project.org
Wed Apr 22 19:47:03 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : gh327
Link : https://github.com/latex3/latex2e/commit/4f02ccd61d70534f80a96bf3fa1d304a996ac0ce
>---------------------------------------------------------------
commit 4f02ccd61d70534f80a96bf3fa1d304a996ac0ce
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Wed Apr 22 19:47:03 2020 +0200
Drop spaces after \verb or \verb* and do not misinterpret them as the delimiter (#327)
>---------------------------------------------------------------
4f02ccd61d70534f80a96bf3fa1d304a996ac0ce
base/changes.txt | 5 +
base/doc/ltnews32.tex | 14 +++
base/ltmiscen.dtx | 109 +++++++++++++++------
.../tlb-latexrelease-rollback-003-often.luatex.tlg | 14 ++-
.../tlb-latexrelease-rollback-003-often.tlg | 14 ++-
.../tlb-latexrelease-rollback-003-often.xetex.tlg | 14 ++-
base/testfiles/tlb-rollback-004-often.luatex.tlg | 7 +-
base/testfiles/tlb-rollback-004-often.tlg | 7 +-
base/testfiles/tlb-rollback-004-often.xetex.tlg | 7 +-
9 files changed, 141 insertions(+), 50 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 8b21f777..94b9534a 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2020-04-22 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * ltmiscen.dtx (subsection{Verbatim}):
+ Drop spaces before \verb delimiter (gh/327)
+
2020-04-22 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
* ltoutenc.dtx (tuenc.def):
diff --git a/base/doc/ltnews32.tex b/base/doc/ltnews32.tex
index 719bb2dc..59fdf7d7 100644
--- a/base/doc/ltnews32.tex
+++ b/base/doc/ltnews32.tex
@@ -358,6 +358,20 @@ code.
\githubissue{186}
+\subsection{Avoid a problem with \cs{verb}}
+
+If the users typed \verb*=\verb !~! foo= instead of
+\verb*=\verb!~! foo= by mistake, then surprisingly the result was
+``\verb=!~!=foo'' without any warning or error.
+%
+What happened was that the
+\verb*= = became the argument delimiter due to the rather complex
+processing done by \cs{verb} to render verbatim. This now got
+fixed and spaces directly following the command \cs{verb} or \cs{verb*}
+are ignored as elsewhere.
+%
+\githubissue{327}
+
diff --git a/base/ltmiscen.dtx b/base/ltmiscen.dtx
index 5d97523e..ac147119 100644
--- a/base/ltmiscen.dtx
+++ b/base/ltmiscen.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltmiscen.dtx}
- [2020/04/21 v1.1t LaTeX Kernel (Misc. Environments)]
+ [2020/04/22 v1.1u LaTeX Kernel (Misc. Environments)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltmiscen.dtx}
@@ -1025,7 +1025,7 @@
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2018/12/01}%
-%<latexrelease> {\verbvisiblespace}{Setup visible space for verb}%
+%<latexrelease> {\verbvisiblespace}{Setup visible space for \verb}%
% \end{macrocode}
%
%
@@ -1107,15 +1107,71 @@
% \end{macrocode}
% \end{macro}
%
+%^^A \@sverb was here
+%
+% \begin{environment}{verbatim*}
+% For \texttt{verbatim*} we also set up the correct visible space
+% character definition and then run |\@vobeyspaces|. As this code
+% is not called as part of the normal verbatim environment (the
+% method is done the other way around this time) we don't have to
+% check if space is already active---it shouldn't be.
+% \changes{v1.1o}{2018/10/11}
+% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
+% \begin{macrocode}
+\@namedef{verbatim*}{\@verbatim
+ \@setupverbvisiblespace
+ \frenchspacing\@vobeyspaces\@sxverbatim}
+\expandafter\let\csname endverbatim*\endcsname =\endverbatim
+% \end{macrocode}
+% \end{environment}
+%
+%
+%
+% \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\verbvisiblespace}{Setup visible space for \verb}%
+%<latexrelease>
+%<latexrelease>\@namedef{verbatim*}{\@verbatim\@sxverbatim}
+%<latexrelease>
+%<latexrelease>\let\asciispace \@undefined
+%<latexrelease>\let\verbvisiblespace \@undefined
+%<latexrelease>\let\@setupverbvisiblespace\@undefined
+%<latexrelease>\let\@verbvisiblespacebox \@undefined
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+% \end{macrocode}
+%
+%
%
% \begin{macro}{\@sverb}
+% \begin{macro}{\@@sverb}
% \changes{v1.0j}{1994/05/10}{Slight change in error message text.}
% Definitions of |\@sverb| and |\@verb| changed so |\verb+ foo+|
% does not lose leading blanks when it comes at the beginning of a line.
% Change made 24 May 89. Suggested by Frank Mittelbach and Rainer
% Sch\"opf.
% \begin{macrocode}
-\def\@sverb#1{%
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease> {\@sverb}{Drop spaces before \verb delimiter}%
+% \end{macrocode}
+%
+% If the users types \verb=\verb !~! foo= then surprisingly we would
+% get the space as the delimiter and thus
+% ``\verb=!~!foo'' in the output.
+% To avoid this scenario we check if \verb=#1= has the character
+% code of a space, if so we recurse otherwise we call \cs{@@sverb}
+% (which is the original definition of \cs{@sverb}.
+% \changes{v1.1u}{2020/04/22}{Drop spaces before \cs{verb} delimiter (gh/327)}
+% \begin{macrocode}
+\def\@sverb#1{\if\noexpand#1 \expandafter\@sverb\else\@@sverb{#1}\fi}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@@sverb#1{%
\catcode`#1\active
\lccode`\~`#1%
\gdef\verb at balance@group{\verb at egroup
@@ -1135,39 +1191,28 @@
\else \@setupverbvisiblespace \@vobeyspaces \fi
}
% \end{macrocode}
-% \end{macro}
-%
-% \begin{environment}{verbatim*}
-% For \texttt{verbatim*} we also set up the correct visible space
-% character definition and then run |\@vobeyspaces|. As this code
-% is not called as part of the normal verbatim environment (the
-% method is done the other way around this time) we don't have to
-% check if space is already active---it shouldn't be.
-% \changes{v1.1o}{2018/10/11}
-% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
-% \begin{macrocode}
-\@namedef{verbatim*}{\@verbatim
- \@setupverbvisiblespace
- \frenchspacing\@vobeyspaces\@sxverbatim}
-\expandafter\let\csname endverbatim*\endcsname =\endverbatim
-% \end{macrocode}
-% \end{environment}
-%
-%
%
% \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
-%<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease> {\verbvisiblespace}{Setup visible space for verb}%
-%<latexrelease>
-%<latexrelease>\@namedef{verbatim*}{\@verbatim\@sxverbatim}
+%<latexrelease>\IncludeInRelease{2018/12/01}%
+%<latexrelease> {\@sverb}{Setup visible space for \verb}%
%<latexrelease>
-%<latexrelease>\let\asciispace \@undefined
-%<latexrelease>\let\verbvisiblespace \@undefined
-%<latexrelease>\let\@setupverbvisiblespace\@undefined
-%<latexrelease>\let\@verbvisiblespacebox \@undefined
+%<latexrelease>\def\@sverb#1{%
+%<latexrelease> \catcode`#1\active
+%<latexrelease> \lccode`\~`#1%
+%<latexrelease> \gdef\verb at balance@group{\verb at egroup
+%<latexrelease> \@latex at error{\noexpand\verb illegal in command argument}\@ehc}%
+%<latexrelease> \aftergroup\verb at balance@group
+%<latexrelease> \lowercase{\let~\verb at egroup}%
+%<latexrelease> \ifnum\catcode`\ =\active
+%<latexrelease> \else \@setupverbvisiblespace \@vobeyspaces \fi
+%<latexrelease>}
+%<latexrelease>\let\@@sverb\@undefined
+%<latexrelease>\EndIncludeInRelease
%<latexrelease>
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\@sverb}{Drop spaces before \verb delimiter}%
%<latexrelease>\def\@sverb#1{%
%<latexrelease> \catcode`#1\active
%<latexrelease> \lccode`\~`#1%
@@ -1179,8 +1224,8 @@
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
-%
-%
+% \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\@makeother}
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
index 841e7767..c4e7b0c4 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
@@ -283,8 +283,11 @@ Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Disable hyphenation in verbatim on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
-Skipping: [....-..-..] Setup visible space for verb on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Drop spaces before \verb delimiter on input line ...
Skipping: [....-..-..] Disable hyphenation in verb on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Skipping: [....-..-..] LuaTeX on input line ....
@@ -670,9 +673,12 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Applying: [....-..-..] LuaTeX on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
index 191cc58a..b29652f9 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
@@ -281,8 +281,11 @@ Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Disable hyphenation in verbatim on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
-Skipping: [....-..-..] Setup visible space for verb on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Drop spaces before \verb delimiter on input line ...
Skipping: [....-..-..] Disable hyphenation in verb on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Skipping: [....-..-..] Pre-load expl3 on input line ....
@@ -662,9 +665,12 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Skipping: [....-..-..] Pre-load expl3 on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
index 2f18c1fa..83f01383 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
@@ -281,8 +281,11 @@ Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Disable hyphenation in verbatim on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
-Skipping: [....-..-..] Setup visible space for verb on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Skipping: [....-..-..] Setup visible space for \verb on input line ....
+Applying: [....-..-..] Drop spaces before \verb delimiter on input line ...
Skipping: [....-..-..] Disable hyphenation in verb on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Skipping: [....-..-..] Pre-load expl3 on input line ....
@@ -671,9 +674,12 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Skipping: [....-..-..] Pre-load expl3 on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.luatex.tlg b/base/testfiles/tlb-rollback-004-often.luatex.tlg
index edd097ee..7c396816 100644
--- a/base/testfiles/tlb-rollback-004-often.luatex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.luatex.tlg
@@ -685,11 +685,14 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
LaTeX Info: Redefining \asciispace on input line ....
LaTeX Info: Redefining \verbvisiblespace on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Applying: [....-..-..] LuaTeX on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.tlg b/base/testfiles/tlb-rollback-004-often.tlg
index ea886f84..ab1f1bf7 100644
--- a/base/testfiles/tlb-rollback-004-often.tlg
+++ b/base/testfiles/tlb-rollback-004-often.tlg
@@ -683,10 +683,13 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
LaTeX Info: Redefining \asciispace on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Applying: [....-..-..] Pre-load expl3 on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.xetex.tlg b/base/testfiles/tlb-rollback-004-often.xetex.tlg
index e9491876..ca22ba2f 100644
--- a/base/testfiles/tlb-rollback-004-often.xetex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.xetex.tlg
@@ -683,11 +683,14 @@ LaTeX Info: Redefining \raggedleft on input line ....
Already applied: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Disable hyphenation in verbatim on input line ....
Already applied: [....-..-..] Disable hyphenation in verbatim on input line ....
-Applying: [....-..-..] Setup visible space for verb on input line ....
+Applying: [....-..-..] Setup visible space for \verb on input line ....
LaTeX Info: Redefining \asciispace on input line ....
LaTeX Info: Redefining \verbvisiblespace on input line ....
\@verbvisiblespacebox=\box...
-Already applied: [....-..-..] Setup visible space for verb on input line ...
+Already applied: [....-..-..] Setup visible space for \verb on input line ....
+Skipping: [....-..-..] Drop spaces before \verb delimiter on input line ...
+Applying: [....-..-..] Setup visible space for \verb on input line ....
+Already applied: [....-..-..] Drop spaces before \verb delimiter on input line ....
Applying: [....-..-..] Disable hyphenation in verb on input line ....
Already applied: [....-..-..] Disable hyphenation in verb on input line ...
Applying: [....-..-..] Pre-load expl3 on input line ....
More information about the latex3-commits
mailing list.