summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-11-19 22:50:00 +0100
committerHans Hagen <pragma@wxs.nl>2010-11-19 22:50:00 +0100
commit2f39a561c13930c72772c2344cd4f8612eff33d6 (patch)
tree739ac8bfca42d22fc3a880b2bf73745f7b7dbe05 /tex/generic
parent04aa4bbecf30774917a3e3e52d3603479291c182 (diff)
downloadcontext-2f39a561c13930c72772c2344cd4f8612eff33d6.tar.gz
beta 2010.11.19 22:50
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua99
1 files changed, 31 insertions, 68 deletions
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index a7056a39d..83a11409e 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 11/18/10 19:47:18
+-- merge date : 11/19/10 22:50:14
do -- begin closure to overcome local limits and interference
@@ -122,52 +122,6 @@ function string.topattern(str,lowercase,strict)
end
end
---~ local t = {
---~ "1234567123456712345671234567",
---~ "a\tb\tc",
---~ "aa\tbb\tcc",
---~ "aaa\tbbb\tccc",
---~ "aaaa\tbbbb\tcccc",
---~ "aaaaa\tbbbbb\tccccc",
---~ "aaaaaa\tbbbbbb\tcccccc",
---~ }
---~ for k,v do
---~ print(string.tabtospace(t[k]))
---~ end
-
--- The following functions might end up in another namespace.
-
-function string.tabtospace(str,tab)
- -- we don't handle embedded newlines
- while true do
- local s = find(str,"\t")
- if s then
- if not tab then tab = 7 end -- only when found
- local d = tab-(s-1) % tab
- if d > 0 then
- str = gsub(str,"\t",rep(" ",d),1)
- else
- str = gsub(str,"\t","",1)
- end
- else
- break
- end
- end
- return str
-end
-
---~ local template = string.striplong([[
---~ aaaa
---~ bb
---~ cccccc
---~ ]])
-
-function string.striplong(str) -- strips all leading spaces
- str = gsub(str,"^%s*","")
- str = gsub(str,"[\n\r]+ *","\n")
- return str
-end
-
-- obsolete names:
string.quote = string.quoted
@@ -187,6 +141,8 @@ if not modules then modules = { } end modules ['l-lpeg'] = {
local lpeg = require("lpeg")
+local type = type
+
lpeg.patterns = lpeg.patterns or { } -- so that we can share
local patterns = lpeg.patterns
@@ -196,10 +152,16 @@ local Ct, C, Cs, Cc, Cf, Cg = lpeg.Ct, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Cf, lpeg.C
local utfcharacters = string.utfcharacters
local utfgmatch = unicode and unicode.utf8.gmatch
+local anything = P(1)
+local endofstring = P(-1)
+
+patterns.anything = anything
+patterns.endofstring = endofstring
+
local digit, sign = R('09'), S('+-')
local cr, lf, crlf = P("\r"), P("\n"), P("\r\n")
local utf8next = R("\128\191")
-local escaped = P("\\") * P(1)
+local escaped = P("\\") * anything
local squote = P("'")
local dquote = P('"')
@@ -210,7 +172,7 @@ patterns.utf8four = R("\240\244") * utf8next * utf8next * utf8next
patterns.utfbom = P('\000\000\254\255') + P('\255\254\000\000') + P('\255\254') + P('\254\255') + P('\239\187\191')
local utf8char = patterns.utf8one + patterns.utf8two + patterns.utf8three + patterns.utf8four
-local validutf8char = utf8char^0 * P(-1) * Cc(true) + Cc(false)
+local validutf8char = utf8char^0 * endofstring * Cc(true) + Cc(false)
patterns.utf8 = utf8char
patterns.utf8char = utf8char
@@ -235,6 +197,7 @@ patterns.uppercase = R("AZ")
patterns.letter = patterns.lowercase + patterns.uppercase
patterns.space = P(" ")
patterns.tab = P("\t")
+patterns.spaceortab = patterns.space + patterns.tab
patterns.eol = S("\n\r")
patterns.spacer = S(" \t\f\v") -- + string.char(0xc2, 0xa0) if we want utf (cf mail roberto)
patterns.newline = crlf + cr + lf
@@ -253,7 +216,7 @@ patterns.unsingle = (squote/"") * ((escaped + (1-squote))^0) * (squote/"")
patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble
patterns.unspacer = ((patterns.spacer^1)/"")^0
-local unquoted = Cs(patterns.unquoted * P(-1)) -- not C
+local unquoted = Cs(patterns.unquoted * endofstring) -- not C
function string.unquoted(str)
return match(unquoted,str) or str
@@ -293,7 +256,7 @@ local function splitat(separator,single)
separator = P(separator)
local other = C((1 - separator)^0)
if single then
- local any = P(1)
+ local any = anything
splitter = other * (separator * C(any^0) + "") -- ?
splitters_s[separator] = splitter
else
@@ -357,18 +320,6 @@ function string.checkedsplit(str,separator)
return match(c,str)
end
---~ function lpeg.append(list,pp)
---~ local p = pp
---~ for l=1,#list do
---~ if p then
---~ p = p + P(list[l])
---~ else
---~ p = P(list[l])
---~ end
---~ end
---~ return p
---~ end
-
--~ from roberto's site:
local f1 = string.byte
@@ -453,7 +404,7 @@ function lpeg.secondofsplit(separator) -- nil if not split
local splitter = splitters_s[separator]
if not splitter then
separator = P(separator)
- splitter = (1 - separator)^0 * separator * C(P(1)^0)
+ splitter = (1 - separator)^0 * separator * C(anything^0)
splitters_s[separator] = splitter
end
return splitter
@@ -476,7 +427,7 @@ end
--~ -- slower:
--~
--~ function lpeg.counter(pattern)
---~ local n, pattern = 0, (lpeg.P(pattern)/function() n = n + 1 end + lpeg.P(1))^0
+--~ local n, pattern = 0, (lpeg.P(pattern)/function() n = n + 1 end + lpeg.anything)^0
--~ return function(str) n = 0 ; lpegmatch(pattern,str) ; return n end
--~ end
@@ -539,8 +490,8 @@ local simple_escapes = { -- also defines in l-string
["*"] = ".*",
}
-local p = Cs((S("-.+*%()[]") / patterns_escapes + P(1))^0)
-local s = Cs((S("-.+*%()[]") / simple_escapes + P(1))^0)
+local p = Cs((S("-.+*%()[]") / patterns_escapes + anything)^0)
+local s = Cs((S("-.+*%()[]") / simple_escapes + anything)^0)
function string.escapedpattern(str,simple)
if simple then
@@ -646,6 +597,18 @@ end
--~ print(lpeg.count("äáàa",lpeg.UR("àá")))
--~ print(lpeg.count("äáàa",lpeg.UR(0x0000,0xFFFF)))
+function lpeg.oneof(list,...) -- lpeg.oneof("elseif","else","if","then")
+ if type(list) ~= "table" then
+ list = { list, ... }
+ end
+ -- sort(list) -- longest match first
+ local p = P(list[1])
+ for l=2,#list do
+ p = p + P(list[l])
+ end
+ return p
+end
+
end -- closure
do -- begin closure to overcome local limits and interference
@@ -3813,7 +3776,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
end
end
-- if trace_scaling then
- -- report_define("t=%s, u=%s, i=%s, n=%s c=%s",k,chr.tounicode or k,description.index,description.name or '-',description.class or '-')
+ -- report_define("t=%s, u=%s, i=%s, n=%s c=%s",k,chr.tounicode or "",index or 0,description.name or '-',description.class or '-')
-- end
if tounicode then
local tu = tounicode[index] -- nb: index!