diff options
author | Norbert Preining <preining@logic.at> | 2013-05-27 01:24:47 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2013-05-27 01:24:47 +0000 |
commit | 04a64779a0d27806141d9b0f6363b27807fba240 (patch) | |
tree | 9f734437a02d6c613113c25bb6f92ac9fed39f06 /Master/texmf-dist/tex/luatex/lualibs | |
parent | 14b2656fed04defad4cdc723d7a1de0fd2d21414 (diff) |
lualibs update 5/27
git-svn-id: svn://tug.org/texlive/trunk@30700 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs')
6 files changed, 63 insertions, 23 deletions
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 |