From ce9eb3564e7376e4452732aef5229a8461f52a09 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 13 Jan 2020 21:30:36 +0000
Subject: l3 (13jan20)

git-svn-id: svn://tug.org/texlive/trunk@53394 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/source/latex/l3kernel/l3luatex.dtx  | 60 +++++++++++++++++-----
 1 file changed, 48 insertions(+), 12 deletions(-)

(limited to 'Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx')

diff --git a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
index 22780b77fd9..a9f1f0c0a3d 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
@@ -2,7 +2,7 @@
 %
 %% File: l3luatex.dtx
 %
-% Copyright (C) 2010-2019 The LaTeX3 Project
+% Copyright (C) 2010-2020 The LaTeX3 Project
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -43,7 +43,7 @@
 %    }^^A
 % }
 %
-% \date{Released 2019-11-07}
+% \date{Released 2020-01-12}
 %
 % \maketitle
 %
@@ -143,6 +143,17 @@
 %   for user input.
 % \end{function}
 %
+% \begin{function}{l3kernel.filedump}
+%   \begin{syntax}
+%     |l3kernel.filedump(|\meta{file}|,|\meta{offset}|,|\meta{length}|)|
+%   \end{syntax}
+%   Returns the uppercase hexadecimal representation of the content of the
+%   \meta{file} read as bytes. If the \meta{length} is given, only this part
+%   of the file is returned; similarly, one may specify the \meta{offset} from
+%   the start of the file. If the \meta{length} is not given, the entire file
+%   is read starting at the \meta{offset}.
+% \end{function}
+%
 % \begin{function}{l3kernel.filemdfivesum}
 %   \begin{syntax}
 %     |l3kernel.filemdfivesum(|\meta{file}|)|
@@ -310,16 +321,17 @@ l3kernel = l3kernel or { }
 %
 %   Local copies of global tables.
 %    \begin{macrocode}
-local io      = io
-local kpse    = kpse
-local lfs     = lfs
-local math    = math
-local md5     = md5
-local os      = os
-local string  = string
-local tex     = tex
-local texio   = texio
-local unicode = unicode
+local io       = io
+local kpse     = kpse
+local lfs      = lfs
+local math     = math
+local md5      = md5
+local os       = os
+local string   = string
+local tex      = tex
+local texio    = texio
+local tonumber = tonumber
+local unicode  = unicode
 %    \end{macrocode}
 %
 %   Local copies of standard functions.
@@ -395,6 +407,30 @@ l3kernel.resettimer = resettimer
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{l3kernel.filedump}
+%   Similar comments here to the next function: read the file in binary mode
+%   to avoid any line-end weirdness.
+%    \begin{macrocode}
+local function filedump(name,offset,length)
+  local file = kpse_find(name,"tex",true)
+  if file then
+    local length = tonumber(length) or lfs_attr(file,"size")
+    local offset = tonumber(offset) or 0
+    local f = open(file,"rb")
+    if f then
+      if offset > 0 then
+        f:seek("set",offset)
+      end
+      local data = f:read(length)
+      escapehex(data)
+      f:close()
+    end
+  end
+end
+l3kernel.filedump = filedump
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{l3kernel.filemdfivesum}
 %   Read an entire file and hash it: the hash function itself is a built-in.
 %   As Lua is byte-based there is no work needed here in terms of UTF-8
-- 
cgit v1.2.3

