Fix string filter generator.

This commit is contained in:
bakpakin
2016-03-05 16:06:56 -05:00
parent 3b4bd9920b
commit 27f881444a
2 changed files with 27 additions and 4 deletions
+5 -4
View File
@@ -92,6 +92,7 @@ local filterJoin
local filterBuildString
do
local loadstring = loadstring or load
local function getchr(c)
return "\\" .. c:byte()
@@ -145,12 +146,12 @@ do
return table.concat(accum)
end
print(buildPart'a|b|(c&d)')
function filterBuildString(str)
local source = ('return function(_, e) return %s end end'):format(buildPart(str))
local source = ("return function(_, e) return %s end"):format(buildPart(str))
local loader, err = loadstring(source)
if err then error(err) end
if err then
error(err)
end
return loader()
end