[latex3-commits] [l3svn] r6942 - Use fewer explicit integers in l3file
noreply at latex-project.org
noreply at latex-project.org
Fri Feb 17 17:46:37 CET 2017
Author: bruno
Date: 2017-02-17 17:46:37 +0100 (Fri, 17 Feb 2017)
New Revision: 6942
Modified:
trunk/l3kernel/l3file.dtx
trunk/l3kernel/testfiles/m3iow001.tlg
trunk/l3kernel/testfiles/m3iow001.uptex.tlg
trunk/l3kernel/testfiles/m3iow001.xetex.tlg
Log:
Use fewer explicit integers in l3file
To use \c_term_iow as the top of the set of available streams,
I made it depend on the engine (128 for recent LuaTeX, 16 otherwise)
hence the testfile changes. This also corrects a bug whereby
\iow_close:N did nothing on streams >16 provided by LuaTeX.
Modified: trunk/l3kernel/l3file.dtx
===================================================================
--- trunk/l3kernel/l3file.dtx 2017-02-17 14:41:47 UTC (rev 6941)
+++ trunk/l3kernel/l3file.dtx 2017-02-17 16:46:37 UTC (rev 6942)
@@ -691,9 +691,9 @@
0 \tl_map_function:NN \l_@@_internal_name_tl
\@@_name_sanitize_aux:n
}
- \c_two
+ { 2 }
}
- = \c_zero
+ = 0
{
\tl_remove_all:Nn \l_@@_internal_name_tl { " }
\tl_if_in:NnT \l_@@_internal_name_tl { ~ }
@@ -714,10 +714,7 @@
}
}
\cs_new:Npn \@@_name_sanitize_aux:n #1
- {
- \token_if_eq_charcode:NNT #1 "
- { + \c_one }
- }
+ { \token_if_eq_charcode:NNT #1 " { + 1 } }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -925,7 +922,7 @@
% but non-existent stream number. Unlike writing, there is no concept
% of reading from the log.
% \begin{macrocode}
-\cs_new_eq:NN \c_term_ior \c_sixteen
+\int_const:Nn \c_term_ior { 16 }
% \end{macrocode}
% \end{variable}
%
@@ -964,14 +961,14 @@
\prop_new:N \g_@@_streams_prop
%<*package>
\int_step_inline:nnnn
- { \c_zero }
- { \c_one }
+ { 0 }
+ { 1 }
{
\cs_if_exist:NTF \normalend
{ \tex_count:D 38 \scan_stop: }
{
\tex_count:D 16 \scan_stop:
- \cs_if_exist:NT \loccount { - \c_one }
+ \cs_if_exist:NT \loccount { - 1 }
}
}
{
@@ -1100,7 +1097,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \ior_close:N #1
{
- \int_compare:nT { - \c_one < #1 < \c_sixteen }
+ \int_compare:nT { -1 < #1 < \c_term_ior }
{
\tex_closein:D #1
\prop_gremove:NV \g_@@_streams_prop #1
@@ -1147,21 +1144,23 @@
%
% \begin{macro}[pTF]{\ior_if_eof:N}
% To test if some particular input stream is exhausted the following
-% conditional is provided.
+% conditional is provided. The primitive test can only deal with
+% numbers in the range $[0,15]$ so we catch outliers (they are
+% exhausted).
% \begin{macrocode}
-\prg_new_conditional:Nnn \ior_if_eof:N { p , T , F , TF }
+\prg_new_conditional:Npnn \ior_if_eof:N #1 { p , T , F , TF }
{
\cs_if_exist:NTF #1
{
- \if_int_compare:w #1 = \c_sixteen
- \prg_return_true:
- \else:
- \if_eof:w #1
- \prg_return_true:
- \else:
- \prg_return_false:
- \fi:
- \fi:
+ \int_compare:nTF { -1 < #1 < \c_term_ior }
+ {
+ \if_eof:w #1
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ { \prg_return_true: }
}
{ \prg_return_true: }
}
@@ -1184,7 +1183,7 @@
{
\use:x
{
- \int_set:Nn \tex_endlinechar:D { - \c_one }
+ \int_set:Nn \tex_endlinechar:D { -1 }
\exp_not:n { \etex_readline:D #1 to #2 }
\int_set:Nn \tex_endlinechar:D { \int_use:N \tex_endlinechar:D }
}
@@ -1213,11 +1212,22 @@
%
% \begin{variable}{\c_log_iow, \c_term_iow}
% Here we allocate two output streams for writing to the transcript
-% file only (\cs{c_log_iow}) and to both the terminal and
-% transcript file (\cs{c_term_iow}).
+% file only (\cs{c_log_iow}) and to both the terminal and transcript
+% file (\cs{c_term_iow}). Recent \LuaTeX{} provide $128$ write
+% streams; we also use \cs{c_term_iow} as the first non-allowed write
+% stream so its value depends on the engine.
% \begin{macrocode}
\int_const:Nn \c_log_iow { -1 }
-\int_const:Nn \c_term_iow { 128 }
+\int_const:Nn \c_term_iow
+ {
+ \cs_if_exist:NTF \luatex_directlua:D
+ {
+ \int_compare:nNnTF \luatex_luatexversion:D > { 80 }
+ { 128 }
+ { 16 }
+ }
+ { 16 }
+ }
% \end{macrocode}
% \end{variable}
%
@@ -1226,15 +1236,12 @@
% \begin{macrocode}
\seq_new:N \g_@@_streams_seq
%<*initex>
-\seq_set_eq:NN \g_@@_streams_seq \g__ior_streams_seq
-\cs_if_exist:NT \luatex_directlua:D
+\use:x
{
- \int_compare:nNnT \luatex_luatexversion:D > { 80 }
+ \exp_not:n { \seq_gset_split:Nnn \g_@@_streams_seq { } }
{
- \int_step_inline:nnnn { 16 } { 1 } { 127 }
- {
- \seq_gput_right:Nn \g_@@_streams_seq {#1}
- }
+ \int_step_function:nnnN { 0 } { 1 } { \c_term_iow }
+ \prg_do_nothing:
}
}
%</initex>
@@ -1255,14 +1262,14 @@
\prop_new:N \g_@@_streams_prop
%<*package>
\int_step_inline:nnnn
- { \c_zero }
- { \c_one }
+ { 0 }
+ { 1 }
{
\cs_if_exist:NTF \normalend
{ \tex_count:D 39 \scan_stop: }
{
\tex_count:D 17 \scan_stop:
- \cs_if_exist:NT \loccount { - \c_one }
+ \cs_if_exist:NT \loccount { - 1 }
}
}
{
@@ -1339,7 +1346,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \iow_close:N #1
{
- \int_compare:nT { - \c_one < #1 < \c_sixteen }
+ \int_compare:nT { - \c_log_iow < #1 < \c_term_iow }
{
\tex_immediate:D \tex_closeout:D #1
\prop_gremove:NV \g_@@_streams_prop #1
@@ -1575,7 +1582,7 @@
% marginally nicer.
% \begin{macrocode}
\group_begin:
- \int_set:Nn \tex_escapechar:D { - \c_one }
+ \int_set:Nn \tex_escapechar:D { -1 }
\tl_const:Nx \c_@@_wrap_marker_tl
{ \tl_to_str:n { \^^I \^^O \^^W \^^_ \^^W \^^R \^^A \^^P } }
\group_end:
@@ -1639,7 +1646,7 @@
\cs_new_protected:Npn \iow_wrap:nnnN #1#2#3#4
{
\group_begin:
- \int_set:Nn \tex_escapechar:D { - \c_one }
+ \int_set:Nn \tex_escapechar:D { -1 }
\cs_set:Npx \{ { \token_to_str:N \{ }
\cs_set:Npx \# { \token_to_str:N \# }
\cs_set:Npx \} { \token_to_str:N \} }
@@ -1671,7 +1678,7 @@
\tl_set:Nx \l_@@_newline_tl { \iow_newline: #2 }
\tl_set:Nx \l_@@_newline_tl { \tl_to_str:N \l_@@_newline_tl }
\int_set:Nn \l_@@_line_target_int
- { \l_iow_line_count_int - \str_count:N \l_@@_newline_tl + \c_one }
+ { \l_iow_line_count_int - \str_count:N \l_@@_newline_tl + 1 }
% \end{macrocode}
% There is then a loop over the input, which will store the wrapped
% result in \cs{l_@@_wrap_tl}. After the loop, the resulting text is
@@ -1810,12 +1817,12 @@
}
\cs_new:Npn \@@_wrap_line_loop:w #1 ; #2#3#4#5#6#7#8#9
{
- \if_int_compare:w #1 < \c_eight
+ \if_int_compare:w #1 < 8 \exp_stop_f:
\@@_wrap_line_aux:Nw #1
\fi:
#2 #3 #4 #5 #6 #7 #8 #9
\exp_after:wN \@@_wrap_line_loop:w
- \__int_value:w \__int_eval:w #1 - \c_eight ;
+ \__int_value:w \__int_eval:w #1 - 8 ;
}
\cs_new:Npn \@@_wrap_line_aux:Nw #1#2#3 \exp_after:wN #4 ;
{
@@ -1839,7 +1846,7 @@
\cs_new:Npn \@@_wrap_line_end:NnnnnnnnN #1#2#3#4#5#6#7#8#9
{
#2 #3 #4 #5 #6 #7 #8
- \use_none:nnnnn \__int_eval:w \c_eight - ; #9
+ \use_none:nnnnn \__int_eval:w 8 - ; #9
\token_if_eq_charcode:NNTF \c_space_token #9
{ \@@_wrap_line_end:nw { } }
{ \if_false: { \fi: } \@@_wrap_break:w #9 }
Modified: trunk/l3kernel/testfiles/m3iow001.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3iow001.tlg 2017-02-17 14:41:47 UTC (rev 6941)
+++ trunk/l3kernel/testfiles/m3iow001.tlg 2017-02-17 16:46:37 UTC (rev 6942)
@@ -24,7 +24,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \mathchar"80
+| \mathchar"10
|...............................................
Defining \testa on line ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -45,7 +45,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \mathchar"80
+| \mathchar"10
|...............................................
Defining \testb on line ...
============================================================
Modified: trunk/l3kernel/testfiles/m3iow001.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3iow001.uptex.tlg 2017-02-17 14:41:47 UTC (rev 6941)
+++ trunk/l3kernel/testfiles/m3iow001.uptex.tlg 2017-02-17 16:46:37 UTC (rev 6942)
@@ -24,7 +24,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \kchar"80
+| \kchar"10
|...............................................
Defining \testa on line ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -45,7 +45,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \kchar"80
+| \kchar"10
|...............................................
Defining \testb on line ...
============================================================
Modified: trunk/l3kernel/testfiles/m3iow001.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3iow001.xetex.tlg 2017-02-17 14:41:47 UTC (rev 6941)
+++ trunk/l3kernel/testfiles/m3iow001.xetex.tlg 2017-02-17 16:46:37 UTC (rev 6942)
@@ -24,7 +24,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \char"80
+| \char"10
|...............................................
Defining \testa on line ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -45,7 +45,7 @@
| has already been used elsewhere.
|
| The current meaning is:
-| \char"80
+| \char"10
|...............................................
Defining \testb on line ...
============================================================
More information about the latex3-commits
mailing list