summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-core.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/generic/context/luatex/luatex-core.lua')
-rw-r--r--tex/generic/context/luatex/luatex-core.lua72
1 files changed, 61 insertions, 11 deletions
diff --git a/tex/generic/context/luatex/luatex-core.lua b/tex/generic/context/luatex/luatex-core.lua
index 35005d1c8..6e1b31e96 100644
--- a/tex/generic/context/luatex/luatex-core.lua
+++ b/tex/generic/context/luatex/luatex-core.lua
@@ -1,18 +1,21 @@
-- luatex-core security and io overloads ...........
-- if not modules then modules = { } end modules ['luatex-core'] = {
--- version = 1.005,
+-- version = 1.080,
-- comment = 'companion to luatex',
-- author = 'Hans Hagen & Luigi Scarso',
-- copyright = 'LuaTeX Development Team',
-- }
-LUATEXCOREVERSION = 1.005
+LUATEXCOREVERSION = 1.080 -- we reflect the luatex version where changes happened
-- This file overloads some Lua functions. The readline variants provide the same
-- functionality as LuaTeX <= 1.04 and doing it this way permits us to keep the
-- original io libraries clean. Performance is probably even a bit better now.
+-- We test for functions already being defined so that we don't overload ones that
+-- are provided in the startup script.
+
local type, next, getmetatable, require = type, next, getmetatable, require
local find, gsub, format = string.find, string.gsub, string.format
@@ -51,7 +54,7 @@ local function luatex_io_open(name,how)
end
local function luatex_io_open_readonly(name,how)
- if how then
+ if not how then
how = 'r'
else
how = gsub(how,'[^rb]','')
@@ -171,6 +174,8 @@ if saferoption == 1 then
lfs.rmdir = installdummy("lfs.rmdir")
lfs.mkdir = installdummy("lfs.mkdir")
+ debug = nil
+
end
if saferoption == 1 or shellescape ~= 1 then
@@ -195,16 +200,20 @@ if md5 then
local format = string.format
local byte = string.byte
- function md5.sumhexa(k)
- return (gsub(sum(k), ".", function(c)
- return format("%02x",byte(c))
- end))
+ if not md5.sumhexa then
+ function md5.sumhexa(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02x",byte(c))
+ end))
+ end
end
- function md5.sumHEXA(k)
- return (gsub(sum(k), ".", function(c)
- return format("%02X",byte(c))
- end))
+ if not md5.sumHEXA then
+ function md5.sumHEXA(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02X",byte(c))
+ end))
+ end
end
end
@@ -367,6 +376,47 @@ do
if not loaded.socket then loaded.socket = loaded["socket.core"] end
if not loaded.mime then loaded.mime = loaded["mime.core"] end
+ if not loaded.lfs then loaded.lfs = lfs end
+
+end
+
+do
+
+ local lfsattributes = lfs.attributes
+ local symlinkattributes = lfs.symlinkattributes
+
+ -- these can now be done using lfs (was dead slow before)
+
+ if not lfs.isfile then
+ function lfs.isfile(name)
+ local m = lfsattributes(name,"mode")
+ return m == "file" or m == "link"
+ end
+ end
+
+ if not lfs.isdir then
+ function lfs.isdir(name)
+ local m = lfsattributes(name,"mode")
+ return m == "directory"
+ end
+ end
+
+ -- shortnames have also be sort of dropped from kpse
+
+ if not lfs.shortname then
+ function lfs.shortname(name)
+ return name
+ end
+ end
+
+ -- now there is a target field, so ...
+
+ if not lfs.readlink then
+ function lfs.readlink(name)
+ return symlinkattributes(name,"target") or nil
+ end
+ end
+
end
-- so far