[latex3-commits] [latex3/latex3] gh684-file_input-raw: Add \file_input_raw:n (dc053b14f)
github at latex-project.org
github at latex-project.org
Fri May 19 00:20:43 CEST 2023
Repository : https://github.com/latex3/latex3
On branch : gh684-file_input-raw
Link : https://github.com/latex3/latex3/commit/dc053b14f29860d176cd13a1aeab22ba340094ec
>---------------------------------------------------------------
commit dc053b14f29860d176cd13a1aeab22ba340094ec
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu May 18 23:20:43 2023 +0100
Add \file_input_raw:n
>---------------------------------------------------------------
dc053b14f29860d176cd13a1aeab22ba340094ec
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3file.dtx | 33 +++++++++++++++++++++++++++++++++
l3kernel/testfiles/m3file001.lvt | 8 ++++++++
l3kernel/testfiles/m3file001.tlg | 21 +++++++++++++--------
4 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index e5c86d73f..be00df406 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -10,6 +10,7 @@ this project uses date-based 'snapshot' version identifiers.
### Added
- Rounded out the `\use_i:nn...` functions to cover all cases taking
one argument from up to nine arguments
+- `\file_input_raw:n`
- `\int_if_zero:n(TF)`
### Fixed
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index b1c8e7c81..08d091368 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -917,6 +917,21 @@
% function. An error is raised if the file is not found.
% \end{function}
%
+% \begin{function}[added = 2023-05-18, EXP]{\file_input_raw:n}
+% \begin{syntax}
+% \cs{file_input_raw:n} \Arg{file name}
+% \end{syntax}
+% Searches for \meta{file name} in the path as detailed for
+% \cs{file_if_exist:nTF}, and if found reads in the file as
+% additional \TeX{} source. No data concerning the file is
+% tracked. If the file is not found, no action is taken.
+% \begin{texnote}
+% This function is intended only for contexts where files must
+% be read purely by expansion, for example at the start of a
+% table cell in a \tn{halign}.
+% \end{texnote}
+% \end{function}
+%
% \begin{function}[added = 2014-07-02]{\file_if_exist_input:n, \file_if_exist_input:nF}
% \begin{syntax}
% \cs{file_if_exist_input:n} \Arg{file name}
@@ -3355,6 +3370,24 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\file_input_raw:n, \@@_input:n}
+% No error checking, no tracking.
+% \begin{macrocode}
+\cs_new:Npn \file_input_raw:n #1
+ { \exp_args:Ne \@@_input_raw:n { \file_full_name:n {#1} } }
+\cs_new:Npx \@@_input_raw:n #1
+ {
+ \exp_not:N \tl_if_blank:nF {#1}
+ {
+ \exp_not:N \tex_input:D
+ \sys_if_engine_luatex:TF
+ { {#1} }
+ { \exp_not:N \__kernel_file_name_quote:n {#1} \scan_stop: }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\file_parse_full_name:n, \file_parse_full_name_apply:nN}
% The main parsing macro \cs{file_parse_full_name_apply:nN} passes the
% file name |#1| through \cs{__kernel_file_name_sanitize:n} so that we
diff --git a/l3kernel/testfiles/m3file001.lvt b/l3kernel/testfiles/m3file001.lvt
index 7f4b77eb8..db5400208 100644
--- a/l3kernel/testfiles/m3file001.lvt
+++ b/l3kernel/testfiles/m3file001.lvt
@@ -97,6 +97,14 @@
\file_input:n { \fileb }
}
+\TEST { Loading~a~file~raw }
+ {
+ \file_input_raw:n { filetest.txt }
+ \file_input_raw:n { \filea }
+ \file_input_raw:n { NotAFile.xxx.yyy.zzz }
+ \file_input_raw:n { \fileb }
+ }
+
\TEST { Loading~a~file~conditionally }
{
\file_if_exist_input:n { filetest.txt }
diff --git a/l3kernel/testfiles/m3file001.tlg b/l3kernel/testfiles/m3file001.tlg
index 7df92af4b..590c1529b 100644
--- a/l3kernel/testfiles/m3file001.tlg
+++ b/l3kernel/testfiles/m3file001.tlg
@@ -57,13 +57,18 @@ The requested file could not be found in the current directory, in the TeX
search path or in the LaTeX search path.
============================================================
============================================================
-TEST 6: Loading a file conditionally
+TEST 6: Loading a file raw
+============================================================
+(filetest.txt) (filetest.txt)
+============================================================
+============================================================
+TEST 7: Loading a file conditionally
============================================================
(filetest.txt) (filetest.txt)
FALSE
============================================================
============================================================
-TEST 7: Ending file_input
+TEST 8: Ending file_input
============================================================
(filetest-endinput.txt)
> \box...=
@@ -139,7 +144,7 @@ TEST 7: Ending file_input
l. ... }
============================================================
============================================================
-TEST 8: File name parsing
+TEST 9: File name parsing
============================================================
Path: "", Name: "", Ext: ""
Path: "", Name: "", Ext: ""
@@ -164,7 +169,7 @@ Path: "/", Name: "", Ext: "."
Path: "/", Name: " ", Ext: ""
============================================================
============================================================
-TEST 9: Expandable file name parsing
+TEST 10: Expandable file name parsing
============================================================
Path: "", Name: "", Ext: ""
Path: "", Name: "", Ext: ""
@@ -189,7 +194,7 @@ Path: "/", Name: "", Ext: "."
Path: "/", Name: " ", Ext: ""
============================================================
============================================================
-TEST 10: File listing
+TEST 11: File listing
============================================================
> File List <
filetest.txt
@@ -197,7 +202,7 @@ filetest-endinput.txt
.............
============================================================
============================================================
-TEST 11: File name sanitizing
+TEST 12: File name sanitizing
============================================================
> \l_tmpa_tl=foo.bar.
<recently read> }
@@ -227,7 +232,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 12: File name with invalid tokens
+TEST 13: File name with invalid tokens
============================================================
! Missing \endcsname inserted.
<to be read again>
@@ -323,7 +328,7 @@ followed by the required stuff, so I'm ignoring it.
l. ... }
============================================================
============================================================
-TEST 13: Getting file information
+TEST 14: Getting file information
============================================================
TRUE
TRUE
More information about the latex3-commits
mailing list.