diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 167 |
1 files changed, 135 insertions, 32 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 58c53afecc0..43c19185279 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2018-06-14} +% \date{Released 2018-08-23} % % \maketitle % @@ -137,19 +137,6 @@ % \end{texnote} % \end{function} % -% \begin{function}[EXP, added = 2018-04-17]{\use_x:n} -% \begin{syntax} -% \cs{use_x:n} \Arg{token list} -% \end{syntax} -% Fully expands the \meta{token list} in an \texttt{x}-type manner, -% \emph{but} the function remains fully expandable, and parameter -% character (usually~|#|) need not be doubled. -% \begin{texnote} -% \cs{use_x:n} the a wrapper around the primitive \tn{expanded}: -% it requires two expansions to complete its action. -% \end{texnote} -% \end{function} -% % \section{Additions to \pkg{l3box}} % % \subsection{Viewing part of a box} @@ -359,7 +346,7 @@ % If found, sets the \meta{str var} to the size of the file in bytes. % Where the file is not found, the \meta{str var} will be empty. % \begin{texnote} -% The \XeTeX{} engine provides no way to implement this function. +% Currently this is not available with \XeTeX{}. % \end{texnote} % \end{function} % @@ -375,7 +362,7 @@ % (UTC) or \meta{plus-minus}\meta{hours}|'|\meta{minutes}|'|. % Where the file is not found, the \meta{str var} will be empty. % \begin{texnote} -% The \XeTeX{} engine provides no way to implement this function. +% Currently this is not available with \XeTeX{}. % \end{texnote} % \end{function} % @@ -905,6 +892,24 @@ % \end{texnote} % \end{function} % +% \begin{function}[added = 2018-07-27, EXP, pTF] +% { +% \sys_if_platform_unix:, +% \sys_if_platform_windows: +% } +% \begin{syntax} +% \cs{sys_if_platform_unix:TF} \Arg{true code} \Arg{false code} +% \end{syntax} +% Conditionals which allow platform-specific code to be used. The names +% follow the \Lua{} |os.type()| function, \emph{i.e.}~all Unix-like systems +% are |unix| (including Linux and MacOS). +% \end{function} +% +% \begin{variable}[added = 2018-07-27]{\c_sys_platform_str} +% The current platform given as a lower case string: one of +% |unix|, |windows| or |unknown|. +% \end{variable} +% % \begin{variable}[added = 2017-05-27]{\c_sys_shell_escape_int} % This variable exposes the internal triple of the shell escape % status. The possible values are @@ -1225,6 +1230,21 @@ % argument. % \end{function} % +% \begin{function}[added = 2018-07-23] +% { +% \tl_set_from_shell:Nnn, \tl_set_from_shell:cnn, +% \tl_gset_from_shell:Nnn, \tl_gset_from_shell:cnn +% } +% \begin{syntax} +% \cs{tl_set_from_shell:Nnn} \meta{tl~var} \Arg{setup} \Arg{shell~command} +% \end{syntax} +% Defines \meta{tl} to the text returned by the \meta{shell command}. +% Category codes may need to be set appropriately via the \meta{setup} +% argument. If shell escape is disabled, the \meta{tl~var} will be empty. +% Note that quote characters (|"|) \emph{cannot} be used inside the +% \meta{shell command}. +% \end{function} +% % \begin{function}[EXP, added = 2016-12-06] % {\tl_rand_item:N, \tl_rand_item:c, \tl_rand_item:n} % \begin{syntax} @@ -2164,10 +2184,10 @@ \file_get_full_name:nN {#1} \l_@@_full_name_str \str_set:Nx #3 { - \lua_now_x:n + \lua_now:e { l3kernel.file#2 - ( " \lua_escape_x:n { \l_@@_full_name_str } " ) + ( " \lua_escape:e { \l_@@_full_name_str } " ) } } } @@ -2878,6 +2898,45 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_sys_platform_str} +% Detecting the platform on \LuaTeX{} is easy: for other engines, we use +% the fact that the two common cases have special null files. It is possible +% to probe further (see package \pkg{platform}), but that requires shell +% escape and seems unlikely to be useful. +% \begin{macrocode} +\sys_if_engine_luatex:TF + { + \str_const:Nx \c_sys_platform_str + { \lua_now:n { tex.print(os.type) } } + } + { + \file_if_exist:nTF { nul: } + { + \file_if_exist:nF { /dev/null } + { \str_const:Nn \c_sys_platform_str { windows } } + } + { + \file_if_exist:nT { /dev/null } + { \str_const:Nn \c_sys_platform_str { unix } } + } + } +\cs_if_exist:NF \c_sys_platform_str + { \str_const:Nn \c_sys_platform_str { unknown } } +% \end{macrocode} +% \end{variable} +% \begin{macro}[pTF]{\sys_if_platform_unix:} +% \begin{macro}[pTF]{\sys_if_platform_windows:} +% We can now set up the tests. +% \begin{macrocode} +\clist_map_inline:nn { unix , windows } + { + \@@_const:nn { sys_if_platform_ #1 } + { \str_if_eq_p:Vn \c_sys_platform_str { #1 } } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \begin{macro}[EXP, pTF]{\sys_if_shell:, \sys_if_shell_unrestricted:, \sys_if_shell_restricted:} % Performs a check for whether shell escape is enabled. The first set % of functions returns true if either of restricted or unrestricted @@ -2895,7 +2954,7 @@ % % \begin{variable}{\c_@@_shell_stream_int} % This is not needed for \LuaTeX{}: shell escape there isn't done using -% a \TeX{} interface +% a \TeX{} interface. % \begin{macrocode} \sys_if_engine_luatex:F { \int_const:Nn \c_@@_shell_stream_int { 18 } } @@ -2909,8 +2968,8 @@ { \cs_new_protected:Npn \sys_shell_now:n #1 { - \lua_now_x:n - { os.execute(" \lua_escape_x:n { \tl_to_str:n {#1} } ") } + \lua_now:e + { os.execute(" \lua_escape:e { \tl_to_str:n {#1} } ") } } } { @@ -2928,8 +2987,8 @@ { \cs_new_protected:Npn \sys_shell_shipout:n #1 { - \lua_shipout_x:n - { os.execute(" \lua_escape_x:n { \tl_to_str:n {#1} } ") } + \lua_shipout_e:n + { os.execute(" \lua_escape:e { \tl_to_str:n {#1} } ") } } } { @@ -3048,6 +3107,7 @@ % } % \begin{macro}{\@@_set_from_file:NNnn} % \begin{macro}{\@@_from_file_do:w} +% \begin{macro}{\@@_set_from:nNNn} % The approach here is similar to that for doing a rescan, and so the same % internals can be reused. Thus the plan is to insert a pair of tokens of % the same charcode but different catcodes after the file has been read. @@ -3066,25 +3126,32 @@ \str_if_empty:NTF \l_@@_file_name_str { \__kernel_file_missing:n {#4} } { - \group_begin: - \exp_args:No \tex_everyeof:D - { \c_@@_rescan_marker_tl \exp_not:N } - #3 \scan_stop: - \exp_after:wN \@@_from_file_do:w - \exp_after:wN \prg_do_nothing: - \tex_input:D \l_@@_file_name_str \scan_stop: - \exp_args:NNNo \group_end: - #1 #2 \l_@@_internal_a_tl + \exp_args:NV \@@_set_from:nNNn + \l_@@_file_name_str + #1 #2 {#3} } } \exp_args:Nno \use:nn { \cs_new_protected:Npn \@@_from_file_do:w #1 } { \c_@@_rescan_marker_tl } { \tl_set:No \l_@@_internal_a_tl {#1} } +\cs_new_protected:Npn \@@_set_from:nNNn #1#2#3#4 + { + \group_begin: + \exp_args:No \tex_everyeof:D + { \c_@@_rescan_marker_tl \exp_not:N } + #4 \scan_stop: + \exp_after:wN \@@_from_file_do:w + \exp_after:wN \prg_do_nothing: + \tex_input:D #1 \scan_stop: + \exp_args:NNNo \group_end: + #2 #3 \l_@@_internal_a_tl + } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro} % { @@ -3128,6 +3195,42 @@ % \end{macrocode} % \end{variable} % +% \begin{macro} +% { +% \tl_set_from_shell:Nnn, \tl_set_from_shell:cnn, +% \tl_gset_from_shell:Nnn, \tl_gset_from_shell:cnn +% } +% \begin{macro}{\@@_set_from_shell:NNnn} +% Setting using a shell is at this level just a slightly specialised file +% operation. +% \begin{macrocode} +\cs_new_protected:Npn \tl_set_from_shell:Nnn + { \@@_set_from_shell:NNnn \tl_set:Nn } +\cs_generate_variant:Nn \tl_set_from_shell:Nnn { c } +\cs_new_protected:Npn \tl_gset_from_shell:Nnn + { \@@_set_from_shell:NNnn \tl_gset:Nn } +\cs_generate_variant:Nn \tl_gset_from_shell:Nnn { c } +\cs_new_protected:Npn \@@_set_from_shell:NNnn #1#2#3#4 + { + \sys_if_shell:TF + { + \tl_set:Nn \l_@@_internal_a_tl {#4} + \tl_if_in:NnTF \l_@@_internal_a_tl { " } + { + \__kernel_msg_error:nnx + { kernel } { quote-in-shell } {#4} + } + { \@@_set_from:nNNn { | " #4 " } #1 #2 {#3} } + } + { #1 #2 { } } + } +\__kernel_msg_new:nnnn { kernel } { quote-in-shell } + { Quotes~in~shell~command~'#1'. } + { Shell~commands~cannot~contain~quotes~("). } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsubsection{Unicode case changing} % % The mechanisms needed for case changing are somewhat involved, particularly |