From b3225c4301e7724de481f410444fef5463799b9d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 14 Jan 2020 03:00:43 +0000 Subject: CTAN sync 202001140300 --- macros/latex/contrib/l3kernel/l3luatex.dtx | 60 ++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 12 deletions(-) (limited to 'macros/latex/contrib/l3kernel/l3luatex.dtx') diff --git a/macros/latex/contrib/l3kernel/l3luatex.dtx b/macros/latex/contrib/l3kernel/l3luatex.dtx index 22780b77fd..a9f1f0c0a3 100644 --- a/macros/latex/contrib/l3kernel/l3luatex.dtx +++ b/macros/latex/contrib/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