diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-23 14:45:17 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-23 14:45:17 +0200 |
commit | c437a26a8c912b66cb51ce90b95dc05f0a5d9fc4 (patch) | |
tree | 64a8366599b2e352c251f8e84e907d8c37c152e2 /lualibs-util-prs.lua | |
parent | 2345a389998dca5c3ca0317cee42346b16eb24d0 (diff) | |
download | lualibs-c437a26a8c912b66cb51ce90b95dc05f0a5d9fc4.tar.gz |
sync with Context as of 2013-05-23v2.0b
Diffstat (limited to 'lualibs-util-prs.lua')
-rw-r--r-- | lualibs-util-prs.lua | 13 |
1 files changed, 6 insertions, 7 deletions
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) |