[latex3-commits] [git/LaTeX3-latex3-latex3] luacmd: Extend LuaTeX emulation of \tex_filedump:N (584a5791c)

Marcel Fabian Krüger tex at 2krueger.de
Fri Aug 21 15:43:58 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : luacmd
Link       : https://github.com/latex3/latex3/commit/584a5791cf0cf7cf2686e3d1dd2b530d50711709

>---------------------------------------------------------------

commit 584a5791cf0cf7cf2686e3d1dd2b530d50711709
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed Aug 19 17:07:18 2020 +0200

    Extend LuaTeX emulation of \tex_filedump:N
    
    Add an option to dump a whole file without getting the length first.


>---------------------------------------------------------------

584a5791cf0cf7cf2686e3d1dd2b530d50711709
 l3kernel/l3file.dtx  | 16 +++++++++++++---
 l3kernel/l3names.dtx |  7 +++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 491d27a34..93f777937 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -2950,10 +2950,20 @@
   }
 \cs_new:Npn \file_hex_dump:n #1
   { \exp_args:Ne \@@_hex_dump:n { \file_full_name:n {#1} } }
-\cs_new:Npn \@@_hex_dump:n #1
+\sys_if_engine_luatex:TF
   {
-    \tl_if_blank:nF {#1}
-      { \tex_filedump:D length \tex_filesize:D {#1} {#1} }
+    \cs_new:Npn \@@_hex_dump:n #1
+      {
+        \tl_if_blank:nF {#1}
+          { \tex_filedump:D whole {#1} {#1} }
+      }
+  }
+  {
+    \cs_new:Npn \@@_hex_dump:n #1
+      {
+        \tl_if_blank:nF {#1}
+          { \tex_filedump:D length \tex_filesize:D {#1} {#1} }
+      }
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index 3ed1565f6..702b6f5b3 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1522,11 +1522,14 @@ end, 'global')
 %   An emulated primitive for getting a hexdump from a (partial) file.
 %   The length has a default of |0|. This is consistent with
 %   \pdfTeX, but it effectivly makes the primitive useless without an
-%   explicit |length|.
+%   explicit |length|. Therefore we allow the keyword |whole| to be used
+%   instead of a length, indicating that the whole remaining file should
+%   be read.
 %    \begin{macrocode}
 luacmd('tex_filedump:D', function()
   local offset = scan_keyword'offset' and scan_int() or nil
-  local length = scan_keyword'length' and scan_int() or 0
+  local length = scan_keyword'length' and scan_int()
+          or not scan_keyword'whole' and 0 or nil
   local data = filedump(scan_string(), offset, length)
   if data then write(data) end
 end, 'global')





More information about the latex3-commits mailing list.