diff options
author | Karl Berry <karl@freefriends.org> | 2016-03-26 22:56:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-03-26 22:56:01 +0000 |
commit | acbc4b3c1d3629ae290305ff7c6056eb83d1151c (patch) | |
tree | 59c4ad13167b9bad138b2c231cbd6bc9f2c9c311 /Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | |
parent | 473c539aefe98fc932ea0ed651464b9f91482938 (diff) |
l3 (26mar16)
git-svn-id: svn://tug.org/texlive/trunk@40146 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 474 |
1 files changed, 96 insertions, 378 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 8bceb8e6661..d3432d6ba07 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3candidates.dtx Copyright(C) 2012-2016 The LaTeX3 Project +%% File: l3candidates.dtx Copyright (C) 2012-2016 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -38,7 +38,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3candidates.dtx 6376 2016-01-14 08:36:20Z joseph $ +\GetIdInfo$Id: l3candidates.dtx 6456 2016-03-25 21:09:37Z joseph $ {L3 Experimental additions to l3kernel} %</driver|package> %<*driver> @@ -94,7 +94,7 @@ % are being finalized. % \item Consider informing us that you use a particular function in your public package, e.g., by % discussing this on the \texttt{LaTeX-L} -% mailing list. This way it becomes easier to coordinate any updates necessary without a issues +% mailing list. This way it becomes easier to coordinate any updates necessary without issues % for the users of your package. % \item Discussing and understanding use cases for a particular addition or concept also helps to % ensure that we provide the right interfaces in the final version so please give us feedback @@ -970,8 +970,8 @@ % \end{verbatim} % irrespective of the expandability of |\"|. % -% The standard contents of this variable is |\"|, |\^|, |\'|, -% |\`|, |\.|, |\c|, |\u|, |\~|, |\H| and |\v| +% The standard contents of this variable is |\"|, |\'|, |\.|, |\^|, |\`|, +% |\~|, |\c|, |\H|, |\k|, |\r|, |\t|, |\u| and |\v|. % \end{variable} % % \enquote{Mixed} case conversion may be regarded informally as converting the @@ -1098,62 +1098,6 @@ % % \section{Additions to \pkg{l3tokens}} % -% \begin{function}[updated = 2015-11-12] -% { -% \char_set_active_eq:NN, \char_set_active_eq:Nc, -% \char_gset_active_eq:NN, \char_gset_active_eq:Nc -% } -% \begin{syntax} -% \cs{char_set_active_eq:NN} \meta{char} \meta{function} -% \end{syntax} -% Sets the behaviour of the \meta{char} in situations where it is -% active (category code $13$) to be equivalent to that of the -% \meta{function}. The category code of the \meta{char} is -% \emph{unchanged} by this process. The \meta{function} may itself -% be an active character. -% \end{function} -% -% \begin{function}[added = 2015-11-12] -% { -% \char_set_active_eq:nN, \char_set_active_eq:nc -% \char_gset_active_eq:nN, \char_gset_active_eq:nc -% } -% \begin{syntax} -% \cs{char_set_active_eq:nN} \Arg{integer expression} \meta{function} -% \end{syntax} -% Sets the behaviour of the \meta{char} which has character -% code as given by the \meta{integer expression} in situations -% where it is active (category code $13$) to be equivalent to that of the -% \meta{function}. The category code of the \meta{char} is -% \emph{unchanged} by this process. The \meta{function} may itself -% be an active character. -% \end{function} -% -% \begin{function}[EXP, added = 2015-09-09]{\char_generate:nn} -% \begin{syntax} -% \cs{char_generate:nn} \Arg{charcode} \Arg{catcode} -% \end{syntax} -% Generates a character token of the given \meta{charcode} and \meta{catcode} -% (both of which may be integer expressions). The \meta{catcode} may be -% one of -% \begin{itemize} -% \item $1$ (begin group) -% \item $2$ (end group) -% \item $3$ (math toggle) -% \item $4$ (alignment) -% \item $6$ (parameter) -% \item $7$ (math superscript) -% \item $8$ (math subscript) -% \item $11$ (letter) -% \item $12$ (other) -% \end{itemize} -% and other values will raise an error. -% -% The \meta{charcode} may be any one valid for the engine in use. Note -% however that for \XeTeX{} releases prior to 0.99992 only the 8-bit -% range ($0$ to $255$) is accepted due to engine limitations. -% \end{function} -% % \begin{function}[TF, updated = 2012-12-20]{\peek_N_type:} % \begin{syntax} % \cs{peek_N_type:TF} \Arg{true code} \Arg{false code} @@ -2012,14 +1956,14 @@ \cs_new_protected:Npn \@@_set_bounding:N #1 { \prop_put:Nnx \l_@@_bounding_prop { tl } - { { 0 pt } { \dim_use:N \box_ht:N #1 } } + { { 0 pt } { \dim_eval:n { \box_ht:N #1 } } } \prop_put:Nnx \l_@@_bounding_prop { tr } - { { \dim_use:N \box_wd:N #1 } { \dim_use:N \box_ht:N #1 } } - \dim_set:Nn \l_@@_internal_dim { - \box_dp:N #1 } + { { \dim_eval:n { \box_wd:N #1 } } { \dim_eval:n { \box_ht:N #1 } } } + \dim_set:Nn \l_@@_internal_dim { -\box_dp:N #1 } \prop_put:Nnx \l_@@_bounding_prop { bl } { { 0 pt } { \dim_use:N \l_@@_internal_dim } } \prop_put:Nnx \l_@@_bounding_prop { br } - { { \dim_use:N \box_wd:N #1 } { \dim_use:N \l_@@_internal_dim } } + { { \dim_eval:n { \box_wd:N #1 } } { \dim_use:N \l_@@_internal_dim } } } % \end{macrocode} % \end{macro} @@ -3074,7 +3018,7 @@ % \@@_change_case_output:nwn , % \@@_change_case_output:Vwn , % \@@_change_case_output:own , -% \@@_change_case_output:Vwn , +% \@@_change_case_output:vwn , % \@@_change_case_output:fwn , % } % \begin{macro}[aux, EXP]{\@@_change_case_end:wn} @@ -3094,10 +3038,10 @@ % {\@@_change_case_char_auxi:nN, \@@_change_case_char_auxii:nN} % \begin{macro}[aux] % {\@@_lookup_lower:N, \@@_lookup_upper:N, \@@_lookup_title:N} -% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFiix:nNN} -% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFiix:nNNN} -% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFiix:nNNNN} -% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFiix:nn} +% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFviii:nNN} +% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFviii:nNNN} +% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFviii:nNNNN} +% \begin{macro}[aux, EXP]{\@@_change_case_char_UTFviii:nn} % \begin{macro}[aux, EXP]{\@@_change_case_cs_letterlike:Nnn} % \begin{macro}[aux, EXP]{\@@_change_case_cs_accents:NN} % \begin{macro}[aux, EXP]{\@@_change_case_cs:N} @@ -3321,11 +3265,11 @@ \int_compare:nNnTF { `#2 } > { "80 } { \int_compare:nNnTF { `#2 } < { "E0 } - { \@@_change_case_char_UTFiix:nNNN {#1} #2 } + { \@@_change_case_char_UTFviii:nNNN {#1} #2 } { \int_compare:nNnTF { `#2 } < { "F0 } - { \@@_change_case_char_UTFiix:nNNNN {#1} #2 } - { \@@_change_case_char_UTFiix:nNNNNN {#1} #2 } + { \@@_change_case_char_UTFviii:nNNNN {#1} #2 } + { \@@_change_case_char_UTFviii:nNNNNN {#1} #2 } } } { \@@_change_case_char_auxi:nN {#1} #2 } @@ -3346,7 +3290,9 @@ \int_compare:nNnTF { \use:c { @@_lookup_ #1 :N } #2 } = { 0 } { \exp_stop_f: #2 } { - \utex_char:D \use:c { @@_lookup_ #1 :N } #2 + \char_generate:nn + { \use:c { @@_lookup_ #1 :N } #2 } + { \char_value_catcode:n { \use:c { @@_lookup_ #1 :N } #2 } } } } \cs_new_protected:Npn \@@_lookup_lower:N #1 { \tex_lccode:D `#1 } @@ -3355,13 +3301,13 @@ } { \cs_new:Npn \@@_change_case_char_auxii:nN #1#2 { \exp_stop_f: #2 } - \cs_new:Npn \@@_change_case_char_UTFiix:nNNN #1#2#3#4 - { \@@_change_case_char_UTFiix:nnN {#1} {#2#4} #3 } - \cs_new:Npn \@@_change_case_char_UTFiix:nNNNN #1#2#3#4#5 - { \@@_change_case_char_UTFiix:nnN {#1} {#2#4#5} #3 } - \cs_new:Npn \@@_change_case_char_UTFiix:nNNNNN #1#2#3#4#5#6 - { \@@_change_case_char_UTFiix:nnN {#1} {#2#4#5#6} #3 } - \cs_new:Npn \@@_change_case_char_UTFiix:nnN #1#2#3 + \cs_new:Npn \@@_change_case_char_UTFviii:nNNN #1#2#3#4 + { \@@_change_case_char_UTFviii:nnN {#1} {#2#4} #3 } + \cs_new:Npn \@@_change_case_char_UTFviii:nNNNN #1#2#3#4#5 + { \@@_change_case_char_UTFviii:nnN {#1} {#2#4#5} #3 } + \cs_new:Npn \@@_change_case_char_UTFviii:nNNNNN #1#2#3#4#5#6 + { \@@_change_case_char_UTFviii:nnN {#1} {#2#4#5#6} #3 } + \cs_new:Npn \@@_change_case_char_UTFviii:nnN #1#2#3 { \cs_if_exist:cTF { c__unicode_ #1 _ \tl_to_str:n {#2} _tl } { @@ -3832,47 +3778,47 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP, int]{\__unicode_codepoint_to_UTFiix:n} -% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFiix_auxi:n} -% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFiix_auxii:Nnn} -% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFiix_auxiii:n} -% This code will convert a codepoint into the correct UTF-8 represenation. +% \begin{macro}[EXP, int]{\__unicode_codepoint_to_UTFviii:n} +% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFviii_auxi:n} +% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFviii_auxii:Nnn} +% \begin{macro}[EXP, aux]{\__unicode_codepoint_to_UTFviii_auxiii:n} +% This code will convert a codepoint into the correct UTF-8 representation. % As there are a variable number of octets, the result starts with the % numeral |1|--|4| to indicate the nature of the returned value. Note that % this code will cover the full range even though at this stage it is not % required here. Also note that longer-term this is likely to need a public % interface and/or moving to \pkg{l3str} (see experimental string -% conversions). In terms of the algoritm itself, see +% conversions). In terms of the algorithm itself, see % \url{https://en.wikipedia.org/wiki/UTF-8} for the octet pattern. % \begin{macrocode} -\cs_new:Npn \__unicode_codepoint_to_UTFiix:n #1 +\cs_new:Npn \__unicode_codepoint_to_UTFviii:n #1 { - \exp_args:Nf \__unicode_codepoint_to_UTFiix_auxi:n + \exp_args:Nf \__unicode_codepoint_to_UTFviii_auxi:n { \int_eval:n {#1} } } -\cs_new:Npn \__unicode_codepoint_to_UTFiix_auxi:n #1 +\cs_new:Npn \__unicode_codepoint_to_UTFviii_auxi:n #1 { \if_int_compare:w #1 > "80 ~ \if_int_compare:w #1 < "800 ~ 2 - \__unicode_codepoint_to_UTFiix_auxii:Nnn C {#1} { 64 } - \__unicode_codepoint_to_UTFiix_auxiii:n {#1} + \__unicode_codepoint_to_UTFviii_auxii:Nnn C {#1} { 64 } + \__unicode_codepoint_to_UTFviii_auxiii:n {#1} \else: \if_int_compare:w #1 < "10000 ~ 3 - \__unicode_codepoint_to_UTFiix_auxii:Nnn E {#1} { 64 * 64 } - \__unicode_codepoint_to_UTFiix_auxiii:n {#1} - \__unicode_codepoint_to_UTFiix_auxiii:n + \__unicode_codepoint_to_UTFviii_auxii:Nnn E {#1} { 64 * 64 } + \__unicode_codepoint_to_UTFviii_auxiii:n {#1} + \__unicode_codepoint_to_UTFviii_auxiii:n { \int_div_truncate:nn {#1} { 64 } } \else: 4 - \__unicode_codepoint_to_UTFiix_auxii:Nnn F + \__unicode_codepoint_to_UTFviii_auxii:Nnn F {#1} { 64 * 64 * 64 } - \__unicode_codepoint_to_UTFiix_auxiii:n + \__unicode_codepoint_to_UTFviii_auxiii:n { \int_div_truncate:nn {#1} { 64 * 64 } } - \__unicode_codepoint_to_UTFiix_auxiii:n + \__unicode_codepoint_to_UTFviii_auxiii:n { \int_div_truncate:nn {#1} { 64 } } - \__unicode_codepoint_to_UTFiix_auxiii:n {#1} + \__unicode_codepoint_to_UTFviii_auxiii:n {#1} \fi: \fi: @@ -3880,9 +3826,9 @@ 1 {#1} \fi: } -\cs_new:Npn \__unicode_codepoint_to_UTFiix_auxii:Nnn #1#2#3 +\cs_new:Npn \__unicode_codepoint_to_UTFviii_auxii:Nnn #1#2#3 { { \int_eval:n { "#10 + \int_div_truncate:nn {#2} {#3} } } } -\cs_new:Npn \__unicode_codepoint_to_UTFiix_auxiii:n #1 +\cs_new:Npn \__unicode_codepoint_to_UTFviii_auxiii:n #1 { { \int_eval:n { \int_mod:nn {#1} { 64 } + 128 } } } % \end{macrocode} % \end{macro} @@ -3916,7 +3862,7 @@ { \utex_char:D "0069 ~ \utex_char:D "0307 ~ \utex_char:D "0303 ~ } } \tl_const:Nx \c__unicode_dot_above_tl { \utex_char:D "0307 ~ } - \tl_const:Nx \c__unicode_upper_Eszett_tl { \utex_char:D "1E9E ~} + \tl_const:Nx \c__unicode_upper_Eszett_tl { \utex_char:D "1E9E ~ } } { \tl_const:Nn \c__unicode_std_sigma_tl { } @@ -3944,20 +3890,21 @@ { \tl_const:Nx #1 { \utex_char:D "#2 ~ } } } { - \char_set_catcode_active:N . - \char_set_catcode_active:N ! \cs_set_protected:Npn \@@_tmp:w #1#2 { \group_begin: \cs_set_protected:Npn \@@_tmp:w ##1##2##3 { - \char_set_lccode:nn { `\. } {##2} - \char_set_lccode:nn { `\! } {##3} - \tex_lowercase:D - { \tl_const:Nn #1 { . ! } } + \tl_const:Nx #1 + { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \__char_generate:nn {##2} { 13 } + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \__char_generate:nn {##3} { 13 } + } } \tl_set:Nx \l_@@_internal_a_tl - { \__unicode_codepoint_to_UTFiix:n {"#2} } + { \__unicode_codepoint_to_UTFviii:n {"#2} } \exp_after:wN \@@_tmp:w \l_@@_internal_a_tl \group_end: } @@ -3977,10 +3924,6 @@ % octets, so that is taken as read. % \begin{macrocode} \group_begin: - \char_set_catcode_active:N . - \char_set_catcode_active:N ! - \char_set_catcode_active:N ; - \char_set_catcode_active:N , \bool_if:nT { \sys_if_engine_pdftex_p: || \sys_if_engine_uptex_p: @@ -3991,24 +3934,39 @@ \quark_if_recursion_tail_stop:n {#1} \tl_set:Nx \l_@@_internal_a_tl { - \__unicode_codepoint_to_UTFiix:n {"#1} - \__unicode_codepoint_to_UTFiix:n {"#2} + \__unicode_codepoint_to_UTFviii:n {"#1} + \__unicode_codepoint_to_UTFviii:n {"#2} } \exp_after:wN \@@_tmp:w \l_@@_internal_a_tl \@@_loop:nn } \cs_set_protected:Npn \@@_tmp:w #1#2#3#4#5#6 { - \char_set_lccode:nn { `\. } {#2} - \char_set_lccode:nn { `\! } {#3} - \char_set_lccode:nn { `\; } {#5} - \char_set_lccode:nn { `\, } {#6} - \tex_lowercase:D + \tl_const:cx { - \tl_const:cn { c__unicode_lower_ \tl_to_str:n { . ! } _tl } - { ; , } - \tl_const:cn { c__unicode_upper_ \tl_to_str:n { ; , } _tl } - { . ! } + c__unicode_lower_ + \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 } + } + \tl_const:cx + { + c__unicode_upper_ + \char_generate:nn {#5} { 12 } + \char_generate:nn {#6} { 12 } + _tl + } + { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \__char_generate:nn {#2} { 13 } + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \__char_generate:nn {#3} { 13 } } } \@@_loop:nn @@ -4118,17 +4076,17 @@ \group_begin: \cs_set_protected:Npn \@@_tmp:w ##1##2##3 { - \char_set_lccode:nn { `\. } {##2} - \char_set_lccode:nn { `\! } {##3} - \tex_lowercase:D + \tl_const:cx { - \tl_const:cn - { c__unicode_ #3 _ \tl_to_str:n { . ! } _tl } + c__unicode_ #3 _ + \char_generate:nn {##2} { 12 } + \char_generate:nn {##3} { 12 } + _tl } - { #2 } + {#2} } \tl_set:Nx \l_@@_internal_a_tl - { \__unicode_codepoint_to_UTFiix:n { "#1 } } + { \__unicode_codepoint_to_UTFviii:n { "#1 } } \exp_after:wN \@@_tmp:w \l_@@_internal_a_tl \group_end: } @@ -4145,8 +4103,8 @@ \cs_set_protected:Npn \@@_change_case_setup:NN #1#2 { \quark_if_recursion_tail_stop:N #1 - \tl_const:cn { c_@@_change_case_lower_ \token_to_str:N #1 _tl } { #2 } - \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N #2 _tl } { #1 } + \tl_const:cn { c_@@_change_case_lower_ \token_to_str:N #1 _tl } { #2 } + \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N #2 _tl } { #1 } \@@_change_case_setup:NN } \@@_change_case_setup:NN @@ -4154,6 +4112,7 @@ \AE \ae \DH \dh \DJ \dj + \IJ \ij \L \l \NG \ng \O \o @@ -4162,8 +4121,8 @@ \TH \th \q_recursion_tail ? \q_recursion_stop - \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N \i _tl } { I } - \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N \j _tl } { J } + \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N \i _tl } { I } + \tl_const:cn { c_@@_change_case_upper_ \token_to_str:N \j _tl } { J } \group_end: % \end{macrocode} % @@ -4171,7 +4130,8 @@ % A list of accents to leave alone. % \begin{macrocode} \tl_new:N \l_tl_case_change_accents_tl -\tl_set:Nn \l_tl_case_change_accents_tl { \" \^ \' \` \. \c \u \~ \H \v } +\tl_set:Nn \l_tl_case_change_accents_tl + { \" \' \. \^ \` \~ \c \H \k \r \t \u \v } % \end{macrocode} % \end{variable} % @@ -4472,248 +4432,6 @@ % \subsection{Additions to \pkg{l3tokens}} % % \begin{macrocode} -%<@@=char> -% \end{macrocode} -% -% \begin{macro} -% {^^A -% \char_set_active_eq:NN, \char_gset_active_eq:NN, -% \char_set_active_eq:Nc, \char_gset_active_eq:Nc, -% \char_set_active_eq:nN, \char_gset_active_eq:nN, -% \char_set_active_eq:nc, \char_gset_active_eq:nc -% } -% Four simple functions with very similar definitions, so set up using -% an auxiliary. -% \begin{macrocode} -\group_begin: - \char_set_catcode_active:N \^^@ - \cs_set_protected:Npn \@@_tmp:nN #1#2 - { - \cs_new_protected:cpn { #1 :nN } ##1 - { - \group_begin: - \char_set_catcode_active:n { ##1 } - \char_set_lccode:nn { `\^^@ } { ##1 } - \tex_lowercase:D { \group_end: #2 ^^@ } - } - \cs_new_protected:cpx { #1 :NN } ##1 - { \exp_not:c { #1 : nN } { `##1 } } - } - \@@_tmp:nN { char_set_active_eq } \cs_set_eq:NN - \@@_tmp:nN { char_gset_active_eq } \cs_gset_eq:NN -\group_end: -\cs_generate_variant:Nn \char_set_active_eq:NN { Nc } -\cs_generate_variant:Nn \char_gset_active_eq:NN { Nc } -\cs_generate_variant:Nn \char_set_active_eq:nN { nc } -\cs_generate_variant:Nn \char_gset_active_eq:nN { nc } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[EXP]{\char_generate:nn} -% \begin{macro}[EXP, aux]{\@@_generate_aux:nn} -% \begin{macro}[EXP, aux]{\@@_generate_aux:nnw} -% \begin{variable}{\l_@@_tmp_tl} -% \begin{variable}{\c_@@_max_int} -% \begin{macro}[EXP, aux]{\@@_generate_invalid_catcode:} -% The aim here is to generate characters of (broadly) arbitrary category -% code. Where possible, that is done using engine support (\XeTeX{}, -% \LuaTeX{}). There are though various issues which are covered below. At -% the interface layer, turn the two arguments into integers up-front so -% this is only done once. -% \begin{macrocode} -\cs_new:Npn \char_generate:nn #1#2 - { - \exp:w \exp_after:wN \@@_generate_aux:w - \int_use:N \__int_eval:w #1 \exp_after:wN ; - \int_use:N \__int_eval:w #2 ; - } -% \end{macrocode} -% Before doing any actual conversion, first some special case filtering. -% The \tn{Ucharcat} primitive cannot make active chars, so that is turned -% off here: if the primitive gets altered then the code is already in -% place for 8-bit engines and will kick in for \LuaTeX{} too. Spaces -% are also banned here as \LuaTeX{} emulation only makes normal (charcode -% $32$ spaces. However, |^^@| is filtered out separately as that can't be -% done with macro emulation either, so is flagged up separately. That -% done, hand off to the engine-dependent part. -% \begin{macrocode} -\cs_new:Npn \@@_generate_aux:w #1 ; #2 ; - { - \if_int_compare:w #2 = \c_thirteen - \__msg_kernel_expandable_error:nn { kernel } { char-active } - \else: - \if_int_compare:w #2 = \c_ten - \if_int_compare:w #1 = \c_zero - \__msg_kernel_expandable_error:nn { kernel } { char-null-space } - \else: - \__msg_kernel_expandable_error:nn { kernel } { char-space } - \fi: - \else: - \if_int_odd:w 0 - \if_int_compare:w #2 < \c_one 1 \fi: - \if_int_compare:w #2 = \c_five 1 \fi: - \if_int_compare:w #2 = \c_nine 1 \fi: - \if_int_compare:w #2 > \c_thirteen 1 \fi: \exp_stop_f: - \__msg_kernel_expandable_error:nn { kernel } - { char-invalid-catcode } - \else: - \if_int_odd:w 0 - \if_int_compare:w #1 < \c_zero 1 \fi: - \if_int_compare:w #1 > \c_@@_max_int 1 \fi: \exp_stop_f: - \__msg_kernel_expandable_error:nn { kernel } - { char-out-of-range } - \else: - \@@_generate_aux:nnw {#1} {#2} - \fi: - \fi: - \fi: - \fi: - \exp_end: - } -\tl_new:N \l_@@_tmp_tl -% \end{macrocode} -% Engine-dependent definitions are now needed for the implementation. For -% \LuaTeX{} and recent \XeTeX{} releases there is engine-level support. -% They can do cases that macro emulation can't. All of those are filtered -% out here using a primitive-based boolean expression for speed. -% The final level is the basic definition at the engine level: the arguments -% here are integers so there is no need to worry about them too much. -% \begin{macrocode} -\group_begin: -%<*package> - \char_set_catcode_active:N \^^L - \cs_set_nopar:Npn ^^L { } -%</package> - \char_set_catcode_other:n { 0 } - \if_int_odd:w 0 - \cs_if_exist:NT \luatex_directlua:D { 1 } - \cs_if_exist:NT \utex_charcat:D { 1 } \exp_stop_f: - \int_const:Nn \c_@@_max_int { 1114111 } - \cs_if_exist:NTF \luatex_directlua:D - { - \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \exp_after:wN \exp_end: - \luatex_directlua:D { l3kernel.charcat(#1, #2) } - } - } - { - \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \exp_after:wN \exp_end: - \utex_charcat:D #1 ~ #2 ~ - } - } - \else: -% \end{macrocode} -% For engines where \tn{Ucharcat} isn't available (or emulated) then we have -% to work in macros, and cover only the $8$-bit range. The first stage is -% to build up a |tl| containing |^^@| with each category code that can -% be accessed in this way, with an error set up for the other cases. This -% is all done such that it can be quickly accessed using a |\if_case:w| -% low-level conditional. There are a few things to notice here. -% As |^^L| is |\outer| we need to locally set it to avoid a problem. -% To get open/close braces into the list, they are set up using |\if_false:| -% pairing here and will later be |x|-type expanded into the desired form. -% For making spaces, there needs to be an |o|-type expansion of a |\use:n| -% (or some other tokenization) to avoid dropping the space. We also -% set up active tokens although they are (currently) filtered out by the -% interface layer (\tn{Ucharcat} cannot make active tokens). -% \begin{macrocode} - \int_const:Nn \c_@@_max_int { 255 } - \tl_set:Nn \l_@@_tmp_tl { \exp_not:N \or: } - \char_set_catcode_group_begin:n { 0 } % { - \tl_put_right:Nn \l_@@_tmp_tl { ^^@ \if_false: } } - \char_set_catcode_group_end:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { { \fi: \exp_not:N \or: ^^@ } % } - \tl_set:Nx \l_@@_tmp_tl { \l_@@_tmp_tl } - \char_set_catcode_math_toggle:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \char_set_catcode_alignment:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \tl_put_right:Nn \l_@@_tmp_tl { \or: } - \char_set_catcode_parameter:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \char_set_catcode_math_superscript:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \char_set_catcode_math_subscript:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \tl_put_right:Nn \l_@@_tmp_tl { \or: } - \char_set_catcode_space:n { 0 } - \tl_put_right:No \l_@@_tmp_tl { \use:n { \or: } ^^@ } - \char_set_catcode_letter:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \char_set_catcode_other:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } - \char_set_catcode_active:n { 0 } - \tl_put_right:Nn \l_@@_tmp_tl { \or: ^^@ } -% \end{macrocode} -% Convert the above temporary list into a series of constant token -% lists, one for each character code, using \tn{tex_lowercase:D} to -% convert |^^@| in each case. The \texttt{x}-type expansion deals with -% the |\if_false:| stuff introduced earlier. This is done in three parts -% as |^^L| is awkward. Notice that at this stage |^^@| is active. In -% format mode this is not needed. -% \begin{macrocode} - \cs_set_protected:Npn \@@_tmp:n #1 - { - \char_set_lccode:nn { 0 } {#1} - \char_set_lccode:nn { 32 } {#1} - \exp_args:Nx \tex_lowercase:D - { - \tl_const:Nn - \exp_not:c { c_@@_ \__int_to_roman:w #1 _tl } - { \exp_not:o \l_@@_tmp_tl } - } - } -%<*package> - \int_step_function:nnnN { 0 } { 1 } { 11 } \@@_tmp:n - \group_begin: - \tl_replace_once:Nnn \l_@@_tmp_tl { ^^@ } { \ERROR } - \@@_tmp:n { 12 } - \group_end: - \int_step_function:nnnN { 13 } { 1 } { 255 } \@@_tmp:n -%</package> -%<*initex> - \int_step_function:nnnN { 0 } { 1 } { 255 } \@@_tmp:n -%</initex> - \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \exp_after:wN \exp_after:wN - \exp_after:wN \exp_end: - \exp_after:wN \exp_after:wN - \if_case:w #2 - \exp_last_unbraced:Nv \exp_stop_f: - { c_@@_ \__int_to_roman:w #1 _tl } - \fi: - } - \fi: -\group_end: -% \end{macrocode} -% Job done, set up a few messages. -% \begin{macrocode} -\__msg_kernel_new:nnn { kernel } { char-active } - { Cannot~generate~active~chars. } -\__msg_kernel_new:nnn { kernel } { char-invalid-catcode } - { Invalid~catcode~for~char~generation. } -\__msg_kernel_new:nnn { kernel } { char-null-space } - { Cannot~generate~null~char~as~a~space. } -\__msg_kernel_new:nnn { kernel } { char-out-of-range } - { Charcode~requested~out~of~engine~range. } -\__msg_kernel_new:nnn { kernel } { char-space } - { Cannot~generate~space~chars. } -% \end{macrocode} -% \end{macro} -% \end{variable} -% \end{variable} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} %<@@=peek> % \end{macrocode} % |