diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-12-14 14:31:43 +0100 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-12-14 14:31:43 +0100 |
commit | a82cbf2bce00df54f59d1b81805e8b40029b93c6 (patch) | |
tree | da13b16e2ff9c367cff159a3e0f951046ecb1940 | |
parent | 3c357e43af3900df8d6de9ec08e05222ea4256eb (diff) | |
download | lualibs-a82cbf2bce00df54f59d1b81805e8b40029b93c6.tar.gz |
sync with Context as of 2013-12-14
-rw-r--r-- | lualibs-table.lua | 21 | ||||
-rw-r--r-- | lualibs-unicode.lua | 22 | ||||
-rw-r--r-- | lualibs-util-prs.lua | 4 |
3 files changed, 38 insertions, 9 deletions
diff --git a/lualibs-table.lua b/lualibs-table.lua index 11cb66b..c6bbc62 100644 --- a/lualibs-table.lua +++ b/lualibs-table.lua @@ -1054,3 +1054,24 @@ function table.sorted(t,...) sort(t,...) return t -- still sorts in-place end + +-- + +function table.values(t,s) -- optional sort flag + if t then + local values, keys, v = { }, { }, 0 + for key, value in next, t do + if not keys[value] then + v = v + 1 + values[v] = value + keys[k] = key + end + end + if s then + sort(values) + end + return values + else + return { } + end +end diff --git a/lualibs-unicode.lua b/lualibs-unicode.lua index 7ada394..902f6a0 100644 --- a/lualibs-unicode.lua +++ b/lualibs-unicode.lua @@ -935,19 +935,27 @@ end local _, l_remap = utf.remapper(little) local _, b_remap = utf.remapper(big) -function utf.utf8_to_utf16_be(str) - return char(254,255) .. lpegmatch(b_remap,str) +function utf.utf8_to_utf16_be(str,nobom) + if nobom then + return lpegmatch(b_remap,str) + else + return char(254,255) .. lpegmatch(b_remap,str) + end end -function utf.utf8_to_utf16_le(str) - return char(255,254) .. lpegmatch(l_remap,str) +function utf.utf8_to_utf16_le(str,nobom) + if nobom then + return lpegmatch(l_remap,str) + else + return char(255,254) .. lpegmatch(l_remap,str) + end end -function utf.utf8_to_utf16(str,littleendian) +function utf.utf8_to_utf16(str,littleendian,nobom) if littleendian then - return utf.utf8_to_utf16_le(str) + return utf.utf8_to_utf16_le(str,nobom) else - return utf.utf8_to_utf16_be(str) + return utf.utf8_to_utf16_be(str,nobom) end end diff --git a/lualibs-util-prs.lua b/lualibs-util-prs.lua index 29a57e0..9518b7f 100644 --- a/lualibs-util-prs.lua +++ b/lualibs-util-prs.lua @@ -483,8 +483,8 @@ function parsers.rfc4180splitter(specification) * Cs((dquotechar + (1 - quotechar))^0) * quotechar local non_escaped = C((1 - quotechar - newline - separator)^1) - local field = escaped + non_escaped - local record = Ct((field * separator^-1)^1) + local field = escaped + non_escaped + Cc("") + local record = Ct(field * (separator * field)^1) local headerline = record * Cp() local wholeblob = Ct((newline^-1 * record)^0) return function(data,getheader) |