summaryrefslogtreecommitdiff
path: root/lualibs-util-prs.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-05-04 23:10:29 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2015-05-04 23:11:06 +0200
commita79c845dba381f543d09526f77dcf2b4687b73a7 (patch)
tree8c42403a55c9c6736eb491331bfa7f650f807414 /lualibs-util-prs.lua
parent9c35a373aa8e0edf14b686568fffab0e6969f447 (diff)
downloadlualibs-a79c845dba381f543d09526f77dcf2b4687b73a7.tar.gz
sync with Context as of 2015-05-04
Diffstat (limited to 'lualibs-util-prs.lua')
-rw-r--r--lualibs-util-prs.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/lualibs-util-prs.lua b/lualibs-util-prs.lua
index 302b984..ea34c2c 100644
--- a/lualibs-util-prs.lua
+++ b/lualibs-util-prs.lua
@@ -333,7 +333,7 @@ end
-- for mtx-context etc: aaaa bbbb cccc=dddd eeee=ffff
-local str = C((1-whitespace-equal)^1)
+local str = Cs(lpegpatterns.unquoted) + C((1-whitespace-equal)^1)
local setting = Cf( Carg(1) * (whitespace^0 * Cg(str * whitespace^0 * (equal * whitespace^0 * str + Cc(""))))^1,rawset)
local splitter = setting^1
@@ -341,6 +341,12 @@ function utilities.parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or { }) or { }
end
+local splitter = lpeg.tsplitat(" ")
+
+function utilities.parsers.options_to_array(str)
+ return str and lpegmatch(splitter,str) or { }
+end
+
-- for chem (currently one level)
local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace)
@@ -524,7 +530,7 @@ function parsers.rfc4180splitter(specification)
local field = escaped + non_escaped + Cc("")
local record = Ct(field * (separator * field)^1)
local headerline = record * Cp()
- local wholeblob = Ct((newline^-1 * record)^0)
+ local wholeblob = Ct((newline^(specification.strict and -1 or 1) * record)^0)
return function(data,getheader)
if getheader then
local header, position = lpegmatch(headerline,data)