summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs/lualibs.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs.lua159
1 files changed, 159 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
new file mode 100644
index 00000000000..f167a27ef85
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua
@@ -0,0 +1,159 @@
+--
+-- This is file `lualibs.lua',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- lualibs.dtx (with options: `lua')
+-- This is a generated file.
+--
+-- Copyright (C) 2009 by PRAGMA ADE / ConTeXt Development Team
+--
+-- See ConTeXt's mreadme.pdf for the license.
+--
+-- This work consists of the main source file lualibs.dtx
+-- and the derived file lualibs.lua.
+--
+do
+ local lualibs_module = {
+ name = "lualibs",
+ version = 0.93,
+ date = "2010/05/10",
+ description = "Lua additional functions.",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "See ConTeXt's mreadme.pdf for the license",
+ }
+ if luatexbase then
+ luatexbase.provides_module(lualibs_module)
+ end
+end
+
+kpse.set_program_name("luatex")
+
+
+local function load_lualibs_module(filename)
+ local path = kpse.find_file(filename)
+ if not path then
+ texio.write_nl(string.format("lualibs: error: cannot find file %s", filename))
+ return
+ end
+ texio.write_nl('log', string.format("lualibs: loading file %s", path))
+ --if (tex and tex.luatexversion and tex.luatexversion > 44)
+ -- or (status and status.luatex_version and status.luatex_version > 44) then
+ -- require(filename)
+ --else
+ dofile(path)
+ --end
+end
+
+load_lualibs_module("lualibs-string.lua")
+load_lualibs_module("lualibs-lpeg.lua")
+load_lualibs_module("lualibs-boolean.lua")
+load_lualibs_module("lualibs-number.lua")
+load_lualibs_module("lualibs-math.lua")
+load_lualibs_module("lualibs-table.lua")
+load_lualibs_module("lualibs-aux.lua")
+load_lualibs_module("lualibs-io.lua")
+load_lualibs_module("lualibs-os.lua")
+load_lualibs_module("lualibs-file.lua")
+load_lualibs_module("lualibs-md5.lua")
+load_lualibs_module("lualibs-dir.lua")
+load_lualibs_module("lualibs-unicode.lua")
+load_lualibs_module("lualibs-utils.lua")
+load_lualibs_module("lualibs-dimen.lua")
+load_lualibs_module("lualibs-url.lua")
+load_lualibs_module("lualibs-set.lua")
+load_lualibs_module("lualibs-dimen.lua")
+
+
+fpath = file
+fpath.split = file.split_path
+lfs.is_readable = file.is_readable
+lfs.is_writable = file.is_writable
+
+
+function string:stripspaces()
+ return (self:gsub("^%s*(.-)%s*$", "%1"))
+end
+
+
+lpeg.space = lpeg.S(" \t\f\v")
+lpeg.newline = lpeg.P("\r\n") + lpeg.P("\r") +lpeg.P("\n")
+
+
+function table.contains_value(t, val)
+ if t then
+ for k, v in pairs(t) do
+ if v==val then
+ return true
+ end
+ end
+ end
+ return false
+end
+
+
+function table.contains_key(t, key)
+ if t then
+ for k, v in pairs(t) do
+ if k==key then
+ return true
+ end
+ end
+ end
+ return false
+end
+
+
+function table.value_position(t, val)
+ if t then
+ local i=1
+ for k, v in pairs(t) do
+ if v==val then
+ return i
+ end
+ i=i+1
+ end
+ end
+ return 0
+end
+
+
+function table.key_position(t, key)
+ if t then
+ local i=1
+ for k,v in pairs(t) do
+ if k==key then
+ return i
+ end
+ i = i+1
+ end
+ end
+ return -1
+end
+
+
+function table.remove_key(t, k)
+ local p = table.key_position(t,k)
+ if p ~= -1 then
+ table.remove(t, table.key_position(t,k))
+ end
+end
+
+
+function fpath.normalize_sep(str)
+ return str:gsub("\\", "/")
+end
+
+
+function fpath.localize_sep(str)
+ if os.type == 'windows' or os.type == 'msdos' then
+ return str:gsub("/", "\\")
+ else
+ return str:gsub("\\", "/")
+ end
+end
+
+--
+-- End of File `lualibs.lua'.