summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-08-26 17:33:09 +0000
committerKarl Berry <karl@freefriends.org>2014-08-26 17:33:09 +0000
commit6c4cd2ab2f8d1ebe3a051d700c3005d73eefe04c (patch)
tree16833d474c6532347c42dee6b34fa77aed22eca6 /Master/texmf-dist/source/latex/l3kernel/l3file.dtx
parent097e7dc0afa442be238a967b292237470680626e (diff)
l3 (26aug14)
git-svn-id: svn://tug.org/texlive/trunk@35045 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3file.dtx124
1 files changed, 108 insertions, 16 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
index a6a43277ac0..bded1318cdc 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
@@ -37,7 +37,7 @@
\documentclass[full]{l3doc}
%</driver>
%<*driver|package>
-\GetIdInfo$Id: l3file.dtx 5188 2014-07-09 12:02:22Z will $
+\GetIdInfo$Id: l3file.dtx 5369 2014-08-24 22:41:47Z bruno $
{L3 File and I/O operations}
%</driver|package>
%<*driver>
@@ -353,6 +353,13 @@
% at the point where the function is used but \emph{not} when the
% resulting tokens are written to the \meta{stream}
% (\emph{cf.}~\cs{iow_shipout_x:Nn}).
+% \begin{texnote}
+% When using \pkg{expl3} with a format other than \LaTeX{}, new line
+% characters inserted using \cs{iow_newline:} or using the
+% line-wrapping code \cs{iow_wrap:nnnN} will not be recognized in
+% the argument of \cs{iow_shipout:Nn}. This may lead to the
+% insertion of additionnal unwanted line-breaks.
+% \end{texnote}
% \end{function}
%
% \begin{function}[updated = 2012-09-08]{\iow_shipout_x:Nn, \iow_shipout_x:Nx, \iow_shipout_x:cn, \iow_shipout_x:cx}
@@ -367,6 +374,11 @@
% the page building process (such as the page number integer).
% \begin{texnote}
% This is a wrapper around the \TeX{} primitive \tn{write}.
+% When using \pkg{expl3} with a format other than \LaTeX{}, new line
+% characters inserted using \cs{iow_newline:} or using the
+% line-wrapping code \cs{iow_wrap:nnnN} will not be recognized in
+% the argument of \cs{iow_shipout:Nn}. This may lead to the
+% insertion of additionnal unwanted line-breaks.
% \end{texnote}
% \end{function}
%
@@ -391,6 +403,13 @@
% Function to add a new line within the \meta{tokens} written to a
% file. The function has no effect if writing is taking place without
% expansion (\emph{e.g.}~in the second argument of \cs{iow_now:Nn}).
+% \begin{texnote}
+% When using \pkg{expl3} with a format other than \LaTeX{}, the
+% character inserted by \cs{iow_newline:} will not be recognized by
+% \TeX{}, which may lead to the insertion of additionnal unwanted
+% line-breaks. This issue only affects \cs{iow_shipout:Nn},
+% \cs{iow_shipout_x:Nn} and direct uses of primitive operations.
+% \end{texnote}
% \end{function}
%
% \subsection{Wrapping lines in output}
@@ -540,6 +559,19 @@
% implementation of \cs{file_add_path:nN},
% \end{function}
%
+% \begin{function}[added = 2014-08-23]{\__iow_with:Nnn}
+% \begin{syntax}
+% \cs{__iow_with:Nnn} \meta{integer} \Arg{value} \Arg{code}
+% \end{syntax}
+% If the \meta{integer} is equal to the \meta{value} then this
+% function simply runs the \meta{code}. Otherwise it saves the
+% current value of the \meta{integer}, sets it to the \meta{value},
+% runs the \meta{code}, and restores the \meta{integer} to its former
+% value. This is used to ensure that the \tn{newlinechar} is~$10$
+% when writing to a stream, which lets \cs{iow_newline:} work, and
+% that \tn{errorcontextlines} is $-1$ when displaying a message.
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -677,9 +709,10 @@
}
}
{
- \__msg_kernel_error:nnx { kernel } { unbalanced-quote-in-filename }
+ \__msg_kernel_error:nnx
+ { kernel } { unbalanced-quote-in-filename }
{ \l_@@_internal_name_tl }
- }
+ }
\use:x
{
\group_end:
@@ -688,7 +721,7 @@
}
\cs_new:Npn \@@_name_sanitize_aux:n #1
{
- \str_if_eq:nnT {#1} { " }
+ \token_if_eq_charcode:NNT #1 "
{ + \c_one }
}
% \end{macrocode}
@@ -720,7 +753,8 @@
%<*package>
\cs_if_exist:NT \input@path
{
- \seq_set_eq:NN \l_@@_saved_search_path_seq \l_@@_search_path_seq
+ \seq_set_eq:NN \l_@@_saved_search_path_seq
+ \l_@@_search_path_seq
\seq_set_split:NnV \l_@@_internal_seq { , } \input@path
\seq_concat:NNN \l_@@_search_path_seq
\l_@@_search_path_seq \l_@@_internal_seq
@@ -737,7 +771,10 @@
}
%<*package>
\cs_if_exist:NT \input@path
- { \seq_set_eq:NN \l_@@_search_path_seq \l_@@_saved_search_path_seq }
+ {
+ \seq_set_eq:NN \l_@@_search_path_seq
+ \l_@@_saved_search_path_seq
+ }
%</package>
}
% \end{macrocode}
@@ -842,7 +879,8 @@
% \begin{macro}{\file_list:}
% A function to list all files used to the log, without duplicates.
% In package mode, if \cs{@filelist} is still defined, we need to take
-% it into account (we capture it \cs{AtBeginDocument} into
+% this list of file names into account
+% (we capture it \cs{AtBeginDocument} into
% \cs{g_@@_record_seq}), turning each file name into a string.
% \begin{macrocode}
\cs_new_protected_nopar:Npn \file_list:
@@ -921,11 +959,27 @@
%
% \begin{variable}{\g_@@_streams_prop}
% The name of the file attached to each stream is tracked in a property
-% list.
+% list. To get the correct number of reserved streams in package mode the
+% underlying mechanism needs to be queried. For \LaTeXe{} and plain \TeX{}
+% this data is stored in |\count16|: with the \pkg{etex} package loaded
+% we need to subtract $1$ as the register holds the number of the next
+% stream to use. In Con\TeX{}t, we need to look at |\count38| but there
+% is no subtraction: like the original plain \TeX{}/\LaTeXe{} mechanism
+% it holds the value of the \emph{last} stream allocated.
% \begin{macrocode}
\prop_new:N \g_@@_streams_prop
%<*package>
-\prop_gput:Nnn \g_@@_streams_prop { 0 } { LaTeX2e~reserved }
+\int_step_inline:nnnn
+ { \c_zero }
+ { \c_one }
+ {
+ \cs_if_exist:NTF \normalend
+ { \tex_count:D 38 \scan_stop: }
+ { \tex_count:D 16 \scan_stop: - \c_one }
+ }
+ {
+ \prop_gput:Nnn \g_@@_streams_prop {#1} { Reserved~by~format }
+ }
%</package>
% \end{macrocode}
% \end{variable}
@@ -1174,13 +1228,22 @@
% \end{variable}
%
% \begin{variable}{\g_@@_streams_prop}
-% As for reads, but with more reserved as \LaTeXe{} takes up a few here.
+% As for reads with the appropriate adjustment of the register numbers to
+% check on.
% \begin{macrocode}
\prop_new:N \g_@@_streams_prop
%<*package>
-\prop_put:Nnn \g_@@_streams_prop { 0 } { LaTeX2e~reserved }
-\prop_put:Nnn \g_@@_streams_prop { 1 } { LaTeX2e~reserved }
-\prop_put:Nnn \g_@@_streams_prop { 2 } { LaTeX2e~reserved }
+\int_step_inline:nnnn
+ { \c_zero }
+ { \c_one }
+ {
+ \cs_if_exist:NTF \normalend
+ { \tex_count:D 39 \scan_stop: }
+ { \tex_count:D 17 \scan_stop: - \c_one }
+ }
+ {
+ \prop_gput:Nnn \g_@@_streams_prop {#1} { Reserved~by~format }
+ }
%</package>
% \end{macrocode}
% \end{variable}
@@ -1288,6 +1351,27 @@
%
% \subsubsection{Immediate writing}
%
+% \begin{macro}[aux]{\@@_with:Nnn, \@@_with_aux:nNnn}
+% If the integer~|#1| is equal to~|#2|, just leave~|#3| in the input
+% stream. Otherwise, pass the old value to an auxiliary, which sets
+% the integer to the new value, runs the code, and restores the
+% integer.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_with:Nnn #1#2
+ {
+ \int_compare:nNnTF {#1} = {#2}
+ { \use:n }
+ { \exp_args:No \@@_with_aux:nNnn { \int_use:N #1 } #1 {#2} }
+ }
+\cs_new_protected:Npn \@@_with_aux:nNnn #1#2#3#4
+ {
+ \int_set:Nn #2 {#3}
+ #4
+ \int_set:Nn #2 {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\iow_now:Nn,\iow_now:Nx,\iow_now:cn,\iow_now:cx}
% This routine writes the second argument onto the output stream without
% expansion. If this stream isn't open, the output goes to the terminal
@@ -1295,10 +1379,17 @@
% internal error. We don't use the expansion done by \tn{write} to
% get the |Nx| variant, because it differs in subtle ways from
% \texttt{x}-expansion, namely, macro parameter characters would not
-% need to be doubled.
+% need to be doubled. We set the \tn{newlinechar} to~$10$ using
+% \cs{@@_with:Nnn} to support formats such as plain \TeX{}: otherwise,
+% \cs{iow_newline:} would not work. We do not do this for
+% \cs{iow_shipout:Nn} or \cs{iow_shipout_x:Nn}, as \TeX{} looks at the
+% value of the \tn{newlinechar} at shipout time in those cases.
% \begin{macrocode}
\cs_new_protected:Npn \iow_now:Nn #1#2
- { \tex_immediate:D \tex_write:D #1 { \exp_not:n {#2} } }
+ {
+ \@@_with:Nnn \tex_newlinechar:D { `\^^J }
+ { \tex_immediate:D \tex_write:D #1 { \exp_not:n {#2} } }
+ }
\cs_generate_variant:Nn \iow_now:Nn { c, Nx, cx }
% \end{macrocode}
% \end{macro}
@@ -1699,7 +1790,8 @@
{
\__int_value:w \__int_eval:w
\exp_after:wN \__str_count_loop:NNNNNNNNN \tl_to_str:n {#1}
- { X8 } { X7 } { X6 } { X5 } { X4 } { X3 } { X2 } { X1 } { X0 } \q_stop
+ { X8 } { X7 } { X6 } { X5 } { X4 } { X3 } { X2 } { X1 } { X0 }
+ \q_stop
\__int_eval_end:
}
\cs_new:Npn \__str_count_loop:NNNNNNNNN #1#2#3#4#5#6#7#8#9