[latex3-commits] [latex3/latex3] develop: Avoid an error if a key prop. is lacking a value (76bdd69d7)
github at latex-project.org
github at latex-project.org
Sat Jul 13 17:00:48 CEST 2024
Repository : https://github.com/latex3/latex3
On branch : develop
Link : https://github.com/latex3/latex3/commit/76bdd69d710136f9b223b77c32726f9b19bac13c
>---------------------------------------------------------------
commit 76bdd69d710136f9b223b77c32726f9b19bac13c
Author: Joseph Wright <joseph at texdev.net>
Date: Wed Jun 19 07:07:18 2024 +0100
Avoid an error if a key prop. is lacking a value
This only shows up if a 2e property has no value:
we need to add one!
>---------------------------------------------------------------
76bdd69d710136f9b223b77c32726f9b19bac13c
l3kernel/CHANGELOG.md | 3 +++
l3kernel/l3keys.dtx | 19 +++++++++++++++----
l3kernel/testfiles/m3keys001.lvt | 10 ++++++++++
l3kernel/testfiles/m3keys001.tlg | 10 +++++++---
4 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index c58c1a618..1a7319090 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Fixed
+- Avoid a low-level error when LaTeX2e key properties are given without a value
+
## [2024-05-27]
### Added
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index 13772d178..202794076 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -1926,6 +1926,7 @@
% \end{macro}
%
% \begin{macro}{\@@_define_code:n}
+% \begin{macro}[EXP]{\@@_define_code:TF}
% \begin{macro}[EXP]{\@@_define_code:w}
% Two possible cases. If there is a value for the key, then just use
% the function. If not, then a check to make sure there is no need for
@@ -1937,8 +1938,7 @@
{
\bool_if:NTF \l_@@_no_value_bool
{
- \exp_after:wN \@@_define_code:w
- \l_@@_property_str \s_@@_stop
+ \@@_define_code:TF
{ \use:c { \c_@@_props_root_str \l_@@_property_str } }
{
\msg_error:nnee { keys } { property-requires-value }
@@ -1947,12 +1947,23 @@
}
{ \use:c { \c_@@_props_root_str \l_@@_property_str } {#1} }
}
-\exp_last_unbraced:NNNNo
- \cs_new:Npn \@@_define_code:w #1 \c_colon_str #2 \s_@@_stop
+\cs_new:Npe \@@_define_code:TF
+ {
+ \exp_not:N \exp_after:wN \exp_not:N \@@_define_code:w
+ \exp_not:N \l_@@_property_str
+ \c_colon_str \c_colon_str
+ \exp_not:N \s_@@_stop
+ }
+\use:e
+ {
+ \cs_new:Npn \exp_not:N \@@_define_code:w
+ #1 \c_colon_str #2 \c_colon_str #3 \exp_not:N \s_@@_stop
+ }
{ \tl_if_empty:nTF {#2} }
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Turning properties into actions}
%
diff --git a/l3kernel/testfiles/m3keys001.lvt b/l3kernel/testfiles/m3keys001.lvt
index c6e56c935..0ba329758 100644
--- a/l3kernel/testfiles/m3keys001.lvt
+++ b/l3kernel/testfiles/m3keys001.lvt
@@ -308,6 +308,16 @@
}
}
+\TEST { Known~property~but~missing~argument }
+ {
+ \OMIT
+ \cs_gset_protected:cpn { \c__keys_props_root_str .demo } { }
+ \TIMO
+ }
+ {
+ \keys_define:nn { module } { key-one .demo }
+ }
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\TEST { Empty~module }
diff --git a/l3kernel/testfiles/m3keys001.tlg b/l3kernel/testfiles/m3keys001.tlg
index 4528b8be2..593c687bd 100644
--- a/l3kernel/testfiles/m3keys001.tlg
+++ b/l3kernel/testfiles/m3keys001.tlg
@@ -149,7 +149,11 @@ Inside \keys_define:nn each key name needs a property:
LaTeX did not find a '.' to indicate the start of a property.
============================================================
============================================================
-TEST 11: Empty module
+TEST 11: Known property but missing argument
+============================================================
+============================================================
+============================================================
+TEST 12: Empty module
============================================================
Defining key key on line ...
> \l_keys_path_str=key.
@@ -157,7 +161,7 @@ Defining key key on line ...
l. ... }
============================================================
============================================================
-TEST 12: Empty module, key with period
+TEST 13: Empty module, key with period
============================================================
Defining key key.name on line ...
Defining key key.space on line ...
@@ -169,7 +173,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 13: Spaces after detokenization
+TEST 14: Spaces after detokenization
============================================================
Defining key module/\test on line ...
You typed "Hello World!"
More information about the latex3-commits
mailing list.