summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-03 04:02:30 -0800
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-03 04:02:30 -0800
commit6b9142ea3d6963af1d525fd57a8c3395d1eda29b (patch)
tree28f6dcb7faf598e9d548f91d1a1ad5d170a17c7f
parentbc287b4f6bb89c78ec57e0e0871fa054075efdf1 (diff)
parent137c28853effaf60c5c20884417643f671c79514 (diff)
downloadlualibs-6b9142ea3d6963af1d525fd57a8c3395d1eda29b.tar.gz
Merge pull request #20 from phi-gamma/master
sync with Context as of 2013-11-03
-rw-r--r--lualibs-lpeg.lua3
-rw-r--r--lualibs-util-tpl.lua16
2 files changed, 11 insertions, 8 deletions
diff --git a/lualibs-lpeg.lua b/lualibs-lpeg.lua
index 58c5524..399b3ad 100644
--- a/lualibs-lpeg.lua
+++ b/lualibs-lpeg.lua
@@ -466,6 +466,9 @@ function lpeg.replacer(one,two,makefunction,isutf) -- in principle we should sor
end
end
+-- local pattern1 = P(1-P(pattern))^0 * P(pattern) : test for not nil
+-- local pattern2 = (P(pattern) * Cc(true) + P(1))^0 : test for true (could be faster, but not much)
+
function lpeg.finder(lst,makefunction) -- beware: slower than find with 'patternless finds'
local pattern
if type(lst) == "table" then
diff --git a/lualibs-util-tpl.lua b/lualibs-util-tpl.lua
index e0c405a..67d0582 100644
--- a/lualibs-util-tpl.lua
+++ b/lualibs-util-tpl.lua
@@ -17,8 +17,8 @@ local trace_template = false trackers.register("templates.trace",function(v) t
local report_template = logs.reporter("template")
local tostring = tostring
-local format, sub = string.format, string.sub
-local P, C, Cs, Carg, lpegmatch, lpegpatterns = lpeg.P, lpeg.C, lpeg.Cs, lpeg.Carg, lpeg.match, lpeg.patterns
+local format, sub, byte = string.format, string.sub, string.byte
+local P, C, R, Cs, Cc, Carg, lpegmatch, lpegpatterns = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match, lpeg.patterns
-- todo: make installable template.new
@@ -71,7 +71,7 @@ lpegpatterns.sqlquoted = sqlquoted
-- }
--
-- slightly faster:
---
+
-- local luaescape = Cs ((
-- P('"' ) / [[\"]] +
-- P('\\') / [[\\]] +
@@ -81,11 +81,11 @@ lpegpatterns.sqlquoted = sqlquoted
-- P(1)
-- )^0)
--- local xmlescape = lpegpatterns.xmlescape
--- local texescape = lpegpatterns.texescape
--- local luaescape = lpegpatterns.luaescape
--- local sqlquoted = lpegpatterns.sqlquoted
--- local luaquoted = lpegpatterns.luaquoted
+----- xmlescape = lpegpatterns.xmlescape
+----- texescape = lpegpatterns.texescape
+local luaescape = lpegpatterns.luaescape
+----- sqlquoted = lpegpatterns.sqlquoted
+----- luaquoted = lpegpatterns.luaquoted
local escapers = {
lua = function(s)