[latex3-commits] [git/LaTeX3-latex3-latex3] main: Make keyval_parse alignment safe (fixes #896) (feea7896c)
Bruno Le Floch
blflatex at gmail.com
Mon May 10 23:09:26 CEST 2021
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/feea7896cdbd6c2792ad6260de2a41c0381fae61
>---------------------------------------------------------------
commit feea7896cdbd6c2792ad6260de2a41c0381fae61
Author: Bruno Le Floch <blflatex at gmail.com>
Date: Mon May 10 23:09:26 2021 +0200
Make keyval_parse alignment safe (fixes #896)
>---------------------------------------------------------------
feea7896cdbd6c2792ad6260de2a41c0381fae61
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3keys.dtx | 15 +++--
l3kernel/testfiles/m3keyval004.lvt | 40 +++++++++++++
.../{m3fp-logic003.tlg => m3keyval004.tlg} | 68 +++++++---------------
4 files changed, 74 insertions(+), 50 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 542169b23..43d7a8dc1 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
### Fixed
- Loading of backend in generic DVI mode (issue #905)
+- Make `\keyval_parse:nnn` alignment-safe (issue #896)
### Changed
- Speed up \group_align_safe_begin: (pull #906)
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index cf04ec82d..006597f8c 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -891,7 +891,7 @@
% \end{verbatim}
% are treated identically.
%
-% \begin{function}[rEXP, added=2020-12-19]{\keyval_parse:nnn}
+% \begin{function}[rEXP, added=2020-12-19, updated = 2021-05-10]{\keyval_parse:nnn}
% \begin{syntax}
% \cs{keyval_parse:nnn} \Arg{code_1} \Arg{code_2} \Arg{key--value list}
% \end{syntax}
@@ -929,7 +929,7 @@
% \end{texnote}
% \end{function}
%
-% \begin{function}[rEXP,updated = 2020-12-19]{\keyval_parse:NNn}
+% \begin{function}[rEXP, updated = 2021-05-10]{\keyval_parse:NNn}
% \begin{syntax}
% \cs{keyval_parse:NNn} \meta{function_1} \meta{function_2} \Arg{key--value list}
% \end{syntax}
@@ -1017,7 +1017,10 @@
% argument.
% \begin{macrocode}
\cs_new:Npn \keyval_parse:nnn ##1 ##2 ##3
- { \@@_loop_active:nnw {##1} {##2} \s_@@_mark ##3 #1 \s_@@_tail #1 }
+ {
+ \group_align_safe_begin:
+ \@@_loop_active:nnw {##1} {##2} \s_@@_mark ##3 #1 \s_@@_tail #1
+ }
\cs_new_eq:NN \keyval_parse:NNn \keyval_parse:nnn
% \end{macrocode}
% \end{macro}
@@ -1255,7 +1258,7 @@
\cs_new:Npn \@@_end_loop_active:w
\s_@@_tail
\@@_loop_other:nnw ##1 \s_@@_mark \s_@@_tail , \s_@@_tail ,
- { }
+ { \group_align_safe_end: }
% \end{macrocode}
% \end{macro}
%
@@ -1280,14 +1283,18 @@
{
\@@_if_blank:w \s_@@_mark #2 \s_@@_nil \s_@@_stop \@@_blank_key_error:w
\s_@@_mark \s_@@_stop
+ \group_align_safe_end:
\exp_not:n { #4 { #2 } { #1 } }
+ \group_align_safe_begin:
\@@_loop_other:nnw {#3} {#4}
}
\cs_new:Npn \@@_key:nn #1 #2
{
\@@_if_blank:w \s_@@_mark #1 \s_@@_nil \s_@@_stop \@@_blank_key_error:w
\s_@@_mark \s_@@_stop
+ \group_align_safe_end:
\exp_not:n { #2 { #1 } }
+ \group_align_safe_begin:
\@@_loop_other:nnw {#2}
}
% \end{macrocode}
diff --git a/l3kernel/testfiles/m3keyval004.lvt b/l3kernel/testfiles/m3keyval004.lvt
new file mode 100644
index 000000000..9e6c6e7dc
--- /dev/null
+++ b/l3kernel/testfiles/m3keyval004.lvt
@@ -0,0 +1,40 @@
+\documentclass{minimal}
+\input{regression-test}
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation , log-functions }
+\ExplSyntaxOff
+\begin{document}
+\START
+\AUTHOR{Bruno Le Floch}
+\ExplSyntaxOn
+
+\OMIT
+\cs_new:Npn \test:nn #1#2
+ {
+ \TEST { while~ searching~ for~ noalign/omit }
+ {
+ \tex_halign:D
+ {
+ \TYPE{0} ## \TYPE{1} \tex_cr:D
+ \keyval_parse:nnn {#1} {#2} { a, a=b&c }
+ \tex_cr:D
+ }
+ }
+ \TEST { with~ relax }
+ {
+ \tex_halign:D
+ {
+ \TYPE{0} ## \TYPE{1} \tex_cr:D
+ \scan_stop: \keyval_parse:nnn {#1} {#2} { a, a=b&c }
+ \tex_cr:D
+ }
+ }
+ }
+\TIMO
+
+\test:nn \use_none:n \use_none:nn
+\test:nn { \scan_stop: \use_none:n } { \scan_stop: \use_none:nn }
+
+
+\END
diff --git a/l3kernel/testfiles/m3fp-logic003.tlg b/l3kernel/testfiles/m3keyval004.tlg
similarity index 79%
copy from l3kernel/testfiles/m3fp-logic003.tlg
copy to l3kernel/testfiles/m3keyval004.tlg
index e86916445..7c5b22046 100644
--- a/l3kernel/testfiles/m3fp-logic003.tlg
+++ b/l3kernel/testfiles/m3keyval004.tlg
@@ -2,50 +2,26 @@ This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
Author: Bruno Le Floch
============================================================
-TEST 1: fp_do_until
-============================================================
-0.75
-1.5
-2.25
-3
-3.75
-4.5
-0.75
-1.5
-2.25
-3
-3.75
-4.5
-============================================================
-============================================================
-TEST 2: fp_do_while
-============================================================
-0.75
-1.5
-2.25
-0.75
-1.5
-2.25
-============================================================
-============================================================
-TEST 3: fp_until_do
-============================================================
-0.75
-1.5
-2.25
-3
-3.75
-0.75
-1.5
-2.25
-3
-3.75
-============================================================
-============================================================
-TEST 4: fp_while_do
-============================================================
-0.75
-1.5
-0.75
-1.5
+TEST 1: while searching for noalign/omit
+============================================================
+0
+1
+============================================================
+============================================================
+TEST 2: with relax
+============================================================
+0
+1
+============================================================
+============================================================
+TEST 3: while searching for noalign/omit
+============================================================
+0
+1
+============================================================
+============================================================
+TEST 4: with relax
+============================================================
+0
+1
============================================================
More information about the latex3-commits
mailing list.