summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx140
1 files changed, 77 insertions, 63 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx b/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx
index ef39b6e3dc1..23a471d1a48 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx
@@ -41,7 +41,7 @@
% }^^A
% }
%
-% \date{Released 2019-01-01}
+% \date{Released 2019-01-12}
%
% \maketitle
%
@@ -73,7 +73,9 @@
% As only the data needs to remain at the end of this process, everything
% is set up inside a group. The only thing that is outside is creating a
% stream: they are global anyway and it is best to force a stream for
-% all engines.
+% all engines. For performance reasons, some of the code here is very
+% low-level: the material is read during loading \pkg{expl3} in package
+% mode.
% \begin{macrocode}
\ior_new:N \g_@@_data_ior
\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
@@ -84,6 +86,29 @@
% \begin{macrocode}
\cs_set_eq:NN \@@_generate:w \tex_Uchar:D
% \end{macrocode}
+% A fast local implementation for generating characters.
+% \begin{macrocode}
+ \cs_set:Npx \@@_generate:n #1
+ {
+ \sys_if_engine_luatex:TF
+ {
+ \exp_not:N \lua_now:e
+ {
+ l3kernel.charcat
+ (
+ \exp_not:N \tex_number:D #1 ,
+ \exp_not:N \tex_the:D \tex_catcode:D #1
+ )
+ }
+ }
+ {
+ \exp_not:N \tex_Ucharcat:D
+ \exp_not:N \tex_number:D #1 ~
+ \c_space_tl
+ \exp_not:N \tex_the:D \tex_catcode:D #1 ~
+ }
+ }
+% \end{macrocode}
% Parse the main Unicode data file for title case exceptions (the one-to-one
% lower and upper case mappings it contains are all be covered by the \TeX{}
% data). There are no comments in the main data file so this can be done using
@@ -96,23 +121,22 @@
\cs_set_protected:Npn \@@_data_auxii:w
#1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 \q_stop
{
- \tl_if_blank:nF {#7}
- {
- \str_if_eq:nnF {#5} {#7}
- {
- \tl_const:cx
- { c_@@_mixed_case_ \@@_generate:w "#1 _tl }
- {
- \char_generate:nn { "#7 }
- { \char_value_catcode:n { "#7 } }
- }
- }
- }
+ \cs_set_nopar:Npn \l_@@_tmpa_tl {#7}
+ \reverse_if:N \if_meaning:w \l_@@_tmpa_tl \c_empty_tl
+ \cs_set_nopar:Npn \l_@@_tmpb_tl {#5}
+ \reverse_if:N \if_meaning:w \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \tl_const:cx
+ { c_@@_mixed_case_ \@@_generate:w "#1 _tl }
+ { \@@_generate:n { "#7 } }
+ \fi:
+ \fi:
}
\ior_map_inline:Nn \g_@@_data_ior
{
- \tl_if_blank:nF {#1}
- { \@@_data_auxi:w #1 \q_stop }
+ \cs_set_nopar:Npn \l_@@_tmpa_tl {#1}
+ \reverse_if:N \if_meaning:w \l_@@_tmpa_tl \c_space_tl
+ \@@_data_auxi:w #1 \q_stop
+ \fi:
}
\ior_close:N \g_@@_data_ior
% \end{macrocode}
@@ -126,46 +150,37 @@
\ior_open:Nn \g_@@_data_ior { CaseFolding.txt }
\cs_set_protected:Npn \@@_data_auxi:w #1 ;~ #2 ;~ #3 ; #4 \q_stop
{
- \str_if_eq:nnTF {#2} { C }
- {
- \int_compare:nNnF
- { \char_value_lccode:n {"#1} } = {"#3}
- {
- \tl_const:cx
- { c_@@_fold_case_ \@@_generate:w "#1 _tl }
- {
- \char_generate:nn { "#3 }
- { \char_value_catcode:n { "#3 } }
- }
- }
- }
- {
- \str_if_eq:nnT {#2} { F }
- { \@@_data_auxii:w #1 ~ #3 ~ \q_stop }
- }
+ \if:w \tl_head:n { #2 ? } C
+ \reverse_if:N \if_int_compare:w
+ \char_value_lccode:n {"#1} = "#3 ~
+ \tl_const:cx
+ { c_@@_fold_case_ \@@_generate:w "#1 _tl }
+ { \@@_generate:n { "#3 } }
+ \fi:
+ \else:
+ \if:w \tl_head:n { #2 ? } F
+ \@@_data_auxii:w #1 ~ #3 ~ \q_stop
+ \fi:
+ \fi:
}
\cs_set_protected:Npn \@@_data_auxii:w #1 ~ #2 ~ #3 ~ #4 \q_stop
{
\tl_const:cx { c_@@_fold_case_ \@@_generate:w "#1 _tl }
{
- \char_generate:nn { "#2 }
- { \char_value_catcode:n { "#2 } }
- \char_generate:nn { "#3 }
- { \char_value_catcode:n { "#3 } }
+ \@@_generate:n { "#2 }
+ \@@_generate:n { "#3 }
\tl_if_blank:nF {#4}
- {
- \char_generate:nn { "#4 }
- { \char_value_catcode:n { "#4 } }
- }
+ { \@@_generate:n { "#4 } }
}
}
\ior_str_map_inline:Nn \g_@@_data_ior
{
- \tl_if_blank:nF {#1}
- {
- \str_if_eq:eeF { \tl_head:n {#1} } { \c_hash_str }
- { \@@_data_auxi:w #1 \q_stop }
- }
+ \cs_set_nopar:Npn \l_@@_tmpa_tl {#1}
+ \reverse_if:N \if_meaning:w \l_@@_tmpa_tl \c_empty_tl
+ \reverse_if:N \if:w \tl_head:n { #1 ? } \c_hash_str
+ \@@_data_auxi:w #1 \q_stop
+ \fi:
+ \fi:
}
\ior_close:N \g_@@_data_ior
% \end{macrocode}
@@ -189,31 +204,30 @@
{
\tl_const:cx { c_@@_ #2 _case_ \@@_generate:w "#1 _tl }
{
- \char_generate:nn { "#3 }
- { \char_value_catcode:n { "#3 } }
- \char_generate:nn { "#4 }
- { \char_value_catcode:n { "#4 } }
+ \@@_generate:n { "#3 }
+ \@@_generate:n { "#4 }
\tl_if_blank:nF {#5}
- {
- \char_generate:nn { "#5 }
- { \char_value_catcode:n { "#5 } }
- }
+ { \@@_generate:n { "#5 } }
}
}
}
\ior_str_map_inline:Nn \g_@@_data_ior
{
- \tl_if_blank:nF {#1}
- {
- \str_if_eq:eeTF { \tl_head:n {#1} } { \c_hash_str }
+ \cs_set_nopar:Npn \l_@@_tmpa_tl {#1}
+ \reverse_if:N \if_meaning:w \l_@@_tmpa_tl \c_empty_tl
+ \if:w \tl_head:n { #1 ? } \c_hash_str
+ \cs_set_nopar:Npx \l_@@_tmpb_tl
{
- \str_if_eq:eeT
- {#1}
- { \c_hash_str \c_space_tl Conditional~Mappings }
- { \ior_map_break: }
+ \c_hash_str \c_space_tl
+ \tl_to_str:n { Conditional~Mappings }
}
- { \@@_data_auxi:w #1 \q_stop }
- }
+ \if_meaning:w \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \exp_after:wN \exp_after:wN \exp_after:wN \ior_map_break:
+ \fi:
+ \else:
+ \@@_data_auxi:w #1 \q_stop
+ \fi:
+ \fi:
}
\ior_close:N \g_@@_data_ior
\group_end: