[latex3-commits] [git/LaTeX3-latex3-latex3] main: Fix \clist_remove_duplicates:N for "unsafe" items (fixes #917) (3d7815891)

Bruno Le Floch blflatex at gmail.com
Sat May 15 17:37:17 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/3d781589161119260ed049888d331463ec588661

>---------------------------------------------------------------

commit 3d781589161119260ed049888d331463ec588661
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Sat May 15 17:36:04 2021 +0200

    Fix \clist_remove_duplicates:N for "unsafe" items (fixes #917)


>---------------------------------------------------------------

3d781589161119260ed049888d331463ec588661
 l3kernel/CHANGELOG.md             | 1 +
 l3kernel/l3clist.dtx              | 8 +++++++-
 l3kernel/testfiles/m3clist002.lvt | 4 ++++
 l3kernel/testfiles/m3clist002.tlg | 1 +
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 029a2291d..24939c7ac 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -18,6 +18,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Fixed
 - Checking brace balance in all regex functions (issue #377)
+- Removing duplicates in clists when items contain commas (issue #917)
 
 ### Changed
 - Speed up mapping functions in l3clist, l3prop, l3seq, l3tl
diff --git a/l3kernel/l3clist.dtx b/l3kernel/l3clist.dtx
index f0e89abfe..8fbf4580f 100644
--- a/l3kernel/l3clist.dtx
+++ b/l3kernel/l3clist.dtx
@@ -1393,7 +1393,13 @@
     \clist_map_inline:Nn #2
       {
         \clist_if_in:NnF \l_@@_internal_remove_clist {##1}
-          { \clist_put_right:Nn \l_@@_internal_remove_clist {##1} }
+          {
+            \tl_put_right:Nx \l_@@_internal_remove_clist
+              {
+                \clist_if_empty:NF \l_@@_internal_remove_clist { , }
+                \@@_if_wrap:nTF {##1} { \exp_not:n { {##1} } } { \exp_not:n {##1} }
+              }
+          }
       }
     #1 #2 \l_@@_internal_remove_clist
   }
diff --git a/l3kernel/testfiles/m3clist002.lvt b/l3kernel/testfiles/m3clist002.lvt
index 0fc6f97ac..af70daebc 100644
--- a/l3kernel/testfiles/m3clist002.lvt
+++ b/l3kernel/testfiles/m3clist002.lvt
@@ -483,6 +483,10 @@
     \TYPE{ \tl_use:N \l_tmpa_clist }
   }
   \TYPE{ \tl_use:N \l_tmpa_clist }
+  %
+  \clist_set:Nn \l_tmpa_clist { a , {a,b,c,d,e,f,g,h} , b , { b ~ } , ~ b }
+  \clist_remove_duplicates:N \l_tmpa_clist
+  \TYPE { \clist_count:N \l_tmpa_clist \c_space_tl items:~ [ \tl_use:N \l_tmpa_clist ] }
 }
 
 \TEST{remove_all}{
diff --git a/l3kernel/testfiles/m3clist002.tlg b/l3kernel/testfiles/m3clist002.tlg
index 2c8bf5dac..b1badd7d9 100644
--- a/l3kernel/testfiles/m3clist002.tlg
+++ b/l3kernel/testfiles/m3clist002.tlg
@@ -384,6 +384,7 @@ This is a coding error.
 Global assignment to a local variable '\l_tmpa_clist'.
 b\par ,c\par ,a\par 
 b\par ,c\par ,a\par 
+4 items: [a,{a,b,c,d,e,f,g,h},b,{b }]
 ============================================================
 ============================================================
 TEST 29: remove_all





More information about the latex3-commits mailing list.