summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2013-05-27 01:24:47 +0000
committerNorbert Preining <preining@logic.at>2013-05-27 01:24:47 +0000
commit04a64779a0d27806141d9b0f6363b27807fba240 (patch)
tree9f734437a02d6c613113c25bb6f92ac9fed39f06
parent14b2656fed04defad4cdc723d7a1de0fd2d21414 (diff)
lualibs update 5/27
git-svn-id: svn://tug.org/texlive/trunk@30700 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/lualibs/lualibs.pdfbin83381 -> 83319 bytes
-rw-r--r--Master/texmf-dist/source/luatex/lualibs/Makefile9
-rw-r--r--Master/texmf-dist/source/luatex/lualibs/whatsnew.lua171
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua21
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua9
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua37
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua2
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua13
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua4
9 files changed, 241 insertions, 25 deletions
diff --git a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
index a0faa9884bd..f845faa49e6 100644
--- a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
+++ b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/luatex/lualibs/Makefile b/Master/texmf-dist/source/luatex/lualibs/Makefile
index 453d6cc45ad..6916f1ed1aa 100644
--- a/Master/texmf-dist/source/luatex/lualibs/Makefile
+++ b/Master/texmf-dist/source/luatex/lualibs/Makefile
@@ -8,16 +8,18 @@ MODULES = $(filter-out $(UNPACKED),$(LUALIBS))
# Files grouped by generation mode
TESTSCRIPT = test-lualibs.lua
+DIFFSCRIPT = whatsnew.lua
+SCRIPTS = $(TESTSCRIPT) $(DIFFSCRIPT)
UNPACKED = lualibs.lua lualibs-extended.lua lualibs-basic.lua
COMPILED = $(DOC_DTX)
GENERATED = $(UNPACKED) $(DOC_DTX) $(MERGED)
-SOURCE = $(DTX) $(MODULES) $(TESTSCRIPT) LICENSE README Makefile NEWS
+SOURCE = $(DTX) $(MODULES) $(SCRIPTS) LICENSE README Makefile NEWS
MERGED = lualibs-basic-merged.lua lualibs-extended-merged.lua
# Files grouped by installation location
RUNFILES = $(UNPACKED) $(MODULES)
DOCFILES = $(DOC_DTX) LICENSE README NEWS
-SRCFILES = $(DTX) $(SRC_TEX) Makefile $(TESTSCRIPT)
+SRCFILES = $(DTX) $(SRC_TEX) Makefile $(SCRIPTS)
# The following definitions should be equivalent
# ALL_FILES = $(RUNFILES) $(DOCFILES) $(SRCFILES)
@@ -49,6 +51,9 @@ world: all ctan
check: $(TESTSCRIPT)
@texlua $(TESTSCRIPT)
+news: $(DIFFSCRIPT)
+ @texlua $(DIFFSCRIPT)
+
.PHONY: all doc unpack ctan tds world
%.pdf: %.dtx
diff --git a/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua b/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua
new file mode 100644
index 00000000000..30cf83782eb
--- /dev/null
+++ b/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua
@@ -0,0 +1,171 @@
+#!/usr/bin/env texlua
+--[===[--
+
+ whatsnew.lua -- Scan Context for changes in Lua libraries.
+ Part of the Lualibs package.
+ https://github.com/lualatex/lualibs
+
+ Copyright 2013 Philipp Gesang
+ License: GPL v2.0
+
+--]===]--
+
+-----------------------------------------------------------------------
+--- configuration
+-----------------------------------------------------------------------
+
+local prefixsep = "-"
+local namespace = "lualibs"
+local luasuffix = ".lua"
+local basedir = "/home/phg/context/tex/texmf-context/tex/context/base"
+local cmd_diff = [[diff "%s" "%s"]]
+
+-----------------------------------------------------------------------
+--- locals
+-----------------------------------------------------------------------
+
+local iopopen = io.popen
+local stringexplode = string.explode
+local stringformat = string.format
+local stringsub = string.sub
+local tableunpack = table.unpack
+
+-----------------------------------------------------------------------
+--- files
+-----------------------------------------------------------------------
+
+--- (prefix, keep) hash_t
+local namespaces = { { "l" , false },
+ { "util" , true },
+ { "trac" , true }, }
+
+--- (prefix, name list) hash_t
+local filenames = {
+ ["l"] = {
+ "boolean",
+ "dir",
+ "file",
+ "function",
+ "io",
+ "lpeg",
+ "lua",
+ "math",
+ "md5",
+ "number",
+ "os",
+ "package",
+ "set",
+ "string",
+ "table",
+ "unicode",
+ "url",
+ },
+
+ ["trac"] = { "inf" },
+
+ ["util"] = {
+ "deb",
+ "dim",
+ "env",
+ "jsn",
+ "lua",
+ "prs",
+ "sta",
+ "sto",
+ "str",
+ "tab",
+ "tpl",
+ },
+}
+
+-----------------------------------------------------------------------
+--- helpers
+-----------------------------------------------------------------------
+
+--- string -> string -> bool -> (string, string)
+local mknames = function (pfx, name, keeppfx)
+ local libname = basedir .. "/" .. pfx
+ .. prefixsep .. name .. luasuffix
+ local ourname = prefixsep .. name .. luasuffix
+ if keeppfx == true then
+ ourname = prefixsep .. pfx .. ourname
+ end
+ ourname = namespace .. ourname
+ ourname = "./" .. ourname
+ return ourname, libname
+end
+
+--- string -> (int * int)
+local count_changes = function (str)
+ local added, removed = 0, 0
+ for n, line in next, stringexplode(str, "\n") do
+ local first = stringsub(line, 1, 1)
+ if first == "<" then
+ removed = removed + 1
+ elseif first == ">" then
+ added = added + 1
+ end
+ end
+ return added, removed
+end
+
+--- string -> string -> (int * int)
+local run_diff = function (f1, f2)
+ local cmd = stringformat(cmd_diff, f1, f2)
+ local res = iopopen(cmd, "r")
+ local dat = res:read"*all"
+ res:close()
+ return count_changes(dat)
+end
+
+-----------------------------------------------------------------------
+--- main
+-----------------------------------------------------------------------
+
+local libs_done = 0
+local total_added = 0
+local total_removed = 0
+
+for n, namespace in next, namespaces do
+ local pfx, keeppfx = tableunpack(namespace)
+ local libs = filenames[pfx]
+ for i=1, #libs do
+ libs_done = libs_done + 1
+ local current = libs[i]
+ local from, to = mknames(pfx, current, keeppfx)
+ if lfs.isfile(from) and lfs.isfile(to) then
+ local added, removed = run_diff (from, to)
+ if added > 0 or removed > 0 then
+ total_added = total_added + added
+ total_removed = total_removed + removed
+ print(stringformat(
+ "(library %q (plus %d) (minus %d))",
+ from, added, removed
+ ))
+ end
+ else
+ if not lfs.isfile(from) then
+ print("cannot read file", from)
+ elseif not lfs.isfile(to) then
+ print("cannot read file", to)
+ end
+ goto fail
+ end
+ end
+end
+
+::done::
+if total_added == 0 and total_removed == 0 then
+ print "stagnation"
+else
+ print(stringformat(
+ "(progress (n-files %d) (added %d) (removed %d))",
+ libs_done, total_added, total_removed
+ ))
+end
+os.exit(0)
+
+::fail::
+print "fatal error"
+os.exit(1)
+
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
index 358b028300c..fa28547b71f 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-basic-merged.lua
-- parent file : lualibs-basic.lua
--- merge date : Sat May 18 12:25:19 2013
+-- merge date : Thu May 23 21:13:25 2013
do -- begin closure to overcome local limits and interference
@@ -2814,7 +2814,7 @@ elseif not lfs.isfile then
end
end
local insert,concat=table.insert,table.concat
-local match,find=string.match,string.find
+local match,find,gmatch=string.match,string.find,string.gmatch
local lpegmatch=lpeg.match
local getcurrentdir,attributes=lfs.currentdir,lfs.attributes
local checkedsplit=string.checkedsplit
@@ -2845,11 +2845,21 @@ local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1
local function suffixonly(name)
return name and lpegmatch(pattern,name) or ""
end
+local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("")
+local function suffixesonly(name)
+ if name then
+ return lpegmatch(pattern,name)
+ else
+ return ""
+ end
+end
file.pathpart=pathpart
file.basename=basename
file.nameonly=nameonly
file.suffixonly=suffixonly
file.suffix=suffixonly
+file.suffixesonly=suffixesonly
+file.suffixes=suffixesonly
file.dirname=pathpart
file.extname=suffixonly
local drive=C(R("az","AZ"))*colon
@@ -3127,6 +3137,13 @@ function file.strip(name,dir)
return a~="" and a or name
end
end
+function lfs.mkdirs(path)
+ local full=""
+ for sub in gmatch(path,"(/*[^\\/]+)") do
+ full=full..sub
+ lfs.mkdir(full)
+ end
+end
end -- closure
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
index fe87e8a09b8..249f8c7f51b 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-extended-merged.lua
-- parent file : lualibs-extended.lua
--- merge date : Sat May 18 12:25:20 2013
+-- merge date : Thu May 23 21:13:25 2013
do -- begin closure to overcome local limits and interference
@@ -766,9 +766,9 @@ function table.deserialize(str)
end
return code
end
-function table.load(filename)
+function table.load(filename,loader)
if filename then
- local t=io.loaddata(filename)
+ local t=(loader or io.loaddata)(filename)
if t and t~="" then
t=load(t)
if type(t)=="function" then
@@ -1289,8 +1289,7 @@ local escape=P('\\')
local separator=S(' ,')
local key=C((1-equal)^1)
local value=dquote*C((1-dquote-escape*dquote)^0)*dquote
-local pattern=Cf(Ct("")*Cg(key*equal*value)*separator^0,rawset)^0*P(-1)
-patterns.keq_to_hash_c=pattern
+local pattern=Cf(Ct("")*(Cg(key*equal*value)*separator^0)^1,rawset)^0*P(-1)
function parsers.keq_to_hash(str)
if str and str~="" then
return lpegmatch(pattern,str)
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
index acb4216b0d4..a64ee86564c 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua
@@ -62,7 +62,7 @@ elseif not lfs.isfile then
end
local insert, concat = table.insert, table.concat
-local match, find = string.match, string.find
+local match, find, gmatch = string.match, string.find, string.gmatch
local lpegmatch = lpeg.match
local getcurrentdir, attributes = lfs.currentdir, lfs.attributes
local checkedsplit = string.checkedsplit
@@ -115,11 +115,23 @@ local function suffixonly(name)
return name and lpegmatch(pattern,name) or ""
end
-file.pathpart = pathpart
-file.basename = basename
-file.nameonly = nameonly
-file.suffixonly = suffixonly
-file.suffix = suffixonly
+local pattern = (noslashes^0 * slashes)^0 * noperiod^1 * ((period * C(noperiod^1))^1) * -1 + Cc("")
+
+local function suffixesonly(name)
+ if name then
+ return lpegmatch(pattern,name)
+ else
+ return ""
+ end
+end
+
+file.pathpart = pathpart
+file.basename = basename
+file.nameonly = nameonly
+file.suffixonly = suffixonly
+file.suffix = suffixonly
+file.suffixesonly = suffixesonly
+file.suffixes = suffixesonly
file.dirname = pathpart -- obsolete
file.extname = suffixonly -- obsolete
@@ -572,3 +584,16 @@ end
-- return f(...)
-- end
-- end
+
+-- a goodie: a dumb version of mkdirs (not used in context itself, only
+-- in generic usage)
+
+function lfs.mkdirs(path)
+ local full = ""
+ for sub in gmatch(path,"(/*[^\\/]+)") do -- accepts leading c: and /
+ full = full .. sub
+ -- lfs.isdir("/foo") mistakenly returns true on windows so
+ -- so we don't test and just make as that one is not too picky
+ lfs.mkdir(full)
+ end
+end
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
index e57abe854c0..9a1b97fff78 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua
@@ -120,7 +120,7 @@ local function sortedhash(t,cmp)
if t then
local s
if cmp then
- -- it would be nice if teh sort function would accept a third argument (or nicer, an optional first)
+ -- it would be nice if the sort function would accept a third argument (or nicer, an optional first)
s = sortedhashkeys(t,function(a,b) return cmp(t,a,b) end)
else
s = sortedkeys(t) -- the robust one
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
index cdf497588ea..9d2ffcc3ee7 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua
@@ -372,9 +372,8 @@ local separator = S(' ,')
local key = C((1-equal)^1)
local value = dquote * C((1-dquote-escape*dquote)^0) * dquote
-local pattern = Cf(Ct("") * Cg(key * equal * value) * separator^0,rawset)^0 * P(-1)
-
-patterns.keq_to_hash_c = pattern
+----- pattern = Cf(Ct("") * Cg(key * equal * value) * separator^0,rawset)^0 * P(-1) -- was wrong
+local pattern = Cf(Ct("") * (Cg(key * equal * value) * separator^0)^1,rawset)^0 * P(-1)
function parsers.keq_to_hash(str)
if str and str ~= "" then
@@ -384,7 +383,7 @@ function parsers.keq_to_hash(str)
end
end
--- inspect(lpeg.match(pattern,[[key="value"]]))
+-- inspect(lpeg.match(pattern,[[key="value" foo="bar"]]))
local defaultspecification = { separator = ",", quote = '"' }
@@ -392,7 +391,7 @@ local defaultspecification = { separator = ",", quote = '"' }
-- database module
function parsers.csvsplitter(specification)
- specification = specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
+ specification = specification and table.setmetatableindex(specification,defaultspecification) or defaultspecification
local separator = specification.separator
local quotechar = specification.quote
local separator = S(separator ~= "" and separator or ",")
@@ -419,14 +418,14 @@ end
-- and this is a slightly patched version of a version posted by Philipp Gesang
-- local mycsvsplitter = utilities.parsers.rfc4180splitter()
---
+
-- local crap = [[
-- first,second,third,fourth
-- "1","2","3","4"
-- "a","b","c","d"
-- "foo","bar""baz","boogie","xyzzy"
-- ]]
---
+
-- local list, names = mycsvsplitter(crap,true) inspect(list) inspect(names)
-- local list, names = mycsvsplitter(crap) inspect(list) inspect(names)
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
index ecf36b13726..a47c0cb77fd 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua
@@ -406,9 +406,9 @@ end
-- inspect(table.fastserialize { a = 1, b = { 4, { 5, 6 } }, c = { d = 7, e = 'f"g\nh' } })
-function table.load(filename)
+function table.load(filename,loader)
if filename then
- local t = io.loaddata(filename)
+ local t = (loader or io.loaddata)(filename)
if t and t ~= "" then
t = load(t)
if type(t) == "function" then