From 3e22d20de49d2e67302953c3d1018a1ceba4c417 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 4 Aug 2012 14:00:00 +0200 Subject: beta 2012.08.04 14:00 --- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4085 -> 4084 bytes tex/context/base/context-version.png | Bin 105411 -> 105760 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/l-file.lua | 10 +- tex/context/base/luat-lib.mkiv | 2 + tex/context/base/m-json.mkiv | 30 ++++ tex/context/base/status-files.pdf | Bin 24428 -> 24438 bytes tex/context/base/status-lua.pdf | Bin 190051 -> 190114 bytes tex/context/base/status-mkiv.lua | 30 ++++ tex/context/base/strc-lst.mkvi | 7 +- tex/context/base/strc-not.lua | 2 +- tex/context/base/syst-aux.mkiv | 2 +- tex/context/base/util-deb.lua | 2 +- tex/context/base/util-jsn.lua | 143 ++++++++++++++++++ tex/context/base/util-mrg.lua | 5 +- tex/context/base/util-sql.lua | 159 +++++++++++++++++++++ tex/context/base/util-tpl.lua | 59 ++++++++ tex/generic/context/luatex/luatex-fonts-merged.lua | 12 +- 21 files changed, 455 insertions(+), 16 deletions(-) create mode 100644 tex/context/base/m-json.mkiv create mode 100644 tex/context/base/util-jsn.lua create mode 100644 tex/context/base/util-sql.lua create mode 100644 tex/context/base/util-tpl.lua (limited to 'tex') diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index e972a84d4..67855e8f2 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.02 10:55} +\newcontextversion{2012.08.04 14:00} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 74a510919..445946693 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.02 10:55} +\newcontextversion{2012.08.04 14:00} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index fc0fd45ca..5eb1c6d96 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index a7071354e..8d1f97043 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 6491882b8..bb18ea3da 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.02 10:55} +\edef\contextversion{2012.08.04 14:00} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index d3de216a9..6fcbd07fa 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.02 10:55} +\edef\contextversion{2012.08.04 14:00} %D For those who want to use this: diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua index edfbc0f92..c47777bd5 100644 --- a/tex/context/base/l-file.lua +++ b/tex/context/base/l-file.lua @@ -431,6 +431,7 @@ local drive = C(R("az","AZ")) * P(":") local path = C(((1-slash)^0 * slash)^0) local suffix = period * C(P(1-period)^0 * P(-1)) local base = C((1-suffix)^0) +local rest = C(P(1)^0) drive = drive + Cc("") path = path + Cc("") @@ -439,7 +440,8 @@ suffix = suffix + Cc("") local pattern_a = drive * path * base * suffix local pattern_b = path * base * suffix -local pattern_c = C(drive * path) * C(base * suffix) +local pattern_c = C(drive * path) * C(base * suffix) -- trick: two extra captures +local pattern_d = path * rest function file.splitname(str,splitdrive) if splitdrive then @@ -449,6 +451,10 @@ function file.splitname(str,splitdrive) end end +function file.splitbase(str) + return lpegmatch(pattern_d,str) -- returns path, base+suffix +end + function file.nametotable(str,splitdrive) -- returns table local path, drive, subpath, name, base, suffix = lpegmatch(pattern_c,str) if splitdrive then @@ -470,6 +476,8 @@ function file.nametotable(str,splitdrive) -- returns table end end +-- print(file.splitbase("a/b/c.txt")) + -- function test(t) for k, v in next, t do print(v, "=>", file.splitname(v)) end end -- -- test { "c:", "c:/aa", "c:/aa/bb", "c:/aa/bb/cc", "c:/aa/bb/cc.dd", "c:/aa/bb/cc.dd.ee" } diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv index fb05a84c1..2eba44931 100644 --- a/tex/context/base/luat-lib.mkiv +++ b/tex/context/base/luat-lib.mkiv @@ -30,6 +30,8 @@ \registerctxluafile{trac-log}{1.001} %registerctxluafile{trac-pro}{1.001} +\registerctxluafile{util-tpl}{1.001} % needs tracker + \registerctxluafile{util-sta}{1.001} \registerctxluafile{data-ini}{1.001} diff --git a/tex/context/base/m-json.mkiv b/tex/context/base/m-json.mkiv new file mode 100644 index 000000000..329aa0f31 --- /dev/null +++ b/tex/context/base/m-json.mkiv @@ -0,0 +1,30 @@ +%D \module +%D [ file=m-json, +%D version=2012.08.03, +%D title=\CONTEXT\ Modules, +%D subtitle=Json, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module is a side effect of looking into json. Currently there are +%D only a few helpers: +%D +%D \starttyping +%D moduledata.json.tolua (str) +%D moduledata.json.tostring(val) +%D \stoptyping +%D +%D Nothing spectacular but maybe handy to have around. + +\startmodule [json] + +% check for: utilities.json + +\registerctxluafile{util-jsn}{} + +\stopmodule diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 8fdaf533e..a80effa46 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 41d97cfe3..4d5a4589e 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index ba4e87283..7b7ff67ef 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -4585,6 +4585,12 @@ return { loading = "luat-lib", status = "todo", }, + { + category = "lua", + filename = "util-jsn", + loading = "m-json", + status = "todo", + }, { category = "lua", filename = "util-lua", @@ -4615,6 +4621,12 @@ return { loading = "luat-lib", status = "todo", }, + { + category = "lua", + filename = "util-sql", + loading = "m-sql", + status = "todo", + }, { category = "lua", filename = "util-sta", @@ -4639,6 +4651,12 @@ return { loading = "luat-lib", status = "todo", }, + { + category = "lua", + filename = "util-tpl", + loading = "luat-lib", + status = "todo", + }, { category = "lua", filename = "x-asciimath", @@ -4873,6 +4891,12 @@ return { loading = "module", status = "okay", }, + { + category = "mkiv", + filename = "m-json", + loading = "module", + status = "okay", + }, { category = "tex", filename = "m-layout", @@ -4983,6 +5007,12 @@ return { filename = "m-subsub", status = "todo", }, + { + category = "mkiv", + filename = "m-sql", + loading = "module", + status = "okay", + }, { category = "mkiv", filename = "m-timing", diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi index ecec2f699..5e2b26cc6 100644 --- a/tex/context/base/strc-lst.mkvi +++ b/tex/context/base/strc-lst.mkvi @@ -1014,9 +1014,6 @@ % \chapter{Chapter three} \chapter{Chapter four} \chapter{Chapter five} % \stoptext -% overrulen interactie kan sneller, bv door hulpconstanten -% te gebruiken en die te letten - \startsetups[\??listrenderings:d] \ifvmode \advance\leftskip\listparameter\c!margin @@ -1176,6 +1173,10 @@ \letvalue{\??listinteractions\v!all }\v!all \letvalue{\??listinteractions\v!yes }\v!all +\def\listboxproperties {\strc_lists_get_reference_attribute} +\def\listrenderingsetup {\the\t_lists_every_renderingtext} +\def\listrenderingsynchronize{\the\t_lists_every_renderingsynchronize} + \unexpanded\def\strc_lists_interaction_check {\iflocation \strc_lists_interaction_check_yes diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua index be6e37f52..df63650e3 100644 --- a/tex/context/base/strc-not.lua +++ b/tex/context/base/strc-not.lua @@ -314,7 +314,7 @@ local function getnumberpage(tag,n) return li end -function notes.deltapage(tag,n) +local function deltapage(tag,n) -- 0:unknown 1:textbefore, 2:textafter, 3:samepage local what = 0 -- references.internals[lists.tobesaved[nd].internal] diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 1c4ab089d..721a2def9 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -1836,7 +1836,7 @@ {\if#2@\parametersfalse\else\parameterstrue\fi} \unexpanded\def\checkparameters[#1]% - {\syst_helpers_get_empty_parameters#1=@@\_e_o_s_} + {\syst_helpers_check_parameters#1=@@\_e_o_s_} %D \macros %D {getfromcommalist,getfromcommacommand, diff --git a/tex/context/base/util-deb.lua b/tex/context/base/util-deb.lua index d82c1a114..6285e05f3 100644 --- a/tex/context/base/util-deb.lua +++ b/tex/context/base/util-deb.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['util.deb'] = { +if not modules then modules = { } end modules ['util-deb'] = { version = 1.001, comment = "companion to luat-lib.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", diff --git a/tex/context/base/util-jsn.lua b/tex/context/base/util-jsn.lua new file mode 100644 index 000000000..7de6e2729 --- /dev/null +++ b/tex/context/base/util-jsn.lua @@ -0,0 +1,143 @@ +if not modules then modules = { } end modules ['util-jsn'] = { + version = 1.001, + comment = "companion to m-json.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Of course we could make a nice complete parser with proper error messages but +-- as json is generated programmatically errors are systematic and we can assume +-- a correct stream. If not, we have some fatal error anyway. So, we can just rely +-- on strings being strings (apart from the unicode escape which is not in 5.1) and +-- as we first catch known types we just assume that anything else is a number. + +local P, V, R, S, C, Cc, Cs, Ct, Cf, Cg = lpeg.P, lpeg.V, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cf, lpeg.Cg +local lpegmatch = lpeg.match +local format = string.format +local utfchar = utf.char +local concat = table.concat + +local tonumber, tostring, rawset, type = tonumber, tostring, rawset, type + +local json = utilities.json or { } +utilities.json = json + +-- moduledata = moduledata or { } +-- moduledata.json = json + +-- \\ \/ \b \f \n \r \t \uHHHH + +local lbrace = P("{") +local rbrace = P("}") +local lparent = P("[") +local rparent = P("]") +local comma = P(",") +local colon = P(":") +local dquote = P('"') + +local whitespace = lpeg.patterns.whitespace +local optionalws = whitespace^0 + +local escape = C(P("\\u") / "0x" * S("09","AF","af")) / function(s) return utfchar(tonumber(s)) end +local jstring = dquote * Cs((escape + (1-dquote))^0) * dquote +local jtrue = P("true") * Cc(true) +local jfalse = P("false") * Cc(false) +local jnull = P("null") * Cc(nil) +local jnumber = (1-whitespace-rparent-rbrace-comma)^1 / tonumber + +local key = jstring + +local jsonconverter = { "value", + object = lbrace * Cf(Ct("") * V("pair") * (comma * V("pair"))^0,rawset) * rbrace, + pair = Cg(optionalws * key * optionalws * colon * V("value")), + array = Ct(lparent * V("value") * (comma * V("value"))^0 * rparent), + value = optionalws * (jstring + V("object") + V("array") + jtrue + jfalse + jnull + jnumber) * optionalws, +} + +-- local jsonconverter = { "value", +-- object = lbrace * Cf(Ct("") * V("pair") * (comma * V("pair"))^0,rawset) * rbrace, +-- pair = Cg(optionalws * V("string") * optionalws * colon * V("value")), +-- array = Ct(lparent * V("value") * (comma * V("value"))^0 * rparent), +-- string = jstring, +-- value = optionalws * (V("string") + V("object") + V("array") + jtrue + jfalse + jnull + jnumber) * optionalws, +-- } + +-- lpeg.print(jsonconverter) -- size 181 + +function json.tolua(str) + return lpegmatch(jsonconverter,str) +end + +local function tojson(value,t) -- we could optimize #t + local kind = type(value) + if kind == "table" then + local done = false + local size = #value + if size == 0 then + for k, v in next, value do + if done then + t[#t+1] = "," + else + t[#t+1] = "{" + done = true + end + t[#t+1] = format("%q:",k) + tojson(v,t) + end + if done then + t[#t+1] = "}" + else + t[#t+1] = "{}" + end + elseif size == 1 then + -- we can optimize for non tables + t[#t+1] = "[" + tojson(value[i],t) + t[#t+1] = "]" + else + for i=1,size do + if done then + t[#t+1] = "," + else + t[#t+1] = "[" + done = true + end + tojson(value[i],t) + end + t[#t+1] = "]" + end + elseif kind == "string" or kind == "number" then + t[#t+1] = value + else + t[#t+1] = tostring(value) + end + return t +end + +function json.tostring(value) + -- todo optimize for non table + local kind = type(value) + if kind == "table" then + return concat(tojson(value,{}),"") + elseif kind == "string" or kind == "number" then + return value + else + return tostring(value) + end +end + +-- local tmp = [[ { "a" : true, "b" : [ 123 , 456E-10, { "a" : true, "b" : [ 123 , 456 ] } ] } ]] +-- +-- tmp = json.tolua(tmp) +-- inspect(tmp) +-- tmp = json.tostring(tmp) +-- inspect(tmp) +-- tmp = json.tolua(tmp) +-- inspect(tmp) +-- tmp = json.tostring(tmp) +-- inspect(tmp) +-- +-- inspect(json.tostring(true)) + +return json diff --git a/tex/context/base/util-mrg.lua b/tex/context/base/util-mrg.lua index c924d30af..8d6c5dd31 100644 --- a/tex/context/base/util-mrg.lua +++ b/tex/context/base/util-mrg.lua @@ -13,11 +13,10 @@ local concat = table.concat local type, next = type, next utilities = utilities or {} -utilities.merger = utilities.merger or { } -- maybe mergers +local merger = utilities.merger or { } +utilities.merger = merger utilities.report = logs and logs.reporter("system") or print -local merger = utilities.merger - merger.strip_comment = true local m_begin_merge = "begin library merge" diff --git a/tex/context/base/util-sql.lua b/tex/context/base/util-sql.lua new file mode 100644 index 000000000..1f7842a83 --- /dev/null +++ b/tex/context/base/util-sql.lua @@ -0,0 +1,159 @@ +if not modules then modules = { } end modules ['util-sql'] = { + version = 1.001, + comment = "companion to m-sql.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local format = string.format +local P, V, Ct, Cs, Cc, Cg, Cf, patterns, lpegmatch = lpeg.P, lpeg.V, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.patterns, lpeg.match + +local trace_sql = false trackers.register("sql.trace",function(v) trace_sql = v end) +local report_state = logs.reporter("sql") + +utilities.sql = utilities.sql or { } +local sql = utilities.sql + +local inifile = "" + +-- todo: + +if os.platform == "mswin" then + inifile = "C:\\Program Files\\MySQL\\MySQL Server 5.5\\ld-test.ini" +else + inifile = "/etc/mysql/ld-test.ini" +end + +local separator = P("\t") +local newline = patterns.newline +local entry = Cs((1-separator-newline)^1) +local empty = Cc("") + +local getfirst = Ct( entry * (separator * (entry+empty))^0) + newline +local skipfirst = (1-newline)^1 * newline + +-- -- faster but less flexible: +-- +-- local splitter = Ct ( (getfirst)^1 ) +-- +-- local function splitdata(data) +-- return lpegmatch(splitter,data) or { } +-- end + +local function splitdata(data) + if data == "" then + if trace_sql then + report_state("no data") + end + return { } + end + local t = lpegmatch(getfirst,data) or { } + if #t == 0 then + if trace_sql then + report_state("no banner") + end + return { } + end + -- quite generic, could be a helper + local p = nil + for i=1,#t do + local ti = t[i] + if trace_sql then + report_state("field %s has name %q",i,ti) + end + local s = Cg(Cc(ti) * entry) + if p then + p = p * s + else + p = s + end + if i < #t then + p = p * separator + end + end + p = Cf(Ct("") * p,rawset) * newline^0 + local d = lpegmatch(skipfirst * Ct(p^0),data) + return d or { } +end + +local function preparedata(sqlfile,templatefile,mapping) + local query = utilities.templates.load(templatefile,mapping) + io.savedata(sqlfile,query) +end + +local function fetchdata(sqlfile,datfile) + local command + if inifile ~= "" then + command = format([[mysql --defaults-extra-file="%s" < %s > %s]],inifile,sqlfile,datfile) + else + command = format([[[mysql < %s > %s]],sqlfile,datfile) + end + if trace_sql then + local t = os.clock() + os.execute(command) + report_state("fetchtime: %.3f sec",os.clock()-t) -- not okay under linux + else + os.execute(command) + end +end + +local function loaddata(datfile) + if trace_sql then + local t = os.clock() + local data = io.loaddata(datfile) or "" + report_state("datasize: %.3f MB",#data/1024/1024) + report_state("loadtime: %.3f sec",os.clock()-t) + return data + else + return io.loaddata(datfile) or "" + end +end + +local function convertdata(data) + if trace_sql then + local t = os.clock() + data = splitdata(data) + report_state("converttime: %.3f",os.clock()-t) + report_state("entries: %s ",#data) -- #data-1 if indexed + else + return splitdata(data) + end +end + +-- todo: new, etc + +function sql.fetch(templatefile,mapping) + local sqlfile = file.nameonly(templatefile) .. "-temp.sql" + local datfile = file.nameonly(templatefile) .. "-temp.dat" + preparedata(sqlfile,templatefile,mapping) + fetchdata(sqlfile,datfile) + local data = loaddata(datfile) + data = convertdata(data) + return data +end + +function sql.reuse(templatefile) + local datfile = file.nameonly(templatefile) .. "-temp.dat" + local data = loaddata(datfile) + data = convertdata(data) + return data +end + +-- tex specific + +if tex then + + function sql.prepare(sqlfile,mapping) + if tex.systemmodes["first"] then + return utilities.sql.fetch(sqlfile,mapping) + else + return utilities.sql.reuse(sqlfile) + end + end + +else + + sql.prepare = utilities.sql.fetch + +end diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua new file mode 100644 index 000000000..09aed8a2c --- /dev/null +++ b/tex/context/base/util-tpl.lua @@ -0,0 +1,59 @@ +if not modules then modules = { } end modules ['util-tpl'] = { + version = 1.001, + comment = "companion to luat-lib.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- experimental code + +-- maybe make %% scanning optional +-- maybe use $[ and ]$ or {{ }} + +utilities.templates = utilities.templates or { } +local templates = utilities.templates + +local trace_template = false trackers.register("templates.trace",function(v) trace_template = v end) +local report_template = logs.reporter("template") + +local P, C, Cs, Carg, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.Carg, lpeg.match + +local function replacekey(k,t) + local v = t[k] + if not v then + if trace_template then + report_template("unknown key %q",k) + end + return "" + else + if trace_template then + report_template("setting key %q to value %q",k,v) + end + return v + end +end + +----- leftmarker = P("") / "" + +local escape = P("%%") / "%%" +local leftmarker = P("%") / "" +local rightmarker = P("%") / "" + +local key = leftmarker * (C((1-rightmarker)^1 * Carg(1))/replacekey) * rightmarker +local any = P(1) +local replacer = Cs((escape + key + any)^0) + +function templates.replace(str,mapping) + return mapping and lpegmatch(replacer,str,1,mapping) or str +end + +function templates.load(filename,mapping) + local data = io.loaddata(filename) or "" + if mapping and next(mapping) then + return templates.replace(data,mapping) + else + return data + end +end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 08ceb2a42..fe64d5078 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 08/02/12 10:55:40 +-- merge date : 08/04/12 14:00:20 do -- begin closure to overcome local limits and interference @@ -2396,6 +2396,7 @@ local drive = C(R("az","AZ")) * P(":") local path = C(((1-slash)^0 * slash)^0) local suffix = period * C(P(1-period)^0 * P(-1)) local base = C((1-suffix)^0) +local rest = C(P(1)^0) drive = drive + Cc("") path = path + Cc("") @@ -2404,7 +2405,8 @@ suffix = suffix + Cc("") local pattern_a = drive * path * base * suffix local pattern_b = path * base * suffix -local pattern_c = C(drive * path) * C(base * suffix) +local pattern_c = C(drive * path) * C(base * suffix) -- trick: two extra captures +local pattern_d = path * rest function file.splitname(str,splitdrive) if splitdrive then @@ -2414,6 +2416,10 @@ function file.splitname(str,splitdrive) end end +function file.splitbase(str) + return lpegmatch(pattern_d,str) -- returns path, base+suffix +end + function file.nametotable(str,splitdrive) -- returns table local path, drive, subpath, name, base, suffix = lpegmatch(pattern_c,str) if splitdrive then @@ -2435,6 +2441,8 @@ function file.nametotable(str,splitdrive) -- returns table end end +-- print(file.splitbase("a/b/c.txt")) + -- function test(t) for k, v in next, t do print(v, "=>", file.splitname(v)) end end -- -- test { "c:", "c:/aa", "c:/aa/bb", "c:/aa/bb/cc", "c:/aa/bb/cc.dd", "c:/aa/bb/cc.dd.ee" } -- cgit v1.2.3