summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lualibs-file.lua19
-rw-r--r--lualibs-util-prs.lua13
2 files changed, 14 insertions, 18 deletions
diff --git a/lualibs-file.lua b/lualibs-file.lua
index deaaca7..a64ee86 100644
--- a/lualibs-file.lua
+++ b/lualibs-file.lua
@@ -585,18 +585,15 @@ end
-- end
-- end
--- a goodie: a dumb version of mkdirs:
+-- 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
- if full then
- full = full .. "/" .. sub
- else
- full = sub
- end
- if not lfs.isdir(full) then
- lfs.mkdir(full)
- end
+ 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/lualibs-util-prs.lua b/lualibs-util-prs.lua
index cdf4975..9d2ffcc 100644
--- a/lualibs-util-prs.lua
+++ b/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)