[latex3-commits] [latex3/latex3] main: Add \file_input_raw:n (3728ca0dc)
github at latex-project.org
github at latex-project.org
Fri May 26 09:22:47 CEST 2023
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/3728ca0dc8a8c5d0548c8f4da5b44b8934c03e0f
>---------------------------------------------------------------
commit 3728ca0dc8a8c5d0548c8f4da5b44b8934c03e0f
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu May 18 23:20:43 2023 +0100
Add \file_input_raw:n
>---------------------------------------------------------------
3728ca0dc8a8c5d0548c8f4da5b44b8934c03e0f
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 cee227f1f..8ba9a25f5 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -27,6 +27,7 @@ this project uses date-based 'snapshot' version identifiers.
- `\coffin_(g)reset_poles:N`
- `\dim_to_decimal_in_<unit>:n`, for `<unit>` types
`cc`, `cm`, `dd`, `in`, `mm` and `pc`
+- `\file_input_raw:n`
- `\int_if_zero:n(TF)`
- `\str_mdfive_hash:n`
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 3b21d3e60..203ea9a29 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -934,6 +934,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}
@@ -3395,6 +3410,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 cda2e07ee..86cca8160 100644
--- a/l3kernel/testfiles/m3file001.lvt
+++ b/l3kernel/testfiles/m3file001.lvt
@@ -96,6 +96,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.