summaryrefslogtreecommitdiff
path: root/common.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-07-06 16:10:17 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2018-09-08 16:12:35 +0200
commit35aaedc729970ae2c5aa26738babd6c9939e338c (patch)
treeba482cd1dcb113c7125c1b66ba52d06b2ad1b7d4 /common.lua
parentba120b9edec8a34b12bbc8b2530d890afc545364 (diff)
downloadcaldr-35aaedc729970ae2c5aa26738babd6c9939e338c.tar.gz
rem, common: recognize multi-valued lines
For muliple values we simply concatenate the input with newlines. None of the properties we implement so far need special considerations in this regard.
Diffstat (limited to 'common.lua')
-rw-r--r--common.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/common.lua b/common.lua
index 6afde62..2c68aee 100644
--- a/common.lua
+++ b/common.lua
@@ -24,6 +24,7 @@ local set_verbosity = function (n) verboselvl = n end
local trim_whitespace
local unescape_string
+local internalize_value
do
local P = lpeg.P
local S = lpeg.S
@@ -41,10 +42,22 @@ do
+ (P"\\v" / "\v")
local p_unescape = Cs ((p_escape_char + 1)^0)
+ --[[--
+
+ rfc2445, sec. 4.1.2: Properties can have multiple values, separated by a
+ literal comma, thus text commas are escaped.
+
+ --]]--
+ local p_value_char = ( p_escape_char
+ + P"\\," / ","
+ + P"," / "\n")
+ local p_value = Cs ((p_value_char + 1)^0)
+
local lpegmatch = lpeg.match
trim_whitespace = function (s) return lpegmatch (p_ws_drop , s) end
unescape_string = function (s) return lpegmatch (p_unescape, s) end
+ internalize_value = function (s) return lpegmatch (p_value, s) end
end
return
@@ -55,5 +68,6 @@ return
, set_verbosity = set_verbosity
, trim_whitespace = trim_whitespace
, unescape_string = unescape_string
+ , internalize_value = internalize_value
}