From 36afb13206c5cf659854dce54a7e001273ca71e9 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Tue, 27 Oct 2020 20:55:42 +0000
Subject: l3 (27oct20)

git-svn-id: svn://tug.org/texlive/trunk@56785 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/l3kernel/expl3-code.tex   | 1283 ++++++++++++++------
 1 file changed, 909 insertions(+), 374 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex')

diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex
index 14b325957ff..ef1d0a3732c 100644
--- a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex
+++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex
@@ -69,7 +69,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: expl3.dtx
-\def\ExplFileDate{2020-10-05}%
+\def\ExplFileDate{2020-10-27}%
 \begingroup
   \def\next{\endgroup}%
   \expandafter\ifx\csname PackageError\endcsname\relax
@@ -3626,6 +3626,8 @@
   }
 \cs_new:Npn \use_none_delimit_by_s_stop:w #1 \s_stop { }
 %% File: l3tl.dtx
+\cs_new_eq:NN \__kernel_tl_set:Nx  \cs_set_nopar:Npx
+\cs_new_eq:NN \__kernel_tl_gset:Nx \cs_gset_nopar:Npx
 \cs_new_protected:Npn \tl_new:N #1
   {
     \__kernel_chk_if_free_cs:N #1
@@ -3635,7 +3637,7 @@
 \cs_new_protected:Npn \tl_const:Nn #1#2
   {
     \__kernel_chk_if_free_cs:N #1
-    \cs_gset_nopar:Npx #1 { \exp_not:n {#2} }
+    \cs_gset_nopar:Npx #1 { \__kernel_exp_not:w {#2} }
   }
 \cs_new_protected:Npn \tl_const:Nx #1#2
   {
@@ -3661,9 +3663,21 @@
 \cs_generate_variant:Nn \tl_set_eq:NN { cN, Nc, cc }
 \cs_generate_variant:Nn \tl_gset_eq:NN { cN, Nc, cc }
 \cs_new_protected:Npn \tl_concat:NNN #1#2#3
-  { \tl_set:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } }
+  {
+    \__kernel_tl_set:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#2}
+        \__kernel_exp_not:w \exp_after:wN {#3}
+      }
+  }
 \cs_new_protected:Npn \tl_gconcat:NNN #1#2#3
-  { \tl_gset:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } }
+  {
+    \__kernel_tl_gset:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#2}
+        \__kernel_exp_not:w \exp_after:wN {#3}
+      }
+  }
 \cs_generate_variant:Nn \tl_concat:NNN  { ccc }
 \cs_generate_variant:Nn \tl_gconcat:NNN { ccc }
 \prg_new_eq_conditional:NNn \tl_if_exist:N \cs_if_exist:N { TF , T , F , p }
@@ -3680,17 +3694,17 @@
   }
 \tl_const:Nn \c_space_tl { ~ }
 \cs_new_protected:Npn \tl_set:Nn #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:n {#2} } }
+  { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w {#2} } }
 \cs_new_protected:Npn \tl_set:No #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o {#2} } }
+  { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#2} } }
 \cs_new_protected:Npn \tl_set:Nx #1#2
-  { \cs_set_nopar:Npx #1 {#2} }
+  { \__kernel_tl_set:Nx #1 {#2} }
 \cs_new_protected:Npn \tl_gset:Nn #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:n {#2} } }
+  { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w {#2} } }
 \cs_new_protected:Npn \tl_gset:No #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o {#2} } }
+  { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#2} } }
 \cs_new_protected:Npn \tl_gset:Nx #1#2
-  { \cs_gset_nopar:Npx #1 {#2} }
+  { \__kernel_tl_gset:Nx #1 {#2} }
 \cs_generate_variant:Nn \tl_set:Nn  {         NV , Nv , Nf }
 \cs_generate_variant:Nn \tl_set:Nx  { c }
 \cs_generate_variant:Nn \tl_set:Nn  { c, co , cV , cv , cf }
@@ -3698,21 +3712,45 @@
 \cs_generate_variant:Nn \tl_gset:Nx { c }
 \cs_generate_variant:Nn \tl_gset:Nn { c, co , cV , cv , cf }
 \cs_new_protected:Npn \tl_put_left:Nn #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:n {#2} \exp_not:o #1 } }
+  {
+    \__kernel_tl_set:Nx #1
+      { \__kernel_exp_not:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
+  }
 \cs_new_protected:Npn \tl_put_left:NV #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:V #2 \exp_not:o #1 } }
+  {
+    \__kernel_tl_set:Nx #1
+      { \exp_not:V #2 \__kernel_exp_not:w \exp_after:wN {#1} }
+  }
 \cs_new_protected:Npn \tl_put_left:No #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o {#2} \exp_not:o #1 } }
+  {
+    \__kernel_tl_set:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#2}
+        \__kernel_exp_not:w \exp_after:wN {#1}
+      }
+  }
 \cs_new_protected:Npn \tl_put_left:Nx #1#2
-  { \cs_set_nopar:Npx #1 { #2 \exp_not:o #1 } }
+  { \__kernel_tl_set:Nx #1 { #2 \__kernel_exp_not:w \exp_after:wN {#1} } }
 \cs_new_protected:Npn \tl_gput_left:Nn #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:n {#2} \exp_not:o #1 } }
+  {
+    \__kernel_tl_gset:Nx #1
+      { \__kernel_exp_not:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
+  }
 \cs_new_protected:Npn \tl_gput_left:NV #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:V #2 \exp_not:o #1 } }
+  {
+    \__kernel_tl_gset:Nx #1
+      { \exp_not:V #2 \__kernel_exp_not:w \exp_after:wN {#1} }
+  }
 \cs_new_protected:Npn \tl_gput_left:No #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o {#2} \exp_not:o #1 } }
+  {
+    \__kernel_tl_gset:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#2}
+        \__kernel_exp_not:w \exp_after:wN {#1}
+      }
+  }
 \cs_new_protected:Npn \tl_gput_left:Nx #1#2
-  { \cs_gset_nopar:Npx #1 { #2 \exp_not:o {#1} } }
+  { \__kernel_tl_gset:Nx #1 { #2 \__kernel_exp_not:w \exp_after:wN {#1} } }
 \cs_generate_variant:Nn \tl_put_left:Nn  { c }
 \cs_generate_variant:Nn \tl_put_left:NV  { c }
 \cs_generate_variant:Nn \tl_put_left:No  { c }
@@ -3722,21 +3760,39 @@
 \cs_generate_variant:Nn \tl_gput_left:No { c }
 \cs_generate_variant:Nn \tl_gput_left:Nx { c }
 \cs_new_protected:Npn \tl_put_right:Nn #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:n {#2} } }
+  { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w \exp_after:wN { #1 #2 } } }
 \cs_new_protected:Npn \tl_put_right:NV #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:V #2 } }
+  {
+    \__kernel_tl_set:Nx #1
+      { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:V #2 }
+  }
 \cs_new_protected:Npn \tl_put_right:No #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o #1 \exp_not:o {#2} } }
+  {
+    \__kernel_tl_set:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#1}
+        \__kernel_exp_not:w \exp_after:wN {#2}
+      }
+  }
 \cs_new_protected:Npn \tl_put_right:Nx #1#2
-  { \cs_set_nopar:Npx #1 { \exp_not:o #1 #2 } }
+  { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#1} #2 } }
 \cs_new_protected:Npn \tl_gput_right:Nn #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:n {#2} } }
+  { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w \exp_after:wN { #1 #2 } } }
 \cs_new_protected:Npn \tl_gput_right:NV #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:V #2 } }
+  {
+    \__kernel_tl_gset:Nx #1
+      { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:V #2 }
+  }
 \cs_new_protected:Npn \tl_gput_right:No #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o #1 \exp_not:o {#2} } }
+  {
+    \__kernel_tl_gset:Nx #1
+      {
+        \__kernel_exp_not:w \exp_after:wN {#1}
+        \__kernel_exp_not:w \exp_after:wN {#2}
+      }
+  }
 \cs_new_protected:Npn \tl_gput_right:Nx #1#2
-  { \cs_gset_nopar:Npx #1 { \exp_not:o {#1} #2 } }
+  { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#1} #2 } }
 \cs_generate_variant:Nn \tl_put_right:Nn  { c }
 \cs_generate_variant:Nn \tl_put_right:NV  { c }
 \cs_generate_variant:Nn \tl_put_right:No  { c }
@@ -3756,9 +3812,11 @@
 \cs_new_protected:Npn \tl_rescan:nn #1#2
   {
     \tl_set_rescan:Nnn \l__tl_internal_a_tl {#1} {#2}
-    \exp_after:wN \tl_clear:N \exp_after:wN \l__tl_internal_a_tl
+    \exp_after:wN \__tl_rescan_aux:
     \l__tl_internal_a_tl
   }
+\exp_args:NNo \cs_new_protected:Npn \__tl_rescan_aux:
+  { \tl_clear:N \l__tl_internal_a_tl }
 \cs_new_protected:Npn \tl_set_rescan:Nnn
   { \__tl_set_rescan:NNnn \tl_set:No }
 \cs_new_protected:Npn \tl_gset_rescan:Nnn
@@ -3777,7 +3835,7 @@
   }
 \cs_new_protected:Npn \__tl_set_rescan_multi:nNN #1#2#3
   {
-    \exp_args:No \tex_everyeof:D { \c__tl_rescan_marker_tl }
+    \tex_everyeof:D \exp_after:wN { \c__tl_rescan_marker_tl }
     \exp_after:wN \__tl_rescan:NNw
     \exp_after:wN #2
     \exp_after:wN #3
@@ -3850,13 +3908,13 @@
   \c__tl_rescan_marker_tl #2
   { \use_i:nn \exp_end: #1 }
 \cs_new_protected:Npn \tl_replace_once:Nnn
-  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \tl_set:Nx  }
+  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \__kernel_tl_set:Nx  }
 \cs_new_protected:Npn \tl_greplace_once:Nnn
-  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \tl_gset:Nx }
+  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \tl_replace_all:Nnn
-  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \tl_set:Nx  }
+  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \__kernel_tl_set:Nx  }
 \cs_new_protected:Npn \tl_greplace_all:Nnn
-  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \tl_gset:Nx }
+  { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \__kernel_tl_gset:Nx }
 \cs_generate_variant:Nn \tl_replace_once:Nnn  { c }
 \cs_generate_variant:Nn \tl_greplace_once:Nnn { c }
 \cs_generate_variant:Nn \tl_replace_all:Nnn   { c }
@@ -3893,7 +3951,7 @@
   {
     \group_align_safe_begin:
     \cs_set:Npn \__tl_replace_wrap:w ##1 #1 ##2
-      { \exp_not:o { \use_none:nn ##1 } ##2 }
+      { \__kernel_exp_not:w \exp_after:wN { \use_none:nn ##1 } ##2 }
     \cs_set:Npx \__tl_replace_next:w ##1 #5
       {
         \exp_not:N \__tl_replace_wrap:w ##1
@@ -3903,9 +3961,7 @@
       }
     #3 #4
       {
-        \exp_after:wN \__tl_replace_next:w
-        \exp_after:wN { \exp_after:wN }
-        \exp_after:wN { \exp_after:wN }
+        \exp_after:wN \__tl_replace_next_aux:w
         #4
         #1
         {
@@ -3916,6 +3972,7 @@
       }
     \group_align_safe_end:
   }
+\cs_new:Npn \__tl_replace_next_aux:w { \__tl_replace_next:w { } { } }
 \cs_new_eq:NN \__tl_replace_wrap:w ?
 \cs_new_eq:NN \__tl_replace_next:w ?
 \cs_new_protected:Npn \tl_remove_once:Nn #1#2
@@ -3930,16 +3987,6 @@
   { \tl_greplace_all:Nnn #1 {#2} { } }
 \cs_generate_variant:Nn \tl_remove_all:Nn  { c }
 \cs_generate_variant:Nn \tl_gremove_all:Nn { c }
-\prg_new_conditional:Npnn \tl_if_blank:n #1 { p , T , F , TF }
-  {
-    \__tl_if_empty_if:o { \use_none:n #1 ? }
-      \prg_return_true:
-    \else:
-      \prg_return_false:
-    \fi:
-  }
-\prg_generate_conditional_variant:Nnn \tl_if_blank:n
-  { e , V , o } { p , T , F , TF }
 \prg_new_conditional:Npnn \tl_if_empty:N #1 { p , T , F , TF }
   {
     \if_meaning:w #1 \c_empty_tl
@@ -3952,8 +3999,7 @@
   { c } { p , T , F , TF }
 \prg_new_conditional:Npnn \tl_if_empty:n #1 { p , TF , T , F }
   {
-    \exp_after:wN \if_meaning:w \exp_after:wN \q__tl_nil
-        \tl_to_str:n {#1} \q__tl_nil
+    \if:w \scan_stop: \tl_to_str:n {#1} \scan_stop:
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -3963,10 +4009,10 @@
   { V } { p , TF , T , F }
 \cs_new:Npn \__tl_if_empty_if:o #1
   {
-    \exp_after:wN \if_meaning:w \exp_after:wN \q__tl_nil
-      \__kernel_tl_to_str:w \exp_after:wN {#1} \q__tl_nil
+    \if:w \scan_stop: \__kernel_tl_to_str:w \exp_after:wN {#1} \scan_stop:
   }
-\prg_new_conditional:Npnn \tl_if_empty:o #1 { p , TF , T , F }
+\exp_args:Nno \use:n
+  { \prg_new_conditional:Npnn \tl_if_empty:o #1 { p , TF , T , F } }
   {
     \__tl_if_empty_if:o {#1}
       \prg_return_true:
@@ -3974,6 +4020,17 @@
       \prg_return_false:
     \fi:
  }
+\exp_args:Nno \use:n
+  { \prg_new_conditional:Npnn \tl_if_blank:n #1 { p , T , F , TF } }
+  {
+    \__tl_if_empty_if:o { \use_none:n #1 ? }
+      \prg_return_true:
+    \else:
+      \prg_return_false:
+    \fi:
+  }
+\prg_generate_conditional_variant:Nnn \tl_if_blank:n
+  { e , V , o } { p , T , F , TF }
 \prg_new_conditional:Npnn \tl_if_eq:NN #1#2 { p , T , F , TF }
   {
     \if_meaning:w #1 #2
@@ -4048,9 +4105,9 @@
 \cs_new:Npn \tl_if_single:NTF { \exp_args:No \tl_if_single:nTF }
 \prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF }
   {
-    \if_catcode:w ^ \exp_after:wN \__tl_if_single:nnw
+    \if:w \scan_stop: \exp_after:wN \__tl_if_single:nnw
         \__kernel_tl_to_str:w
-          \exp_after:wN { \use_none:nn #1 ?? } ^ ? \s__tl_stop
+          \exp_after:wN { \use_none:nn #1 ?? } \scan_stop: ? \s__tl_stop
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -4196,18 +4253,16 @@
   {
     \int_eval:n
       {
-        \__tl_act:NNNnn
-          \__tl_act_count_normal:nN
-          \__tl_act_count_group:nn
-          \__tl_act_count_space:n
-          { }
+        \__tl_act:NNNn
+          \__tl_act_count_normal:N
+          \__tl_act_count_group:n
+          \__tl_act_count_space:
           {#1}
       }
   }
-\cs_new:Npn \__tl_act_count_normal:nN #1 #2 { 1 + }
-\cs_new:Npn \__tl_act_count_space:n #1 { 1 + }
-\cs_new:Npn \__tl_act_count_group:nn #1 #2
-  { 2 + \tl_count_tokens:n {#2} + }
+\cs_new:Npn \__tl_act_count_normal:N #1 { 1 + }
+\cs_new:Npn \__tl_act_count_space: { 1 + }
+\cs_new:Npn \__tl_act_count_group:n #1 { 2 + \tl_count_tokens:n {#1} + }
 \cs_new:Npn \tl_reverse_items:n #1
   {
     \__tl_reverse_items:nwNwn #1 ?
@@ -4223,43 +4278,48 @@
       \s__tl_stop { {#1} #5 }
   }
 \cs_new:Npn \__tl_reverse_items:wn #1 \s__tl_stop #2
-  { \exp_not:o { \use_none:nn #2 } }
+  { \__kernel_exp_not:w \exp_after:wN { \use_none:nn #2 } }
 \cs_new:Npn \tl_trim_spaces:n #1
-  { \__tl_trim_spaces:nn { \s__tl_mark #1 } \exp_not:o }
+  {
+    \__tl_trim_spaces:nn
+      { \__tl_trim_mark: #1 }
+      { \__kernel_exp_not:w \exp_after:wN }
+  }
 \cs_generate_variant:Nn \tl_trim_spaces:n { o }
 \cs_new:Npn \tl_trim_spaces_apply:nN #1#2
-  { \__tl_trim_spaces:nn { \s__tl_mark #1 } { \exp_args:No #2 } }
+  { \__tl_trim_spaces:nn { \__tl_trim_mark: #1 } { \exp_args:No #2 } }
 \cs_generate_variant:Nn \tl_trim_spaces_apply:nN { o }
 \cs_new_protected:Npn \tl_trim_spaces:N #1
-  { \tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
+  { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
 \cs_new_protected:Npn \tl_gtrim_spaces:N #1
-  { \tl_gset:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
+  { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
 \cs_generate_variant:Nn \tl_trim_spaces:N  { c }
 \cs_generate_variant:Nn \tl_gtrim_spaces:N { c }
-\cs_set:Npn \__tl_tmp:w #1
+\cs_set_protected:Npn \__tl_tmp:w #1
   {
     \cs_new:Npn \__tl_trim_spaces:nn ##1
       {
         \__tl_trim_spaces_auxi:w
           ##1
           \s__tl_nil
-          \s__tl_mark #1 { }
-          \s__tl_mark \__tl_trim_spaces_auxii:w
+          \__tl_trim_mark: #1 { }
+          \__tl_trim_mark: \__tl_trim_spaces_auxii:w
           \__tl_trim_spaces_auxiii:w
           #1 \s__tl_nil
           \__tl_trim_spaces_auxiv:w
         \s__tl_stop
       }
-    \cs_new:Npn \__tl_trim_spaces_auxi:w ##1 \s__tl_mark #1 ##2 \s__tl_mark ##3
+    \cs_new:Npn
+        \__tl_trim_spaces_auxi:w ##1 \__tl_trim_mark: #1 ##2 \__tl_trim_mark: ##3
       {
         ##3
         \__tl_trim_spaces_auxi:w
-        \s__tl_mark
+        \__tl_trim_mark:
         ##2
-        \s__tl_mark #1 {##1}
+        \__tl_trim_mark: #1 {##1}
       }
     \cs_new:Npn \__tl_trim_spaces_auxii:w
-        \__tl_trim_spaces_auxi:w \s__tl_mark \s__tl_mark ##1
+        \__tl_trim_spaces_auxi:w \__tl_trim_mark: \__tl_trim_mark: ##1
       {
         \__tl_trim_spaces_auxiii:w
         ##1
@@ -4271,111 +4331,52 @@
         \__tl_trim_spaces_auxiii:w
       }
     \cs_new:Npn \__tl_trim_spaces_auxiv:w ##1 \s__tl_nil ##2 \s__tl_stop ##3
-      { ##3 { \use_none:n ##1 } }
+      { ##3 { ##1 } }
+    \cs_new:Npn \__tl_trim_mark: {}
   }
 \__tl_tmp:w { ~ }
-\quark_new:N \q__tl_act_mark
-\quark_new:N \q__tl_act_stop
-\cs_new:Npn \__tl_act:NNNnn #1#2#3#4#5
-  {
-    \group_align_safe_begin:
-    \__tl_act_loop:w #5 \q__tl_act_mark \q__tl_act_stop
-    {#4} #1 #2 #3
-    \__tl_act_result:n { }
-  }
-\cs_new:Npn \__tl_act_loop:w #1 \q__tl_act_stop
+\cs_if_exist:NTF \tex_expanded:D
   {
-    \tl_if_head_is_N_type:nTF {#1}
-      { \__tl_act_normal:NwnNNN }
+    \cs_new:Npn \tl_head:n #1
       {
-        \tl_if_head_is_group:nTF {#1}
-          { \__tl_act_group:nwnNNN }
-          { \__tl_act_space:wwnNNN }
+        \__kernel_exp_not:w \tex_expanded:D
+          { { \if_false: { \fi: \__tl_head_aux:n #1 { } } } }
+      }
+    \cs_new:Npn \__tl_head_aux:n #1
+      {
+        \__kernel_exp_not:w {#1}
+        \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
       }
-    #1 \q__tl_act_stop
-  }
-\cs_new:Npn \__tl_act_normal:NwnNNN #1 #2 \q__tl_act_stop #3#4
-  {
-    \if_meaning:w \q__tl_act_mark #1
-      \exp_after:wN \__tl_act_end:wn
-    \fi:
-    #4 {#3} #1
-    \__tl_act_loop:w #2 \q__tl_act_stop
-    {#3} #4
-  }
-\cs_new:Npn \__tl_act_end:wn #1 \__tl_act_result:n #2
-  { \group_align_safe_end: \exp_end: #2 }
-\cs_new:Npn \__tl_act_group:nwnNNN #1 #2 \q__tl_act_stop #3#4#5
-  {
-    #5 {#3} {#1}
-    \__tl_act_loop:w #2 \q__tl_act_stop
-    {#3} #4 #5
-  }
-\exp_last_unbraced:NNo
-  \cs_new:Npn \__tl_act_space:wwnNNN \c_space_tl #1 \q__tl_act_stop #2#3#4#5
-  {
-    #5 {#2}
-    \__tl_act_loop:w #1 \q__tl_act_stop
-    {#2} #3 #4 #5
   }
-\cs_new:Npn \__tl_act_output:n #1 #2 \__tl_act_result:n #3
-  { #2 \__tl_act_result:n { #3 #1 } }
-\cs_new:Npn \__tl_act_reverse_output:n #1 #2 \__tl_act_result:n #3
-  { #2 \__tl_act_result:n { #1 #3 } }
-\cs_new:Npn \tl_reverse:n #1
   {
-    \__kernel_exp_not:w \exp_after:wN
+    \cs_new:Npn \tl_head:n #1
       {
-        \exp:w
-        \__tl_act:NNNnn
-          \__tl_reverse_normal:nN
-          \__tl_reverse_group_preserve:nn
-          \__tl_reverse_space:n
-          { }
+        \__kernel_exp_not:w
+          \if_false: { \fi: \__tl_head_auxi:nw #1 { } \s__tl_stop }
+      }
+    \cs_new:Npn \__tl_head_auxi:nw #1#2 \s__tl_stop
+      {
+        \exp_after:wN \__tl_head_auxii:n \exp_after:wN {
+          \if_false: } \fi: {#1}
+      }
+    \exp_args:Nno \use:n
+      { \cs_new:Npn \__tl_head_auxii:n #1 }
+      {
+        \__tl_if_empty_if:o { \use_none:n #1 }
+          \exp_after:wN \use_ii:nnn
+        \fi:
+        \use_ii:nn
           {#1}
+          { \if_false: { \fi: \__tl_head_auxi:nw #1 } }
       }
   }
-\cs_generate_variant:Nn \tl_reverse:n { o , V }
-\cs_new:Npn \__tl_reverse_normal:nN #1#2
-  { \__tl_act_reverse_output:n {#2} }
-\cs_new:Npn \__tl_reverse_group_preserve:nn #1#2
-  { \__tl_act_reverse_output:n { {#2} } }
-\cs_new:Npn \__tl_reverse_space:n #1
-  { \__tl_act_reverse_output:n { ~ } }
-\cs_new_protected:Npn \tl_reverse:N #1
-  { \tl_set:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
-\cs_new_protected:Npn \tl_greverse:N #1
-  { \tl_gset:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
-\cs_generate_variant:Nn \tl_reverse:N  { c }
-\cs_generate_variant:Nn \tl_greverse:N { c }
-\cs_new:Npn \tl_head:n #1
-  {
-    \__kernel_exp_not:w
-      \if_false: { \fi: \__tl_head_auxi:nw #1 { } \s__tl_stop }
-  }
-\cs_new:Npn \__tl_head_auxi:nw #1#2 \s__tl_stop
-  {
-    \exp_after:wN \__tl_head_auxii:n \exp_after:wN {
-      \if_false: } \fi: {#1}
-  }
-\cs_new:Npn \__tl_head_auxii:n #1
-  {
-    \exp_after:wN \if_meaning:w \exp_after:wN \q__tl_nil
-      \__kernel_tl_to_str:w \exp_after:wN { \use_none:n #1 } \q__tl_nil
-      \exp_after:wN \use_i:nn
-    \else:
-      \exp_after:wN \use_ii:nn
-    \fi:
-      {#1}
-      { \if_false: { \fi: \__tl_head_auxi:nw #1 } }
-  }
 \cs_generate_variant:Nn \tl_head:n { V , v , f }
 \cs_new:Npn \tl_head:w #1#2 \q_stop {#1}
 \cs_new:Npn \__tl_tl_head:w #1#2 \s__tl_stop {#1}
 \cs_new:Npn \tl_head:N { \exp_args:No \tl_head:n }
-\cs_new:Npn \tl_tail:n #1
+\exp_args:Nno \use:n { \cs_new:Npn \tl_tail:n #1 }
   {
-    \__kernel_exp_not:w
+    \exp_after:wN \__kernel_exp_not:w
       \tl_if_blank:nTF {#1}
         { { } }
         { \exp_after:wN { \use_none:n #1 } }
@@ -4385,13 +4386,10 @@
 \prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 { p , T , F , TF }
   {
     \if_charcode:w
-        \exp_not:N #2
         \tl_if_head_is_N_type:nTF { #1 ? }
-          {
-            \exp_after:wN \exp_not:N
-            \__tl_tl_head:w #1 { ? \use_none:nn } \s__tl_stop
-          }
+          { \__tl_head_exp_not:w #1 { ^ \__tl_if_head_eq_empty_arg:w } \s__tl_stop }
           { \str_head:n {#1} }
+        \exp_not:N #2
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -4402,17 +4400,14 @@
 \prg_new_conditional:Npnn \tl_if_head_eq_catcode:nN #1 #2 { p , T , F , TF }
   {
     \if_catcode:w
-        \exp_not:N #2
         \tl_if_head_is_N_type:nTF { #1 ? }
-          {
-            \exp_after:wN \exp_not:N
-            \__tl_tl_head:w #1 { ? \use_none:nn } \s__tl_stop
-          }
+          { \__tl_head_exp_not:w #1 { ^ \__tl_if_head_eq_empty_arg:w } \s__tl_stop }
           {
             \tl_if_head_is_group:nTF {#1}
-              { \c_group_begin_token }
-              { \c_space_token }
+              \c_group_begin_token
+              \c_space_token
           }
+        \exp_not:N #2
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -4423,8 +4418,8 @@
 \prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF }
   {
     \tl_if_head_is_N_type:nTF { #1 ? }
-      { \__tl_if_head_eq_meaning_normal:nN }
-      { \__tl_if_head_eq_meaning_special:nN }
+      \__tl_if_head_eq_meaning_normal:nN
+      \__tl_if_head_eq_meaning_special:nN
     {#1} #2
   }
 \cs_new:Npn \__tl_if_head_eq_meaning_normal:nN #1 #2
@@ -4439,11 +4434,11 @@
 \cs_new:Npn \__tl_if_head_eq_meaning_special:nN #1 #2
   {
     \if_charcode:w \str_head:n {#1} \exp_not:N #2
-      \exp_after:wN \use:n
+      \exp_after:wN \use_ii:nn
     \else:
       \prg_return_false:
-      \exp_after:wN \use_none:n
     \fi:
+    \use_none:n
     {
       \if_catcode:w \exp_not:N #2
                     \tl_if_head_is_group:nTF {#1}
@@ -4455,46 +4450,148 @@
       \fi:
     }
   }
+\cs_new:Npn \__tl_head_exp_not:w #1 #2 \s__tl_stop
+  { \exp_not:N #1 }
+\cs_new:Npn \__tl_if_head_eq_empty_arg:w \exp_not:N #1
+  { ? }
 \prg_new_conditional:Npnn \tl_if_head_is_N_type:n #1 { p , T , F , TF }
   {
-    \if_catcode:w
-        \if_false: { \fi: \__tl_if_head_is_N_type:w ? #1 ~ }
-        \exp_after:wN \use_none:n
-          \exp_after:wN { \exp_after:wN { \token_to_str:N #1 ? } }
-        * *
+    \if:w
+        \if_false: { \fi: \__tl_if_head_is_N_type_auxi:w \prg_do_nothing: #1 ~ }
+        { \exp_after:wN { \token_to_str:N #1 } }
+        \scan_stop: \scan_stop:
       \prg_return_true:
     \else:
       \prg_return_false:
     \fi:
   }
-\cs_new:Npn \__tl_if_head_is_N_type:w #1 ~
+\exp_args:Nno \use:n { \cs_new:Npn \__tl_if_head_is_N_type_auxi:w #1 ~ }
   {
-    \tl_if_empty:oTF { \use_none:n #1 } { ^ } { }
-    \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
+    \tl_if_empty:oTF { #1 }
+      { f \exp_after:wN \use_none:nn }
+      { \exp_after:wN \__tl_if_head_is_N_type_auxii:n }
+    \exp_after:wN { \if_false: } \fi:
   }
+\cs_new:Npn \__tl_if_head_is_N_type_auxii:n #1
+  { \exp_after:wN \use_none:n \exp_after:wN }
 \prg_new_conditional:Npnn \tl_if_head_is_group:n #1 { p , T , F , TF }
   {
-    \if_catcode:w
+    \if:w
         \exp_after:wN \use_none:n
           \exp_after:wN { \exp_after:wN { \token_to_str:N #1 ? } }
-        * *
-      \prg_return_false:
-    \else:
+        \scan_stop: \scan_stop:
+      \__tl_if_head_is_group_fi_false:w
+    \fi:
+    \if_true:
       \prg_return_true:
+    \else:
+      \prg_return_false:
     \fi:
   }
+\cs_new:Npn \__tl_if_head_is_group_fi_false:w \fi: \if_true: { \fi: \if_false: }
 \prg_new_conditional:Npnn \tl_if_head_is_space:n #1 { p , T , F , TF }
   {
-    \exp:w \if_false: { \fi:
-      \__tl_if_head_is_space:w ? #1 ? ~ }
+    \if:w
+        \if_false: { \fi: \__tl_if_head_is_space:w \prg_do_nothing: #1 ? ~ }
+        \scan_stop: \scan_stop:
+      \prg_return_true:
+    \else:
+      \prg_return_false:
+    \fi:
   }
-\cs_new:Npn \__tl_if_head_is_space:w #1 ~
+\exp_args:Nno \use:n { \cs_new:Npn \__tl_if_head_is_space:w #1 ~ }
   {
-    \tl_if_empty:oTF { \use_none:n #1 }
-      { \exp_after:wN \exp_end: \exp_after:wN \prg_return_true: }
-      { \exp_after:wN \exp_end: \exp_after:wN \prg_return_false: }
+    \__tl_if_empty_if:o {#1} \else: f \fi:
     \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
   }
+\scan_new:N \s__tl_act_stop
+\cs_set_protected:Npn \__tl_tmp:w #1
+  {
+    \cs_new:Npn \__tl_act_if_head_is_space:nTF ##1
+      {
+        \__tl_act_if_head_is_space:w
+          \s__tl_act_stop ##1 \s__tl_act_stop \__tl_act_if_head_is_space_true:w
+          \s__tl_act_stop #1  \s__tl_act_stop \use_ii:nn
+      }
+    \cs_new:Npn \__tl_act_if_head_is_space:w
+        ##1 \s__tl_act_stop #1 ##2 \s__tl_act_stop
+      {}
+    \cs_new:Npn \__tl_act_if_head_is_space_true:w
+        \s__tl_act_stop #1 \s__tl_act_stop \use_ii:nn ##1 ##2
+      {##1}
+  }
+\__tl_tmp:w { ~ }
+\exp_args:Nnx \use:n { \cs_new:Npn \__tl_act_loop:w #1 \s__tl_act_stop }
+  {
+    \exp_not:o { \__tl_act_if_head_is_space:nTF {#1} }
+      \exp_not:N \__tl_act_space:wwNNN
+      {
+        \exp_not:o { \tl_if_head_is_group:nTF {#1} }
+          \exp_not:N \__tl_act_group:nwNNN
+          \exp_not:N \__tl_act_normal:NwNNN
+      }
+    \exp_not:n {#1} \s__tl_act_stop
+  }
+\cs_undefine:N \__tl_act_if_head_is_space:nTF
+\cs_new:Npn \__tl_act_normal:NwNNN #1 #2 \s__tl_act_stop #3
+  {
+    #3 #1
+    \__tl_act_loop:w #2 \s__tl_act_stop
+    #3
+  }
+\cs_new:Npn \__tl_use_none_delimit_by_s_act_stop:w #1 \s__tl_act_stop { }
+\cs_new:Npn \__tl_act_end:wn #1 \__tl_act_result:n #2
+  { \group_align_safe_end: \exp_end: #2 }
+\cs_new:Npn \__tl_act_group:nwNNN #1 #2 \s__tl_act_stop #3#4#5
+  {
+    \__tl_use_none_delimit_by_s_act_stop:w #1 \__tl_act_end:wn \s__tl_act_stop
+    #5 {#1}
+    \__tl_act_loop:w #2 \s__tl_act_stop
+    #3 #4 #5
+  }
+\exp_last_unbraced:NNo
+  \cs_new:Npn \__tl_act_space:wwNNN \c_space_tl #1 \s__tl_act_stop #2#3
+  {
+    #3
+    \__tl_act_loop:w #1 \s__tl_act_stop
+    #2 #3
+  }
+\cs_new:Npn \__tl_act:NNNn #1#2#3#4
+  {
+    \group_align_safe_begin:
+    \__tl_act_loop:w #4 { \s__tl_act_stop } ? \s__tl_act_stop
+    #1 #3 #2
+    \__tl_act_result:n { }
+  }
+\cs_new:Npn \__tl_act_output:n #1 #2 \__tl_act_result:n #3
+  { #2 \__tl_act_result:n { #3 #1 } }
+\cs_new:Npn \__tl_act_reverse_output:n #1 #2 \__tl_act_result:n #3
+  { #2 \__tl_act_result:n { #1 #3 } }
+\cs_new:Npn \tl_reverse:n #1
+  {
+    \__kernel_exp_not:w \exp_after:wN
+      {
+        \exp:w
+        \__tl_act:NNNn
+          \__tl_reverse_normal:N
+          \__tl_reverse_group_preserve:n
+          \__tl_reverse_space:
+          {#1}
+      }
+  }
+\cs_generate_variant:Nn \tl_reverse:n { o , V }
+\cs_new:Npn \__tl_reverse_normal:N
+  { \__tl_act_reverse_output:n }
+\cs_new:Npn \__tl_reverse_group_preserve:n #1
+  { \__tl_act_reverse_output:n { {#1} } }
+\cs_new:Npn \__tl_reverse_space:
+  { \__tl_act_reverse_output:n { ~ } }
+\cs_new_protected:Npn \tl_reverse:N #1
+  { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
+\cs_new_protected:Npn \tl_greverse:N #1
+  { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
+\cs_generate_variant:Nn \tl_reverse:N  { c }
+\cs_generate_variant:Nn \tl_greverse:N { c }
 \cs_new:Npn \tl_item:nn #1#2
   {
     \exp_args:Nf \__tl_item:nn
@@ -4630,7 +4727,10 @@
 \cs_new_protected:Npn \__tl_show:NN #1#2
   {
     \__kernel_chk_defined:NT #2
-      { \exp_args:Nx #1 { \token_to_str:N #2 = \exp_not:o {#2} } }
+      {
+        \exp_args:Ne #1
+          { \token_to_str:N #2 = \__kernel_exp_not:w \exp_after:wN {#2} }
+      }
   }
 \cs_new_protected:Npn \tl_show:n #1
   { \iow_wrap:nnnN { >~ \tl_to_str:n {#1} . } { } { } \__tl_show:n }
@@ -4656,6 +4756,7 @@
 \tl_new:N \g_tmpb_tl
 \tl_new:N \l_tmpa_tl
 \tl_new:N \l_tmpb_tl
+\cs_undefine:N \__tl_tmp:w
 %% File: l3str.dtx
 \scan_new:N \s__str_mark
 \scan_new:N \s__str_stop
@@ -4717,13 +4818,13 @@
     { }
 \group_end:
 \cs_new_protected:Npn \str_replace_once:Nnn
-  { \__str_replace:NNNnn \prg_do_nothing: \tl_set:Nx  }
+  { \__str_replace:NNNnn \prg_do_nothing: \__kernel_tl_set:Nx  }
 \cs_new_protected:Npn \str_greplace_once:Nnn
-  { \__str_replace:NNNnn \prg_do_nothing: \tl_gset:Nx }
+  { \__str_replace:NNNnn \prg_do_nothing: \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \str_replace_all:Nnn
-  { \__str_replace:NNNnn \__str_replace_next:w \tl_set:Nx  }
+  { \__str_replace:NNNnn \__str_replace_next:w \__kernel_tl_set:Nx  }
 \cs_new_protected:Npn \str_greplace_all:Nnn
-  { \__str_replace:NNNnn \__str_replace_next:w \tl_gset:Nx }
+  { \__str_replace:NNNnn \__str_replace_next:w \__kernel_tl_gset:Nx }
 \cs_generate_variant:Nn \str_replace_once:Nnn  { c }
 \cs_generate_variant:Nn \str_greplace_once:Nnn { c }
 \cs_generate_variant:Nn \str_replace_all:Nnn   { c }
@@ -5318,22 +5419,22 @@
 \cs_new_eq:NN \seq_gset_eq:cc \tl_gset_eq:cc
 \cs_new_protected:Npn \seq_set_from_clist:NN #1#2
   {
-    \tl_set:Nx #1
+    \__kernel_tl_set:Nx #1
       { \s__seq \clist_map_function:NN #2 \__seq_wrap_item:n }
   }
 \cs_new_protected:Npn \seq_set_from_clist:Nn #1#2
   {
-    \tl_set:Nx #1
+    \__kernel_tl_set:Nx #1
       { \s__seq \clist_map_function:nN {#2} \__seq_wrap_item:n }
   }
 \cs_new_protected:Npn \seq_gset_from_clist:NN #1#2
   {
-    \tl_gset:Nx #1
+    \__kernel_tl_gset:Nx #1
       { \s__seq \clist_map_function:NN #2 \__seq_wrap_item:n }
   }
 \cs_new_protected:Npn \seq_gset_from_clist:Nn #1#2
   {
-    \tl_gset:Nx #1
+    \__kernel_tl_gset:Nx #1
       { \s__seq \clist_map_function:nN {#2} \__seq_wrap_item:n }
   }
 \cs_generate_variant:Nn \seq_set_from_clist:NN  {     Nc }
@@ -5349,9 +5450,9 @@
   }
 \cs_generate_variant:Nn \seq_const_from_clist:Nn { c }
 \cs_new_protected:Npn \seq_set_split:Nnn
-  { \__seq_set_split:NNnn \tl_set:Nx }
+  { \__seq_set_split:NNnn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gset_split:Nnn
-  { \__seq_set_split:NNnn \tl_gset:Nx }
+  { \__seq_set_split:NNnn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_set_split:NNnn #1#2#3#4
   {
     \tl_if_empty:nTF {#3}
@@ -5371,7 +5472,7 @@
             \__seq_set_split_end:
             \__seq_set_split_auxi:w \prg_do_nothing:
           }
-        \tl_set:Nx \l__seq_internal_a_tl { \l__seq_internal_a_tl }
+        \__kernel_tl_set:Nx \l__seq_internal_a_tl { \l__seq_internal_a_tl }
       }
     #1 #2 { \s__seq \l__seq_internal_a_tl }
   }
@@ -5397,7 +5498,7 @@
   { TF , T , F , p }
 \cs_new_protected:Npn \seq_put_left:Nn #1#2
   {
-    \tl_set:Nx #1
+    \__kernel_tl_set:Nx #1
       {
         \exp_not:n { \s__seq \__seq_item:n {#2} }
         \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 }
@@ -5405,7 +5506,7 @@
   }
 \cs_new_protected:Npn \seq_gput_left:Nn #1#2
   {
-    \tl_gset:Nx #1
+    \__kernel_tl_gset:Nx #1
       {
         \exp_not:n { \s__seq \__seq_item:n {#2} }
         \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 }
@@ -5443,9 +5544,9 @@
 \cs_generate_variant:Nn \seq_remove_duplicates:N  { c }
 \cs_generate_variant:Nn \seq_gremove_duplicates:N { c }
 \cs_new_protected:Npn \seq_remove_all:Nn
-  { \__seq_remove_all_aux:NNn \tl_set:Nx }
+  { \__seq_remove_all_aux:NNn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gremove_all:Nn
-  { \__seq_remove_all_aux:NNn \tl_gset:Nx }
+  { \__seq_remove_all_aux:NNn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_remove_all_aux:NNn #1#2#3
   {
     \__seq_push_item_def:n
@@ -5469,9 +5570,9 @@
 \cs_generate_variant:Nn \seq_remove_all:Nn  { c }
 \cs_generate_variant:Nn \seq_gremove_all:Nn { c }
 \cs_new_protected:Npn \seq_reverse:N
-  { \__seq_reverse:NN \tl_set:Nx }
+  { \__seq_reverse:NN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_greverse:N
-  { \__seq_reverse:NN \tl_gset:Nx }
+  { \__seq_reverse:NN \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_reverse:NN #1 #2
   {
     \cs_set_eq:NN \__seq_tmp:w \__seq_item:n
@@ -5584,7 +5685,7 @@
   }
 \cs_new_protected:Npn \seq_get_left:NN #1#2
   {
-    \tl_set:Nx #2
+    \__kernel_tl_set:Nx #2
       {
         \exp_after:wN \__seq_get_left:wnw
         #1 \__seq_item:n { \q_no_value } \s__seq_stop
@@ -5609,7 +5710,7 @@
 \cs_generate_variant:Nn \seq_gpop_left:NN { c }
 \cs_new_protected:Npn \seq_get_right:NN #1#2
   {
-    \tl_set:Nx #2
+    \__kernel_tl_set:Nx #2
       {
         \exp_after:wN \use_i_ii:nnn
         \exp_after:wN \__seq_get_right_loop:nw
@@ -5626,9 +5727,9 @@
 \cs_new:Npn \__seq_get_right_end:NnN #1#2#3 { \exp_not:n {#2} }
 \cs_generate_variant:Nn \seq_get_right:NN { c }
 \cs_new_protected:Npn \seq_pop_right:NN
-  { \__seq_pop:NNNN \__seq_pop_right:NNN \tl_set:Nx }
+  { \__seq_pop:NNNN \__seq_pop_right:NNN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gpop_right:NN
-  { \__seq_pop:NNNN \__seq_pop_right:NNN \tl_gset:Nx }
+  { \__seq_pop:NNNN \__seq_pop_right:NNN \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_pop_right:NNN #1#2#3
   {
     \cs_set_eq:NN \__seq_tmp:w \__seq_item:n
@@ -5640,7 +5741,7 @@
         #2
         {
           \if_false: { \fi: }
-          \tl_set:Nx #3
+          \__kernel_tl_set:Nx #3
         }
         { } \use_none:nn
     \cs_set_eq:NN \__seq_item:n \__seq_tmp:w
@@ -5668,10 +5769,10 @@
   { \__seq_pop_TF:NNNN \__seq_pop_left:NNN \tl_gset:Nn #1 #2 }
 \prg_new_protected_conditional:Npnn \seq_pop_right:NN #1#2
   { T , F , TF }
-  { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \tl_set:Nx #1 #2 }
+  { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \__kernel_tl_set:Nx #1 #2 }
 \prg_new_protected_conditional:Npnn \seq_gpop_right:NN #1#2
   { T , F , TF }
-  { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \tl_gset:Nx #1 #2 }
+  { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \__kernel_tl_gset:Nx #1 #2 }
 \prg_generate_conditional_variant:Nnn \seq_pop_left:NN { c }
   { T , F , TF }
 \prg_generate_conditional_variant:Nnn \seq_gpop_left:NN { c }
@@ -5819,9 +5920,9 @@
     \int_value:w \int_eval:w 1 + #2 ;
   }
 \cs_new_protected:Npn \seq_set_map_x:NNn
-  { \__seq_set_map_x:NNNn \tl_set:Nx }
+  { \__seq_set_map_x:NNNn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gset_map_x:NNn
-  { \__seq_set_map_x:NNNn \tl_gset:Nx }
+  { \__seq_set_map_x:NNNn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_set_map_x:NNNn #1#2#3#4
   {
     \__seq_push_item_def:n { \exp_not:N \__seq_item:n {#4} }
@@ -5829,9 +5930,9 @@
     \__seq_pop_item_def:
   }
 \cs_new_protected:Npn \seq_set_map:NNn
-  { \__seq_set_map:NNNn \tl_set:Nx }
+  { \__seq_set_map:NNNn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gset_map:NNn
-  { \__seq_set_map:NNNn \tl_gset:Nx }
+  { \__seq_set_map:NNNn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_set_map:NNNn #1#2#3#4
   {
     \__seq_push_item_def:n { \exp_not:n { \__seq_item:n {#4} } }
@@ -7478,7 +7579,7 @@
 \tl_new:N \g__sys_backend_tl
 \__sys_finalise:n
   {
-    \tl_gset:Nx \g__sys_backend_tl
+    \__kernel_tl_gset:Nx \g__sys_backend_tl
       {
         \sys_if_engine_xetex:TF
           { xdvipdfmx }
@@ -7594,9 +7695,9 @@
 \cs_new_eq:NN \clist_gset_eq:cN \tl_gset_eq:cN
 \cs_new_eq:NN \clist_gset_eq:cc \tl_gset_eq:cc
 \cs_new_protected:Npn \clist_set_from_seq:NN
-  { \__clist_set_from_seq:NNNN \clist_clear:N  \tl_set:Nx  }
+  { \__clist_set_from_seq:NNNN \clist_clear:N  \__kernel_tl_set:Nx  }
 \cs_new_protected:Npn \clist_gset_from_seq:NN
-  { \__clist_set_from_seq:NNNN \clist_gclear:N \tl_gset:Nx }
+  { \__clist_set_from_seq:NNNN \clist_gclear:N \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__clist_set_from_seq:NNNN #1#2#3#4
   {
     \seq_if_empty:NTF #4
@@ -7621,9 +7722,9 @@
 \cs_generate_variant:Nn \clist_gset_from_seq:NN {     Nc }
 \cs_generate_variant:Nn \clist_gset_from_seq:NN { c , cc }
 \cs_new_protected:Npn \clist_concat:NNN
-  { \__clist_concat:NNNN \tl_set:Nx }
+  { \__clist_concat:NNNN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \clist_gconcat:NNN
-  { \__clist_concat:NNNN \tl_gset:Nx }
+  { \__clist_concat:NNNN \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__clist_concat:NNNN #1#2#3#4
   {
     #1 #2
@@ -7640,9 +7741,9 @@
 \prg_new_eq_conditional:NNn \clist_if_exist:c \cs_if_exist:c
   { TF , T , F , p }
 \cs_new_protected:Npn \clist_set:Nn #1#2
-  { \tl_set:Nx #1 { \__clist_sanitize:n {#2} } }
+  { \__kernel_tl_set:Nx #1 { \__clist_sanitize:n {#2} } }
 \cs_new_protected:Npn \clist_gset:Nn #1#2
-  { \tl_gset:Nx #1 { \__clist_sanitize:n {#2} } }
+  { \__kernel_tl_gset:Nx #1 { \__clist_sanitize:n {#2} } }
 \cs_generate_variant:Nn \clist_set:Nn  { NV , No , Nx , c , cV , co , cx }
 \cs_generate_variant:Nn \clist_gset:Nn { NV , No , Nx , c , cV , co , cx }
 \cs_new_protected:Npn \clist_put_left:Nn
@@ -7683,9 +7784,9 @@
   { \tl_set:Nn #3 {#1} }
 \cs_generate_variant:Nn \clist_get:NN { c }
 \cs_new_protected:Npn \clist_pop:NN
-  { \__clist_pop:NNN \tl_set:Nx }
+  { \__clist_pop:NNN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \clist_gpop:NN
-  { \__clist_pop:NNN \tl_gset:Nx }
+  { \__clist_pop:NNN \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__clist_pop:NNN #1#2#3
   {
     \if_meaning:w #2 \c_empty_clist
@@ -7719,9 +7820,9 @@
   }
 \prg_generate_conditional_variant:Nnn \clist_get:NN { c } { T , F , TF }
 \prg_new_protected_conditional:Npnn \clist_pop:NN #1#2 { T , F , TF }
-  { \__clist_pop_TF:NNN \tl_set:Nx #1 #2 }
+  { \__clist_pop_TF:NNN \__kernel_tl_set:Nx #1 #2 }
 \prg_new_protected_conditional:Npnn \clist_gpop:NN #1#2 { T , F , TF }
-  { \__clist_pop_TF:NNN \tl_gset:Nx #1 #2 }
+  { \__clist_pop_TF:NNN \__kernel_tl_gset:Nx #1 #2 }
 \cs_new_protected:Npn \__clist_pop_TF:NNN #1#2#3
   {
     \if_meaning:w #2 \c_empty_clist
@@ -7768,9 +7869,9 @@
 \cs_generate_variant:Nn \clist_remove_duplicates:N  { c }
 \cs_generate_variant:Nn \clist_gremove_duplicates:N { c }
 \cs_new_protected:Npn \clist_remove_all:Nn
-  { \__clist_remove_all:NNNn \clist_set_from_seq:NN \tl_set:Nx }
+  { \__clist_remove_all:NNNn \clist_set_from_seq:NN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \clist_gremove_all:Nn
-  { \__clist_remove_all:NNNn \clist_gset_from_seq:NN \tl_gset:Nx }
+  { \__clist_remove_all:NNNn \clist_gset_from_seq:NN \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__clist_remove_all:NNNn #1#2#3#4
   {
     \__clist_if_wrap:nTF {#4}
@@ -7807,9 +7908,9 @@
 \cs_generate_variant:Nn \clist_remove_all:Nn  { c }
 \cs_generate_variant:Nn \clist_gremove_all:Nn { c }
 \cs_new_protected:Npn \clist_reverse:N #1
-  { \tl_set:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
+  { \__kernel_tl_set:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
 \cs_new_protected:Npn \clist_greverse:N #1
-  { \tl_gset:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
+  { \__kernel_tl_gset:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
 \cs_generate_variant:Nn \clist_reverse:N { c }
 \cs_generate_variant:Nn \clist_greverse:N { c }
 \cs_new:Npn \clist_reverse:n #1
@@ -8306,7 +8407,7 @@
       \tl_put_right:Nn \l__char_tmp_tl { ^^@ \if_false: } }
       \char_set_catcode_group_end:n { 0 }
       \tl_put_right:Nn \l__char_tmp_tl { { \fi: \exp_not:N \or: ^^@ } % }
-      \tl_set:Nx \l__char_tmp_tl { \l__char_tmp_tl }
+      \__kernel_tl_set:Nx \l__char_tmp_tl { \l__char_tmp_tl }
       \char_set_catcode_math_toggle:n { 0 }
       \tl_put_right:Nn \l__char_tmp_tl { \or: ^^@ }
       \char_set_catcode_alignment:n { 0 }
@@ -8725,6 +8826,7 @@
 \__token_tmp:w { char" }
 \__token_tmp:w { count }
 \__token_tmp:w { dimen }
+\__token_tmp:w { ~ font }
 \__token_tmp:w { macro }
 \__token_tmp:w { muskip }
 \__token_tmp:w { skip }
@@ -8772,6 +8874,7 @@
   { \tl_to_str:n { \protected } macro }
 \__token_tmp:w { protected_long_macro } { macro }
   { \token_to_str:N \protected \tl_to_str:n { \long } macro }
+\__token_tmp:w { font_selection } { ~ font } { select ~ font }
 \__token_tmp:w { dim_register } { dimen } { \token_to_str:N \dimen }
 \__token_tmp:w { int_register } { count } { \token_to_str:N \count }
 \__token_tmp:w { muskip_register } { muskip } { \token_to_str:N \muskip }
@@ -9237,8 +9340,8 @@
   }
 \prg_generate_conditional_variant:Nnn \prop_pop:NnN { c } { T , F , TF }
 \prg_generate_conditional_variant:Nnn \prop_gpop:NnN { c } { T , F , TF }
-\cs_new_protected:Npn \prop_put:Nnn  { \__prop_put:NNnn \tl_set:Nx }
-\cs_new_protected:Npn \prop_gput:Nnn { \__prop_put:NNnn \tl_gset:Nx }
+\cs_new_protected:Npn \prop_put:Nnn  { \__prop_put:NNnn \__kernel_tl_set:Nx }
+\cs_new_protected:Npn \prop_gput:Nnn { \__prop_put:NNnn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__prop_put:NNnn #1#2#3#4
   {
     \tl_set:Nn \l__prop_internal_tl
@@ -9259,9 +9362,9 @@
 \cs_generate_variant:Nn \prop_gput:Nnn
   { c , cnV , cno , cnx , cV , cVV , cVx , cvx , co , coo , cxx }
 \cs_new_protected:Npn \prop_put_if_new:Nnn
-  { \__prop_put_if_new:NNnn \tl_set:Nx }
+  { \__prop_put_if_new:NNnn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \prop_gput_if_new:Nnn
-  { \__prop_put_if_new:NNnn \tl_gset:Nx }
+  { \__prop_put_if_new:NNnn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__prop_put_if_new:NNnn #1#2#3#4
   {
     \tl_set:Nn \l__prop_internal_tl
@@ -10402,7 +10505,7 @@
       { \__ior_open_stream:Nn #1 {#2} }
       {
         \__ior_new:N #1
-        \tl_set:Nx \l__ior_stream_tl { \int_eval:n {#1} }
+        \__kernel_tl_set:Nx \l__ior_stream_tl { \int_eval:n {#1} }
         \__ior_open_stream:Nn #1 {#2}
       }
   }
@@ -10592,14 +10695,14 @@
 \tl_new:N \l__iow_file_name_tl
 \cs_new_protected:Npn \iow_open:Nn #1#2
   {
-    \tl_set:Nx \l__iow_file_name_tl
+    \__kernel_tl_set:Nx \l__iow_file_name_tl
       { \__kernel_file_name_sanitize:n {#2} }
     \iow_close:N #1
     \seq_gpop:NNTF \g__iow_streams_seq \l__iow_stream_tl
       { \__iow_open_stream:NV #1 \l__iow_file_name_tl }
       {
         \__iow_new:N #1
-        \tl_set:Nx \l__iow_stream_tl { \int_eval:n {#1} }
+        \__kernel_tl_set:Nx \l__iow_stream_tl { \int_eval:n {#1} }
         \__iow_open_stream:NV #1 \l__iow_file_name_tl
       }
   }
@@ -10675,7 +10778,7 @@
 \cs_new:Npn \__iow_unindent:w { }
 \cs_new_protected:Npn \__iow_set_indent:n #1
   {
-    \tl_set:Nx \l__iow_one_indent_tl
+    \__kernel_tl_set:Nx \l__iow_one_indent_tl
       { \exp_args:No \__kernel_str_to_other_fast:n { \tl_to_str:n {#1} } }
     \int_set:Nn \l__iow_one_indent_int
       { \str_count:N \l__iow_one_indent_tl }
@@ -10750,11 +10853,11 @@
       \cs_set_eq:NN \iow_indent:n \__iow_indent:n
       #3
       \cs_set_eq:NN \protect \token_to_str:N
-      \tl_set:Nx \l__iow_wrap_tl {#1}
+      \__kernel_tl_set:Nx \l__iow_wrap_tl {#1}
       \cs_set_eq:NN \iow_allow_break: \__iow_allow_break_error:
       \cs_set_eq:NN \iow_indent:n \__iow_indent_error:n
-      \tl_set:Nx \l__iow_newline_tl { \iow_newline: #2 }
-      \tl_set:Nx \l__iow_newline_tl { \tl_to_str:N \l__iow_newline_tl }
+      \__kernel_tl_set:Nx \l__iow_newline_tl { \iow_newline: #2 }
+      \__kernel_tl_set:Nx \l__iow_newline_tl { \tl_to_str:N \l__iow_newline_tl }
       \int_set:Nn \l__iow_line_target_int
         { \l_iow_line_count_int - \str_count:N \l__iow_newline_tl + 1 }
        \int_compare:nNnT { \l__iow_line_target_int } < 0
@@ -10770,12 +10873,12 @@
 \cs_generate_variant:Nn \iow_wrap:nnnN { nx }
 \cs_new_protected:Npn \__iow_wrap_do:
   {
-    \tl_set:Nx \l__iow_wrap_tl
+    \__kernel_tl_set:Nx \l__iow_wrap_tl
       {
         \exp_args:No \__kernel_str_to_other_fast:n \l__iow_wrap_tl
         \c__iow_wrap_end_marker_tl
       }
-    \tl_set:Nx \l__iow_wrap_tl
+    \__kernel_tl_set:Nx \l__iow_wrap_tl
       {
         \exp_after:wN \__iow_wrap_fix_newline:w \l__iow_wrap_tl
           ^^J \q__iow_nil ^^J \s__iow_stop
@@ -10933,7 +11036,7 @@
   }
 \cs_new_protected:Npn \__iow_wrap_allow_break:n #1
   {
-    \tl_set:Nx \l__iow_line_tl
+    \__kernel_tl_set:Nx \l__iow_line_tl
       { \l__iow_line_tl \__iow_wrap_trim:N \l__iow_line_part_tl }
     \bool_set_false:N \l__iow_line_break_bool
     \tl_if_empty:NTF \l__iow_line_part_tl
@@ -10953,7 +11056,7 @@
     \tl_put_right:Nx \l__iow_line_tl { \l__iow_line_part_tl }
     \bool_set_false:N \l__iow_line_break_bool
     \int_sub:Nn \l__iow_indent_int { \l__iow_one_indent_int }
-    \tl_set:Nx \l__iow_indent_tl
+    \__kernel_tl_set:Nx \l__iow_indent_tl
       { \exp_after:wN \__iow_unindent:w \l__iow_indent_tl }
     \__iow_wrap_chunk:nw {#1}
   }
@@ -10972,9 +11075,9 @@
   }
 \cs_new_protected:Npn \__iow_wrap_store_do:n #1
   {
-    \tl_set:Nx \l__iow_line_tl
+    \__kernel_tl_set:Nx \l__iow_line_tl
       { \l__iow_line_tl \l__iow_line_part_tl }
-    \tl_set:Nx \l__iow_wrap_tl
+    \__kernel_tl_set:Nx \l__iow_wrap_tl
       {
         \l__iow_wrap_tl
         \l__iow_newline_tl
@@ -11268,7 +11371,7 @@
 \cs_generate_variant:Nn \file_get_full_name:nN { V }
 \prg_new_protected_conditional:Npnn \file_get_full_name:nN #1#2 { T , F , TF }
   {
-    \tl_set:Nx #2
+    \__kernel_tl_set:Nx #2
       { \file_full_name:n {#1} }
     \tl_if_empty:NTF #2
       { \prg_return_false: }
@@ -11281,7 +11384,7 @@
   {
     \prg_set_protected_conditional:Npnn \file_get_full_name:nN #1#2 { T , F , TF }
       {
-        \tl_set:Nx \l__file_base_name_tl
+        \__kernel_tl_set:Nx \l__file_base_name_tl
           { \__kernel_file_name_sanitize:n {#1} }
         \__file_get_full_name_search:nN { } \use:n
         \seq_map_inline:Nn \l_file_search_path_seq
@@ -11316,7 +11419,7 @@
   }
 \cs_new_protected:Npn \__file_get_full_name_search:nN #1#2
   {
-    \tl_set:Nx \l__file_full_name_tl
+    \__kernel_tl_set:Nx \l__file_full_name_tl
       { \tl_to_str:n {#1} \l__file_base_name_tl }
     \__kernel_ior_open:No \g__file_internal_ior \l__file_full_name_tl
     \ior_if_eof:NF \g__file_internal_ior { #2 { \prg_break: } }
@@ -11423,7 +11526,7 @@
   { \__file_get_details:nnN {#1} { timestamp } #2 }
 \cs_new_protected:Npn \__file_get_details:nnN #1#2#3
   {
-    \tl_set:Nx #3
+    \__kernel_tl_set:Nx #3
       { \use:c { file_ #2 :n } {#1} }
     \tl_if_empty:NTF #3
       { \prg_return_false: }
@@ -11457,7 +11560,7 @@
 \prg_new_protected_conditional:Npnn \file_get_hex_dump:nnnN #1#2#3#4
   { T , F , TF }
   {
-    \tl_set:Nx #4
+    \__kernel_tl_set:Nx #4
       { \file_hex_dump:nnn {#1} {#2} {#3} }
     \tl_if_empty:NTF #4
       { \prg_return_false: }
@@ -13083,7 +13186,7 @@
   {
     \clist_clear:N \l__keys_unused_clist
     \__keys_set_known:nnn {#2} {#3} {#4}
-    \tl_set:Nx #5 { \exp_not:o \l__keys_unused_clist }
+    \__kernel_tl_set:Nx #5 { \exp_not:o \l__keys_unused_clist }
     \tl_set:Nn \l__keys_unused_clist {#1}
   }
 \cs_new_protected:Npn \keys_set_known:nn #1#2
@@ -13125,7 +13228,7 @@
   {
     \clist_clear:N \l__keys_unused_clist
     \__keys_set_filter:nnnn {#2} {#3} {#4} {#5}
-    \tl_set:Nx #6 { \exp_not:o \l__keys_unused_clist }
+    \__kernel_tl_set:Nx #6 { \exp_not:o \l__keys_unused_clist }
     \tl_set:Nn \l__keys_unused_clist {#1}
   }
 \cs_new_protected:Npn \keys_set_filter:nnn #1#2#3
@@ -13191,7 +13294,7 @@
   }
 \cs_new_protected:Npn \__keys_set_keyval:nnn #1#2#3
   {
-    \tl_set:Nx \l_keys_path_str
+    \__kernel_tl_set:Nx \l_keys_path_str
       {
         \tl_if_blank:nF {#1}
           { #1 / }
@@ -13389,7 +13492,7 @@
   }
 \cs_new_protected:Npn \__keys_store_unused_aux:
   {
-    \tl_set:Nx \l__keys_relative_tl
+    \__kernel_tl_set:Nx \l__keys_relative_tl
       { \exp_args:No \__keys_trim_spaces:n \l__keys_relative_tl }
     \use:x
       {
@@ -16027,9 +16130,9 @@
   { \cs_new_eq:NN #1 \c_zero_fp }
 \cs_generate_variant:Nn \fp_new:N {c}
 \cs_new_protected:Npn \fp_set:Nn   #1#2
-  { \tl_set:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
+  { \__kernel_tl_set:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
 \cs_new_protected:Npn \fp_gset:Nn  #1#2
-  { \tl_gset:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
+  { \__kernel_tl_gset:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
 \cs_new_protected:Npn \fp_const:Nn #1#2
   { \tl_const:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
 \cs_generate_variant:Nn \fp_set:Nn {c}
@@ -20461,6 +20564,9 @@
       \char_set_catcode_group_end:n        { 125 } % right brace
       \char_set_catcode_space:n            { 126 } % tilde
       \char_set_catcode_invalid:n          { 127 } % ^^?
+      \bool_lazy_or:nnF
+        { \sys_if_engine_xetex_p: } { \sys_if_engine_luatex_p: }
+        { \int_step_function:nnN { 128 } { 255 } \char_set_catcode_active:n }
       \__cctab_gset:n { \c_code_cctab }
     \group_end:
     \cctab_const:Nn \c_document_cctab
@@ -20629,7 +20735,7 @@
   {
     \group_begin:
       \__sort_main:NNNn \tl_map_inline:Nn \tl_map_break:n #2 {#3}
-      \tl_gset:Nx \g__sort_internal_tl
+      \__kernel_tl_gset:Nx \g__sort_internal_tl
         { \__sort_tl_toks:w \l__sort_min_int ; }
     \group_end:
     #1 #2 \g__sort_internal_tl
@@ -21012,7 +21118,7 @@
     \fi:
   }
 \group_begin:
-  \tl_set:Nx \l__str_internal_tl { \tl_to_str:n { 0123456789ABCDEF } }
+  \__kernel_tl_set:Nx \l__str_internal_tl { \tl_to_str:n { 0123456789ABCDEF } }
    \tl_map_inline:Nn \l__str_internal_tl
      {
         \tl_map_inline:Nn \l__str_internal_tl
@@ -21057,7 +21163,7 @@
   }
 \cs_new_protected:Npn \__str_convert_gmap:N #1
   {
-    \tl_gset:Nx \g__str_result_tl
+    \__kernel_tl_gset:Nx \g__str_result_tl
       {
         \exp_after:wN \__str_convert_gmap_loop:NN
         \exp_after:wN #1
@@ -21073,7 +21179,7 @@
   }
 \cs_new_protected:Npn \__str_convert_gmap_internal:N #1
   {
-    \tl_gset:Nx \g__str_result_tl
+    \__kernel_tl_gset:Nx \g__str_result_tl
       {
         \exp_after:wN \__str_convert_gmap_internal_loop:Nww
         \exp_after:wN #1
@@ -21123,7 +21229,7 @@
   {
     \group_begin:
       #1
-      \tl_gset:Nx \g__str_result_tl { \__kernel_str_to_other_fast:n {#4} }
+      \__kernel_tl_gset:Nx \g__str_result_tl { \__kernel_str_to_other_fast:n {#4} }
       \exp_after:wN \__str_convert:wwwnn
         \tl_to_str:n {#5} /// \s__str_stop
         { decode } { unescape }
@@ -21269,7 +21375,7 @@
     \cs_new_protected:Npn \__str_convert_unescape_:
       {
         \flag_clear:n { str_byte }
-        \tl_gset:Nx \g__str_result_tl
+        \__kernel_tl_gset:Nx \g__str_result_tl
           { \exp_args:No \__str_filter_bytes:n \g__str_result_tl }
         \__str_if_flag_error:nnx { str_byte } { non-byte } { bytes }
       }
@@ -21321,7 +21427,7 @@
 \cs_new_protected:Npn \__str_convert_decode_clist:
   {
     \clist_gset:No \g__str_result_tl \g__str_result_tl
-    \tl_gset:Nx \g__str_result_tl
+    \__kernel_tl_gset:Nx \g__str_result_tl
       {
         \exp_args:No \clist_map_function:nN
           \g__str_result_tl \__str_decode_clist_char:n
@@ -21332,7 +21438,7 @@
 \cs_new_protected:Npn \__str_convert_encode_clist:
   {
     \__str_convert_gmap_internal:N \__str_encode_clist_char:n
-    \tl_gset:Nx \g__str_result_tl { \tl_tail:N \g__str_result_tl }
+    \__kernel_tl_gset:Nx \g__str_result_tl { \tl_tail:N \g__str_result_tl }
   }
 \cs_new:Npn \__str_encode_clist_char:n #1 { , #1 }
 \cs_new_protected:Npn \__str_declare_eight_bit_encoding:nnnn #1
@@ -21490,7 +21596,7 @@
     \group_begin:
       \flag_clear:n { str_error }
       \int_set:Nn \tex_escapechar:D { 92 }
-      \tl_gset:Nx \g__str_result_tl
+      \__kernel_tl_gset:Nx \g__str_result_tl
         {
           \__str_output_byte:w "
             \exp_last_unbraced:Nf \__str_unescape_hex_auxi:N
@@ -21539,7 +21645,7 @@
           \flag_clear:n { str_byte }
           \flag_clear:n { str_error }
           \int_set:Nn \tex_escapechar:D { 92 }
-          \tl_gset:Nx \g__str_result_tl
+          \__kernel_tl_gset:Nx \g__str_result_tl
             {
               \exp_after:wN #3 \g__str_result_tl
                 #1 ? { ? \prg_break: }
@@ -21592,13 +21698,13 @@
             \flag_clear:n { str_byte }
             \flag_clear:n { str_error }
             \int_set:Nn \tex_escapechar:D { 92 }
-            \tl_gset:Nx \g__str_result_tl
+            \__kernel_tl_gset:Nx \g__str_result_tl
               {
                 \exp_after:wN \__str_unescape_string_newlines:wN
                   \g__str_result_tl \prg_break: ^^M ?
                 \prg_break_point:
               }
-            \tl_gset:Nx \g__str_result_tl
+            \__kernel_tl_gset:Nx \g__str_result_tl
               {
                 \exp_after:wN \__str_unescape_string_loop:wNNN
                   \g__str_result_tl #1 ?? { ? \prg_break: }
@@ -21829,7 +21935,7 @@
     \flag_clear:n { str_extra }
     \flag_clear:n { str_overlong }
     \flag_clear:n { str_overflow }
-    \tl_gset:Nx \g__str_result_tl
+    \__kernel_tl_gset:Nx \g__str_result_tl
       {
         \exp_after:wN \__str_decode_utf_viii_start:N \g__str_result_tl
           { \prg_break: \__str_decode_utf_viii_end: }
@@ -22029,7 +22135,7 @@
       \flag_clear:n { str_extra }
       \flag_clear:n { str_end }
       \cs_set:Npn \__str_tmp:w ##1 ##2 { ` ## #1 }
-      \tl_gset:Nx \g__str_result_tl
+      \__kernel_tl_gset:Nx \g__str_result_tl
         {
           \exp_after:wN \__str_decode_utf_xvi_pair:NN
             #2 \q__str_nil \q__str_nil
@@ -22186,7 +22292,7 @@
       \flag_clear:n { str_end }
       \flag_clear:n { str_error }
       \cs_set:Npn \__str_tmp:w ##1 ##2 { ` ## #1 }
-      \tl_gset:Nx \g__str_result_tl
+      \__kernel_tl_gset:Nx \g__str_result_tl
         {
           \exp_after:wN \__str_decode_utf_xxxii_loop:NNNN
             #2 \s__str_stop \s__str_stop \s__str_stop \s__str_stop
@@ -22466,7 +22572,7 @@
   }
 \cs_new_protected:Npn \__tl_analysis_b:n #1
   {
-    \tl_gset:Nx \g__tl_analysis_result_tl
+    \__kernel_tl_gset:Nx \g__tl_analysis_result_tl
       {
         \__tl_analysis_b_loop:w 0; #1
         \prg_break_point:
@@ -22867,7 +22973,7 @@
   {
     \int_compare:nNnTF \l__regex_curr_catcode_int = 0
       {
-        \tl_set:Nx \l__regex_internal_a_tl
+        \__kernel_tl_set:Nx \l__regex_internal_a_tl
           { \scan_stop: \__regex_curr_cs_to_str: \scan_stop: }
         \tl_if_in:noTF { \scan_stop: #1 \scan_stop: }
           \l__regex_internal_a_tl
@@ -22880,7 +22986,7 @@
     \int_compare:nNnT \l__regex_curr_catcode_int = 0
       {
         \group_begin:
-          \tl_set:Nx \l__regex_cs_name_tl { \__regex_curr_cs_to_str: }
+          \__kernel_tl_set:Nx \l__regex_cs_name_tl { \__regex_curr_cs_to_str: }
           \__regex_single_match:
           \__regex_disable_submatches:
           \__regex_build_for_cs:n {#1}
@@ -22978,7 +23084,7 @@
       \cs_set:Npn \__regex_escape_escaped:N ##1 { #2 }
       \cs_set:Npn \__regex_escape_raw:N ##1 { #3 }
       \__regex_standard_escapechar:
-      \tl_gset:Nx \g__regex_internal_tl
+      \__kernel_tl_gset:Nx \g__regex_internal_tl
         { \__kernel_str_to_other_fast:n {#4} }
       \tl_put_right:Nx \l__regex_internal_a_tl
         {
@@ -23736,12 +23842,12 @@
     \__regex_two_if_eq:NNNNTF #5 #6 \__regex_compile_special:N ^
       {
         \bool_set_false:N \l__regex_internal_bool
-        \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
+        \__kernel_tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
           \__regex_compile_class_posix_loop:w
       }
       {
         \bool_set_true:N \l__regex_internal_bool
-        \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
+        \__kernel_tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
           \__regex_compile_class_posix_loop:w #5 #6
       }
   }
@@ -24006,7 +24112,7 @@
   {
     \__regex_compile_end:
     \flag_clear:n { __regex_cs }
-    \tl_set:Nx \l__regex_internal_a_tl
+    \__kernel_tl_set:Nx \l__regex_internal_a_tl
       {
         \exp_after:wN \__regex_compile_cs_aux:Nn \l__regex_internal_regex
         \q__regex_nil \q__regex_nil \q__regex_recursion_stop
@@ -24067,7 +24173,7 @@
       {
         \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N \c_left_brace_str
           {
-            \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
+            \__kernel_tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi:
             \__regex_compile_u_loop:NN
           }
           {
@@ -24106,7 +24212,7 @@
   }
 \cs_new_protected:Npn \__regex_compile_u_in_cs:
   {
-    \tl_gset:Nx \g__regex_internal_tl
+    \__kernel_tl_gset:Nx \g__regex_internal_tl
       {
         \exp_args:No \__kernel_str_to_other_fast:n
           { \l__regex_internal_a_tl }
@@ -25531,7 +25637,7 @@
             \__regex_replacement_balance_one_match:n
               { \l__regex_zeroth_submatch_int }
           }
-        \tl_set:Nx \l__regex_internal_a_tl
+        \__kernel_tl_set:Nx \l__regex_internal_a_tl
           {
             \__regex_replacement_do_one_match:n
               { \l__regex_zeroth_submatch_int }
@@ -25561,7 +25667,7 @@
             { \l__regex_submatch_int - 1 }
             \__regex_replacement_balance_one_match:n
         }
-      \tl_set:Nx \l__regex_internal_a_tl
+      \__kernel_tl_set:Nx \l__regex_internal_a_tl
         {
           \int_step_function:nnnN
             { \l__regex_min_submatch_int }
@@ -27635,7 +27741,7 @@
   { \AtBeginDocument }
   { \use:n }
   {
-    \tl_set:Nx \l__coffin_display_font_tl
+    \__kernel_tl_set:Nx \l__coffin_display_font_tl
       {
         \cs_if_exist:NT \sffamily { \exp_not:N \sffamily }
         \cs_if_exist:NT \tiny { \exp_not:N \tiny }
@@ -28554,6 +28660,7 @@
 \cs_new:Npn \__text_change_case_aux:nnn #1#2#3
   {
     \group_align_safe_begin:
+    \cs_if_exist_use:c { __text_change_case_boundary_ #2 _ #3 :Nnnw }
     \__text_change_case_loop:nnw {#2} {#3} #1
       \q__text_recursion_tail \q__text_recursion_stop
     \__text_change_case_result:n { }
@@ -28629,6 +28736,7 @@
   }
   {
     \__text_change_case_store:n { ~ }
+    \cs_if_exist_use:c { __text_change_case_boundary_ #1 _ #2 :Nnnw }
     \__text_change_case_loop:nnw {#1} {#2}
   }
 \cs_new:Npn \__text_change_case_N_type:nnN #1#2#3
@@ -28761,16 +28869,10 @@
           { \__text_change_case_loop:nnw {#3} {#4} }
       }
   }
-\cs_new:Npx \__text_change_case_char_lower:nnN #1#2#3
+\cs_new:Npn \__text_change_case_char_lower:nnN #1#2#3
   {
-    \exp_not:N \cs_if_exist_use:cF { __text_change_case_lower_ #2 :nnnN }
-      {
-        \bool_lazy_or:nnTF
-          { \sys_if_engine_luatex_p: }
-          { \sys_if_engine_xetex_p: }
-          { \exp_not:N \__text_change_case_lower_sigma:nnnN }
-          { \exp_not:N \__text_change_case_char:nnnN }
-       }
+    \cs_if_exist_use:cF { __text_change_case_lower_ #2 :nnnN }
+      { \__text_change_case_lower_sigma:nnnN }
         {#1} {#1} {#2} #3
   }
 \cs_new:Npn \__text_change_case_char_upper:nnN #1#2#3
@@ -28779,7 +28881,7 @@
       { \__text_change_case_char:nnnN }
         {#1} {#1} {#2} #3
   }
-\bool_lazy_or:nnT
+\bool_lazy_or:nnTF
   { \sys_if_engine_luatex_p: }
   { \sys_if_engine_xetex_p: }
   {
@@ -28811,6 +28913,44 @@
         \__text_change_case_loop:nnw {#2} {#3} #4
       }
   }
+  {
+    \cs_new:Npn \__text_change_case_lower_sigma:nnnN #1#2#3#4
+      {
+        \int_compare:nNnTF { `#4 } = { "CE }
+          { \__text_change_case_lower_sigma:nnnNN  }
+          { \__text_change_case_char:nnnN }
+            {#1} {#2} {#3} #4
+      }
+    \cs_new:Npn \__text_change_case_lower_sigma:nnnNN #1#2#3#4#5
+      {
+        \int_compare:nNnTF { `#5 } = { "A3 }
+          { \__text_change_case_lower_sigma:nnw {#2} {#3}  }
+          { \__text_change_case_char:nnnN {#1} {#2} {#3} #4#5 }
+      }
+    \cs_new:Npn \__text_change_case_lower_sigma:nnw #1#2#3 \q__text_recursion_stop
+      {
+        \tl_if_head_is_N_type:nTF {#3}
+          { \__text_change_case_lower_sigma:nnN }
+          {
+            \__text_change_case_store:V \c__text_final_sigma_tl
+            \__text_change_case_loop:nnw
+          }
+        {#1} {#2} #3 \q__text_recursion_stop
+      }
+    \cs_new:Npn \__text_change_case_lower_sigma:nnN #1#2#3
+      {
+        \bool_lazy_or:nnTF
+          { \token_if_letter_p:N #3 }
+          {
+            \bool_lazy_and_p:nn
+              { \token_if_active_p:N #3 }
+              { \int_compare_p:nNn { `#3 } > { "80 } }
+          }
+          { \__text_change_case_store:V \c__text_sigma_tl }
+          { \__text_change_case_store:V \c__text_final_sigma_tl }
+        \__text_change_case_loop:nnw {#1} {#2} #3
+      }
+  }
 \cs_new:Npx \__text_change_case_char_title:nnN #1#2#3
   {
     \exp_not:N \bool_if:NTF \l_text_titlecase_check_letter_bool
@@ -28947,90 +29087,250 @@
       {
         \__text_change_case_if_greek:nTF { `#4 }
           {
-            \exp_args:Ne \__text_change_case_upper_el:nnnn
-              { \char_to_nfd:N #4 } {#1} {#2} {#3}
+            \exp_args:Ne \__text_change_case_upper_el:nnn
+              { \char_to_nfd:N #4 } {#2} {#3}
           }
           { \__text_change_case_char:nnnN {#1} {#2} {#3} #4 }
       }
-    \cs_new:Npn \__text_change_case_upper_el:nnnn #1#2#3#4
-      { \__text_change_case_upper_el_aux:nnnN {#2} {#3} {#4} #1 }
-    \cs_new:Npn \__text_change_case_upper_el_aux:nnnN #1#2#3#4
-      {
-        \__text_change_case_store:e { \use:c { char_ #1 case:N } #4 }
-        \__text_change_case_upper_el_loop:nnw {#2} {#3}
-      }
-    \cs_new:Npn \__text_change_case_upper_el_loop:nnw
-      #1#2#3 \q__text_recursion_stop
+    \cs_new:Npn \__text_change_case_upper_el:nnn #1#2#3
+      { \__text_change_case_upper_el:nnNw {#2} {#3} #1 }
+    \cs_new:Npn \__text_change_case_upper_el:nnNw #1#2#3#4 \q__text_recursion_stop
       {
-        \tl_if_head_is_N_type:nTF {#3}
-          { \__text_change_case_upper_el:nnN }
-          { \__text_change_case_loop:nnw }
-            {#1} {#2} #3 \q__text_recursion_stop
+        \tl_if_head_is_N_type:nTF {#4}
+          { \__text_change_case_upper_el:NnnN #3 }
+          {
+            \__text_change_case_store:e { \char_uppercase:N #3 }
+            \__text_change_case_loop:nnw
+          }
+            {#1} {#2} #4 \q__text_recursion_stop
       }
-    \cs_new:Npn \__text_change_case_upper_el:nnN #1#2#3
+    \cs_new:Npn \__text_change_case_upper_el:NnnN #1#2#3#4
       {
-        \token_if_cs:NTF #3
-          { \__text_change_case_loop:nnw {#1} {#2} #3 }
+        \token_if_cs:NTF #4
           {
-            \int_compare:nNnTF { `#3 } = { "0308 }
-              {
-                \__text_change_case_store:n {#3}
-                \__text_change_case_upper_el_loop:nnw {#1} {#2}
-              }
+            \__text_change_case_store:e { \char_uppercase:N #1 }
+            \__text_change_case_loop:nnw {#2} {#3} #4
+          }
+          {
+            \int_compare:nNnTF { `#4 } = { "0308 }
+              { \__text_change_case_upper_el_dialytika:nnN {#2} {#3} #1 }
               {
-                \bool_lazy_any:nTF
-                  {
-                    { \int_compare_p:nNn { `#3 } = { "0300 } }
-                    { \int_compare_p:nNn { `#3 } = { "0301 } }
-                    { \int_compare_p:nNn { `#3 } = { "0304 } }
-                    { \int_compare_p:nNn { `#3 } = { "0306 } }
-                    { \int_compare_p:nNn { `#3 } = { "0308 } }
-                    { \int_compare_p:nNn { `#3 } = { "0313 } }
-                    { \int_compare_p:nNn { `#3 } = { "0314 } }
-                    { \int_compare_p:nNn { `#3 } = { "0342 } }
-                    { \int_compare_p:nNn { `#3 } = { "0340 } }
-                    { \int_compare_p:nNn { `#3 } = { "0341 } }
-                    { \int_compare_p:nNn { `#3 } = { "0343 } }
-                  }
-                  { \__text_change_case_upper_el_loop:nnw {#1} {#2} }
+                 \__text_change_case_if_greek_accent:nTF { `#4 }
+                  { \__text_change_case_upper_el_hiatus:nnNw {#2} {#3} #1 }
                   {
-                    \int_compare:nNnTF { `#3 } = { "0344 }
+                    \__text_change_case_if_greek_diacritic:nTF { `#4 }
                       {
-                        \__text_change_case_store:e
-                          {
-                            \char_generate:nn { "0308 }
-                              { \__text_char_catcode:N #3 }
-                          }
-                        \__text_change_case_upper_el_loop:nnw {#1} {#2}
+                        \__text_change_case_store:e { \char_uppercase:N #1 }
+                        \__text_change_case_loop:nnw {#2} {#3}
                       }
                       {
-                        \int_compare:nNnTF { `#3 } = { "0345 }
-                          { \__text_change_case_loop:nnw {#1} {#2} }
-                          { \__text_change_case_loop:nnw {#1} {#2} #3 }
+                        \__text_change_case_store:e { \char_uppercase:N #1 }
+                        \__text_change_case_loop:nnw {#2} {#3} #4
                       }
                   }
               }
           }
       }
-    \prg_new_conditional:Npnn \__text_change_case_if_greek:n #1 { TF }
+    \cs_new:Npn \__text_change_case_upper_el_dialytika:nnN #1#2#3
+      {
+        \__text_change_case_if_takes_dialytika:nTF { `#3 }
+          { \__text_change_case_upper_el_dialytika:N #3 }
+          { \__text_change_case_store:e { \char_uppercase:N #3 } }
+        \__text_change_case_upper_el_gobble:nnw {#1} {#2}
+      }
+    \cs_new:Npn \__text_change_case_upper_el_dialytika:N #1
+      {
+        \__text_change_case_store:e
+          {
+            \bool_lazy_or:nnTF
+              { \int_compare_p:nNn { `#1 } = { "0399 } }
+              { \int_compare_p:nNn { `#1 } = { "03B9 } }
+              { \char_generate:nn { "03AA } { \__text_char_catcode:N #1 } }
+              { \char_generate:nn { "03AB } { \__text_char_catcode:N #1 } }
+          }
+      }
+    \cs_new:Npn \__text_change_case_upper_el_hiatus:nnNw
+      #1#2#3#4 \q__text_recursion_stop
+      {
+        \__text_change_case_store:e { \char_uppercase:N #3 }
+        \tl_if_head_is_N_type:nTF {#4}
+          { \__text_change_case_upper_el_hiatus:nnN }
+          { \__text_change_case_loop:nnw }
+            {#1} {#2} #4 \q__text_recursion_stop
+      }
+    \cs_new:Npn \__text_change_case_upper_el_hiatus:nnN #1#2#3
+      {
+        \token_if_cs:NTF #3
+          { \__text_change_case_loop:nnw {#1} {#2} #3 }
+          {
+            \__text_change_case_if_takes_dialytika:nTF { `#3 }
+              {
+                \__text_change_case_upper_el_dialytika:N #3
+                \__text_change_case_upper_el_gobble:nnw {#1} {#2}
+              }
+              { \__text_change_case_loop:nnw {#1} {#2} #3 }
+          }
+      }
+    \cs_new:Npn \__text_change_case_upper_el_gobble:nnw
+      #1#2#3 \q__text_recursion_stop
+      {
+        \tl_if_head_is_N_type:nTF {#3}
+          { \__text_change_case_upper_el_gobble:nnN }
+          { \__text_change_case_loop:nnw }
+            {#1} {#2} #3 \q__text_recursion_stop
+      }
+    \cs_new:Npn \__text_change_case_upper_el_gobble:nnN #1#2#3
       {
-        \if_int_compare:w #1 < "0370 \exp_stop_f:
+        \bool_lazy_or:nnTF
+          { \token_if_cs_p:N #3 }
+          {
+            ! \bool_lazy_or_p:nn
+              { \__text_change_case_if_greek_accent_p:n { `#3 } }
+              { \__text_change_case_if_greek_diacritic_p:n { `#3 } }
+          }
+          { \__text_change_case_loop:nnw {#1} {#2} #3 }
+          { \__text_change_case_upper_el_gobble:nnw {#1} {#2} }
+      }
+  }
+\prg_new_conditional:Npnn \__text_change_case_if_greek:n #1 { TF }
+  {
+    \if_int_compare:w #1 < "0370 \exp_stop_f:
+      \prg_return_false:
+    \else:
+      \if_int_compare:w #1 > "03FF \exp_stop_f:
+        \if_int_compare:w #1 < "1F00 \exp_stop_f:
           \prg_return_false:
         \else:
-          \if_int_compare:w #1 > "03FF \exp_stop_f:
-            \if_int_compare:w #1 < "1F00 \exp_stop_f:
-              \prg_return_false:
+          \if_int_compare:w #1 > "1FFF \exp_stop_f:
+            \prg_return_false:
+          \else:
+            \prg_return_true:
+          \fi:
+        \fi:
+      \else:
+        \prg_return_true:
+      \fi:
+    \fi:
+  }
+\prg_new_conditional:Npnn \__text_change_case_if_greek_accent:n #1 { TF , p }
+  {
+    \if_int_compare:w #1 = "0300 \exp_stop_f:
+      \prg_return_true:
+    \else:
+      \if_int_compare:w #1 = "0301 \exp_stop_f:
+        \prg_return_true:
+      \else:
+        \if_int_compare:w #1 = "0342 \exp_stop_f:
+          \prg_return_true:
+        \else:
+          \if_int_compare:w #1 = "0302 \exp_stop_f:
+            \prg_return_true:
+          \else:
+            \if_int_compare:w #1 = "0303 \exp_stop_f:
+              \prg_return_true:
             \else:
-              \if_int_compare:w #1 > "1FFF \exp_stop_f:
-                \prg_return_false:
-              \else:
+              \if_int_compare:w #1 = "0311 \exp_stop_f:
                 \prg_return_true:
+              \else:
+                \prg_return_false:
               \fi:
             \fi:
+          \fi:
+        \fi:
+      \fi:
+    \fi:
+  }
+\prg_new_conditional:Npnn \__text_change_case_if_greek_diacritic:n
+  #1 { TF , p }
+  {
+    \if_int_compare:w #1 = "0304 \exp_stop_f:
+      \prg_return_true:
+    \else:
+      \if_int_compare:w #1 = "0306 \exp_stop_f:
+        \prg_return_true:
+      \else:
+        \if_int_compare:w #1 = "0313 \exp_stop_f:
+          \prg_return_true:
+        \else:
+          \if_int_compare:w #1 = "0314 \exp_stop_f:
+            \prg_return_true:
           \else:
+            \if_int_compare:w #1 = "0343 \exp_stop_f:
+              \prg_return_true:
+            \else:
+              \prg_return_false:
+            \fi:
+          \fi:
+        \fi:
+      \fi:
+    \fi:
+  }
+\prg_new_conditional:Npnn \__text_change_case_if_takes_dialytika:n #1 { TF }
+  {
+    \if_int_compare:w #1 = "0399 \exp_stop_f:
+      \prg_return_true:
+    \else:
+      \if_int_compare:w #1 = "03B9 \exp_stop_f:
+        \prg_return_true:
+      \else:
+        \if_int_compare:w #1 = "03A5 \exp_stop_f:
+          \prg_return_true:
+        \else:
+          \if_int_compare:w #1 = "03C5 \exp_stop_f:
             \prg_return_true:
+          \else:
+            \prg_return_false:
           \fi:
         \fi:
+      \fi:
+    \fi:
+   }
+\bool_lazy_or:nnT
+  { \sys_if_engine_luatex_p: }
+  { \sys_if_engine_xetex_p: }
+  {
+    \cs_new:Npn \__text_change_case_boundary_upper_el:Nnnw
+      #1#2#3#4 \q__text_recursion_stop
+      {
+        \tl_if_head_is_N_type:nTF {#4}
+          { \__text_change_case_boundary_upper_el:nnN }
+          { \__text_change_case_loop:nnw }
+            {#2} {#3} #4 \q__text_recursion_stop
+      }
+    \cs_new:Npn \__text_change_case_boundary_upper_el:nnN #1#2#3
+      {
+        \bool_lazy_or:nnTF
+          { \token_if_cs_p:N #3 }
+          {
+            ! \bool_lazy_or_p:nn
+              { \int_compare_p:nNn { `#3 } = { "03AE } }
+              { \int_compare_p:nNn { `#3 } = { "1F22 } }
+          }
+          { \__text_change_case_loop:nnw }
+          { \__text_change_case_boundary_upper_el:nnNw }
+            {#1} {#2} #3
+      }
+    \cs_new:Npn \__text_change_case_boundary_upper_el:nnNw
+      #1#2#3#4 \q__text_recursion_stop
+       {
+        \tl_if_head_is_N_type:nTF {#4}
+          { \__text_change_case_boundary_upper_el:NnnN #3 }
+          {
+            \__text_change_case_store:e
+              { \char_generate:nn { "0389 } { \__text_char_catcode:N #3 } }
+            \__text_change_case_loop:nnw
+          }
+            {#1} {#2} #4 \q__text_recursion_stop
+      }
+    \cs_new:Npn \__text_change_case_boundary_upper_el:NnnN #1#2#3#4
+      {
+        \token_if_letter:NTF #4
+          { \__text_change_case_loop:nnw {#2} {#3} #1#4 }
+          {
+            \__text_change_case_store:e
+              { \char_generate:nn { "0389 } { \__text_char_catcode:N #1 } }
+            \__text_change_case_loop:nnw {#2} {#3} #4
+          }
       }
   }
 \bool_lazy_or:nnT
@@ -29327,6 +29627,8 @@
       \__text_tmp:w \c__text_dotted_I_tl       { 0130 }
       \__text_tmp:w \c__text_i_ogonek_tl       { 012F }
       \__text_tmp:w \c__text_I_ogonek_tl       { 012E }
+      \__text_tmp:w \c__text_final_sigma_tl    { 03C2 }
+      \__text_tmp:w \c__text_sigma_tl          { 03C3 }
       \__text_tmp:w \c__text_grosses_Eszett_tl { 1E9E }
     }
 \group_end:
@@ -29529,6 +29831,16 @@
         { 042D } { 044D }
         { 042E } { 044E }
         { 042F } { 044F }
+        { 0370 } { 0371 }
+        { 0372 } { 0373 }
+        { 0376 } { 0377 }
+        { 03FD } { 037B }
+        { 03FE } { 037C }
+        { 03FF } { 037D }
+        { 0386 } { 03AC }
+        { 0388 } { 03AD }
+        { 0389 } { 03AE }
+        { 038A } { 03AF }
         { 0391 } { 03B1 }
         { 0392 } { 03B2 }
         { 0393 } { 03B3 }
@@ -29553,19 +29865,73 @@
         { 03A7 } { 03C7 }
         { 03A8 } { 03C8 }
         { 03A9 } { 03C9 }
+        { 03AA } { 03CA }
+        { 03AB } { 03CB }
+        { 038C } { 03CC }
+        { 038E } { 03CD }
+        { 038F } { 03CE }
+        { 03CF } { 03D7 }
         { 03D8 } { 03D9 }
         { 03DA } { 03DB }
         { 03DC } { 03DD }
         { 03DE } { 03DF }
         { 03E0 } { 03E1 }
+        { 03E2 } { 03E3 }
+        { 03E4 } { 03E5 }
+        { 03E6 } { 03E7 }
+        { 03E8 } { 03E9 }
+        { 03EA } { 03EB }
+        { 03EC } { 03ED }
+        { 03EE } { 03EF }
+        { 03F9 } { 03F2 }
+        { 037F } { 03F3 }
+        { 03F7 } { 03F8 }
+        { 03FA } { 03FB }
         \q_recursion_tail ?
         \q_recursion_stop
       \cs_set_protected:Npn \__text_tmp:w #1#2#3
         {
           \group_begin:
-            \cs_set_protected:Npn \__text_tmp:w ##1##2##3##4
+            \cs_set_protected:Npn \__text_tmp:w ##1##2##3##4##5##6##7##8
               {
                 \tl_const:cx
+                  {
+                    c__text_ #3 case_
+                    \char_generate:nn {##1} { 12 }
+                    \char_generate:nn {##2} { 12 }
+                    _tl
+                  }
+                  {
+                    \exp_after:wN \exp_after:wN \exp_after:wN
+                      \exp_not:N \char_generate:nn {##5} { 13 }
+                    \exp_after:wN \exp_after:wN \exp_after:wN
+                      \exp_not:N \char_generate:nn {##6} { 13 }
+                  }
+              }
+            \use:x
+              {
+                \__text_tmp:w
+                  \char_to_utfviii_bytes:n { "#1 }
+                  \char_to_utfviii_bytes:n { "#2 }
+              }
+          \group_end:
+        }
+      \__text_tmp:w { 0345 } { 0399 } { upper }
+      \__text_tmp:w { 03C2 } { 03A3 } { upper }
+      \__text_tmp:w { 03D0 } { 0392 } { upper }
+      \__text_tmp:w { 03D1 } { 0398 } { upper }
+      \__text_tmp:w { 03D5 } { 03A6 } { upper }
+      \__text_tmp:w { 03D6 } { 03A0 } { upper }
+      \__text_tmp:w { 03F0 } { 039A } { upper }
+      \__text_tmp:w { 03F1 } { 03A1 } { upper }
+      \__text_tmp:w { 03F4 } { 03B8 } { lower }
+      \__text_tmp:w { 03F5 } { 0395 } { upper }
+      \cs_set_protected:Npn \__text_tmp:w #1#2#3
+        {
+          \group_begin:
+            \cs_set_protected:Npn \__text_tmp:w ##1##2##3##4
+              {
+                \tl_const:cn
                   {
                     c__text_ #3 case_
                     \char_generate:nn {##1} { 12 }
@@ -29581,8 +29947,176 @@
       \__text_tmp:w { 00DF } { SS } { upper }
       \__text_tmp:w { 00DF } { Ss } { title }
       \__text_tmp:w { 0131 } { I }  { upper }
-    }
-  \group_end:
+      \cs_set_protected:Npn \__text_tmp:nnnnnn #1#2#3#4#5#6#7
+        {
+          \tl_const:cx
+            {
+              c__text_ #1 case_
+              \char_generate:nn {#2} { 12 }
+              \char_generate:nn {#3} { 12 }
+              \char_generate:nn {#4} { 12 }
+              _tl
+            }
+            {
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#5} { 13 }
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#6} { 13 }
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#7} { 13 }
+            }
+        }
+      \cs_set_protected:Npn \__text_tmp:w #1#2#3#4#5#6#7#8
+        {
+          \tl_const:cx
+            {
+              c__text_lowercase_
+              \char_generate:nn {#1} { 12 }
+              \char_generate:nn {#2} { 12 }
+              \char_generate:nn {#3} { 12 }
+              _tl
+            }
+            {
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#5} { 13 }
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#6} { 13 }
+              \exp_after:wN \exp_after:wN \exp_after:wN
+                \exp_not:N \char_generate:nn {#7} { 13 }
+            }
+          \__text_tmp:nnnnnn { upper } {#5} {#6} {#7} {#1} {#2} {#3}
+          \__text_tmp:nnnnnn { title } {#5} {#6} {#7} {#1} {#2} {#3}
+        }
+      \__text_loop:nn
+        { 1F08 } { 1F00 }
+        { 1F09 } { 1F01 }
+        { 1F0A } { 1F02 }
+        { 1F0B } { 1F03 }
+        { 1F0C } { 1F04 }
+        { 1F0D } { 1F05 }
+        { 1F0E } { 1F06 }
+        { 1F0F } { 1F07 }
+        { 1F18 } { 1F10 }
+        { 1F19 } { 1F11 }
+        { 1F1A } { 1F12 }
+        { 1F1B } { 1F13 }
+        { 1F1C } { 1F14 }
+        { 1F1D } { 1F15 }
+        { 1F28 } { 1F20 }
+        { 1F29 } { 1F21 }
+        { 1F2A } { 1F22 }
+        { 1F2B } { 1F23 }
+        { 1F2C } { 1F24 }
+        { 1F2D } { 1F25 }
+        { 1F2E } { 1F26 }
+        { 1F2F } { 1F27 }
+        { 1F38 } { 1F30 }
+        { 1F39 } { 1F31 }
+        { 1F3A } { 1F32 }
+        { 1F3B } { 1F33 }
+        { 1F3C } { 1F34 }
+        { 1F3D } { 1F35 }
+        { 1F3E } { 1F36 }
+        { 1F3F } { 1F37 }
+        { 1F48 } { 1F40 }
+        { 1F49 } { 1F41 }
+        { 1F4A } { 1F42 }
+        { 1F4B } { 1F43 }
+        { 1F4C } { 1F44 }
+        { 1F4D } { 1F45 }
+        { 1F59 } { 1F51 }
+        { 1F5B } { 1F53 }
+        { 1F5D } { 1F55 }
+        { 1F5F } { 1F57 }
+        { 1F68 } { 1F60 }
+        { 1F69 } { 1F61 }
+        { 1F6A } { 1F62 }
+        { 1F6B } { 1F63 }
+        { 1F6C } { 1F64 }
+        { 1F6D } { 1F65 }
+        { 1F6E } { 1F66 }
+        { 1F6F } { 1F67 }
+        { 1FBA } { 1F70 }
+        { 1FBB } { 1F71 }
+        { 1FC8 } { 1F72 }
+        { 1FC9 } { 1F73 }
+        { 1FCA } { 1F74 }
+        { 1FCB } { 1F75 }
+        { 1FDA } { 1F76 }
+        { 1FDB } { 1F77 }
+        { 1FF8 } { 1F78 }
+        { 1FF9 } { 1F79 }
+        { 1FEA } { 1F7A }
+        { 1FEB } { 1F7B }
+        { 1FFA } { 1F7C }
+        { 1FFB } { 1F7D }
+        { 1F88 } { 1F80 }
+        { 1F89 } { 1F81 }
+        { 1F8A } { 1F82 }
+        { 1F8B } { 1F83 }
+        { 1F8C } { 1F84 }
+        { 1F8D } { 1F85 }
+        { 1F8E } { 1F86 }
+        { 1F8F } { 1F87 }
+        { 1F98 } { 1F90 }
+        { 1F99 } { 1F91 }
+        { 1F9A } { 1F92 }
+        { 1F9B } { 1F93 }
+        { 1F9C } { 1F94 }
+        { 1F9D } { 1F95 }
+        { 1F9E } { 1F96 }
+        { 1F9F } { 1F97 }
+        { 1FA8 } { 1FA0 }
+        { 1FA9 } { 1FA1 }
+        { 1FAA } { 1FA2 }
+        { 1FAB } { 1FA3 }
+        { 1FAC } { 1FA4 }
+        { 1FAD } { 1FA5 }
+        { 1FAE } { 1FA6 }
+        { 1FAF } { 1FA7 }
+        { 1FB8 } { 1FB0 }
+        { 1FB9 } { 1FB1 }
+        { 1FBC } { 1FB3 }
+        { 1FCC } { 1FC3 }
+        { 1FD8 } { 1FD0 }
+        { 1FD9 } { 1FD1 }
+        { 1FE8 } { 1FE0 }
+        { 1FE9 } { 1FE1 }
+        { 1FEC } { 1FE5 }
+        { 1FFC } { 1FF3 }
+        \q_recursion_tail ?
+        \q_recursion_stop
+      \cs_set_protected:Npn \__text_tmp:w #1#2#3
+        {
+          \group_begin:
+            \cs_set_protected:Npn \__text_tmp:w ##1##2##3##4##5##6##7##8
+              {
+                \tl_const:cx
+                  {
+                    c__text_ #3 case_
+                    \char_generate:nn {##1} { 12 }
+                    \char_generate:nn {##2} { 12 }
+                    \char_generate:nn {##3} { 12 }
+                    _tl
+                  }
+                  {
+                    \exp_after:wN \exp_after:wN \exp_after:wN
+                      \exp_not:N \char_generate:nn {##5} { 13 }
+                    \exp_after:wN \exp_after:wN \exp_after:wN
+                      \exp_not:N \char_generate:nn {##6} { 13 }
+                  }
+              }
+            \use:x
+              {
+                \__text_tmp:w
+                  \char_to_utfviii_bytes:n { "#1 }
+                  \char_to_utfviii_bytes:n { "#2 }
+              }
+          \group_end:
+        }
+    \__text_tmp:w { 1FBE } { 0399 } { upper }
+  }
+\group_end:
 \group_begin:
   \cs_set_protected:Npn \__text_change_case_setup:NN #1#2
     {
@@ -29881,7 +30415,8 @@
   }
   { \text_declare_purify_equivalent:Nn #1 { } }
 \text_declare_purify_equivalent:Nn \begin { \use:c }
-\text_declare_purify_equivalent:Nn \end { \use:c }
+\text_declare_purify_equivalent:Nn \end { \__text_end_env:n }
+\cs_new:Npn \__text_end_env:n #1 { \cs:w end #1 \cs_end: }
 \text_declare_purify_equivalent:Nn \\ { }
 \tl_map_inline:nn
   { \{ \} \# \$ \% \_ }
@@ -30469,9 +31004,9 @@
   }
 \cs_generate_variant:Nn \seq_mapthread_function:NNN { Nc , c , cc }
 \cs_new_protected:Npn \seq_set_filter:NNn
-  { \__seq_set_filter:NNNn \tl_set:Nx }
+  { \__seq_set_filter:NNNn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gset_filter:NNn
-  { \__seq_set_filter:NNNn \tl_gset:Nx }
+  { \__seq_set_filter:NNNn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_set_filter:NNNn #1#2#3#4
   {
     \__seq_push_item_def:n { \bool_if:nT {#4} { \__seq_wrap_item:n {##1} } }
@@ -30479,9 +31014,9 @@
     \__seq_pop_item_def:
   }
 \cs_new_protected:Npn \seq_set_from_inline_x:Nnn
-  { \__seq_set_from_inline_x:NNnn \tl_set:Nx }
+  { \__seq_set_from_inline_x:NNnn \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \seq_gset_from_inline_x:Nnn
-  { \__seq_set_from_inline_x:NNnn \tl_gset:Nx }
+  { \__seq_set_from_inline_x:NNnn \__kernel_tl_gset:Nx }
 \cs_new_protected:Npn \__seq_set_from_inline_x:NNnn #1#2#3#4
   {
     \__seq_push_item_def:n { \exp_not:N \__seq_item:n {#4} }
@@ -30641,7 +31176,7 @@
       }
   }
 \cs_new_protected:Npn \tl_build_get:NN
-  { \__tl_build_get:NNN \tl_set:Nx }
+  { \__tl_build_get:NNN \__kernel_tl_set:Nx }
 \cs_new_protected:Npn \__tl_build_get:NNN #1#2#3
   { #1 #3 { \if_false: { \fi: \exp_after:wN \__tl_build_get:w #2 } } }
 \cs_new:Npn \__tl_build_get:w #1 \__tl_build_last:NNn #2#3#4
@@ -30656,12 +31191,12 @@
   { \exp_after:wN \exp_not:n \exp_after:wN { \if_false: } \fi: }
 \cs_new_protected:Npn \tl_build_end:N #1
   {
-    \__tl_build_get:NNN \tl_set:Nx #1 #1
+    \__tl_build_get:NNN \__kernel_tl_set:Nx #1 #1
     \exp_args:Nc \__tl_build_end_loop:NN { \cs_to_str:N #1 ' } \tl_clear:N
   }
 \cs_new_protected:Npn \tl_build_gend:N #1
   {
-    \__tl_build_get:NNN \tl_gset:Nx #1 #1
+    \__tl_build_get:NNN \__kernel_tl_gset:Nx #1 #1
     \exp_args:Nc \__tl_build_end_loop:NN { \cs_to_str:N #1 ' } \tl_gclear:N
   }
 \cs_new_protected:Npn \__tl_build_end_loop:NN #1#2
-- 
cgit v1.2.3

