[latex3-commits] [l3svn] r7318 - Document and test \ior_open:Nn and \ior_open:NnTF
noreply at latex-project.org
noreply at latex-project.org
Wed Jun 28 01:47:08 CEST 2017
Author: bruno
Date: 2017-06-28 01:47:06 +0200 (Wed, 28 Jun 2017)
New Revision: 7318
Modified:
trunk/l3kernel/l3file.dtx
trunk/l3kernel/testfiles/m3ior002.lvt
trunk/l3kernel/testfiles/m3ior002.tlg
Log:
Document and test \ior_open:Nn and \ior_open:NnTF
Modified: trunk/l3kernel/l3file.dtx
===================================================================
--- trunk/l3kernel/l3file.dtx 2017-06-27 23:13:35 UTC (rev 7317)
+++ trunk/l3kernel/l3file.dtx 2017-06-27 23:47:06 UTC (rev 7318)
@@ -198,6 +198,7 @@
% \meta{stream} is available for access immediately and will remain
% allocated to \meta{file name} until a \cs{ior_close:N} instruction
% is given or the \TeX{} run ends.
+% If the file is not found, an error is raised.
% \end{function}
%
% \begin{function}[added = 2013-01-12, TF]{\ior_open:Nn, \ior_open:cn}
@@ -1201,26 +1202,19 @@
% \end{macro}
%
% \begin{macro}{\ior_open:Nn, \ior_open:cn}
-% Opening an input stream requires a bit of pre-processing. The file name
-% is sanitized to deal with active characters, before an auxiliary adds a
-% path and checks that the file really exists. If those two tests pass, then
-% pass the information on to the lower-level function which deals with
-% streams.
+% Use the conditional version, with an error if the file is not found.
% \begin{macrocode}
\cs_new_protected:Npn \ior_open:Nn #1#2
- {
- \file_get_full_name:nN {#2} \l__file_full_name_str
- \str_if_empty:NTF \l__file_full_name_str
- { \__file_missing:n {#2} }
- { \@@_open:No #1 \l__file_full_name_str }
- }
+ { \ior_open:NnF #1 {#2} { \__file_missing:n {#2} } }
\cs_generate_variant:Nn \ior_open:Nn { c }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\ior_open:Nn, \ior_open:cn}
-% Much the same idea for opening a read with a conditional, except the
-% auxiliary function does not issue an error if the file is not found.
+% An auxiliary searches for the file in the \TeX{}, \LaTeXe{} and
+% \LaTeX3 paths. Then pass the file found to the lower-level function
+% which deals with streams. The |full_name| is empty when the file is
+% not found.
% \begin{macrocode}
\prg_new_protected_conditional:Npnn \ior_open:Nn #1#2 { T , F , TF }
{
Modified: trunk/l3kernel/testfiles/m3ior002.lvt
===================================================================
--- trunk/l3kernel/testfiles/m3ior002.lvt 2017-06-27 23:13:35 UTC (rev 7317)
+++ trunk/l3kernel/testfiles/m3ior002.lvt 2017-06-27 23:47:06 UTC (rev 7318)
@@ -19,6 +19,7 @@
\TEST { Mapping }
{
\OMIT
+ \ior_new:N \test
\ior_open:Nn \test { filetest.txt }
\int_zero:N \l_tmpa_int
\TIMO
@@ -65,6 +66,24 @@
\int_incr:N \l_tmpa_int
}
\TYPE { \int_use:N \l_tmpa_int \c_space_tl lines }
+ \OMIT
+ \ior_close:N \test
+ \TIMO
}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\TEST { Open~read~stream~with~conditional }
+ {
+ \ior_new:N \anothertestior
+ \ior_open:NnTF \anothertestior { thisfiledoesnotexist }
+ { \ERROR } { \FALSE }
+ \ior_open:Nn \anothertestior { thisfiledoesnotexist }
+ \ior_open:NnTF \anothertestior { filetest.txt }
+ { \TRUE } { \ERROR }
+ \ior_open:Nn \anothertestior { filetest.txt }
+ \ior_str_get:NN \anothertestior \l_tmpa_tl
+ \tl_log:N \l_tmpa_tl
+ }
+
\END
Modified: trunk/l3kernel/testfiles/m3ior002.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3ior002.tlg 2017-06-27 23:13:35 UTC (rev 7317)
+++ trunk/l3kernel/testfiles/m3ior002.tlg 2017-06-27 23:47:06 UTC (rev 7318)
@@ -27,3 +27,26 @@
||
2 lines
============================================================
+============================================================
+TEST 3: Open read stream with conditional
+============================================================
+Defining \anothertestior on line ...
+FALSE
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/file-not-found"
+!
+! File 'thisfiledoesnotexist' not found.
+!
+! See the LaTeX3 documentation for further information.
+!
+! For immediate help type H <return>.
+!...............................................
+l. ... }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| The requested file could not be found in the current directory, in the TeX
+| search path or in the LaTeX search path.
+|...............................................
+TRUE
+> \l_tmpa_tl=\ExplSyntaxOff.
+============================================================
More information about the latex3-commits
mailing list