summaryrefslogtreecommitdiff
path: root/tex/context/base/char-ini.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-01-08 15:15:04 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-01-08 15:15:04 +0100
commit1bda0d9ea4d65df72ed3382039a6d061c3e1073f (patch)
tree65b39c384edb595b5b62162bf8b8c1625248d665 /tex/context/base/char-ini.lua
parent9f639e93850762b4169cbe7db9cfa7a8edb5a856 (diff)
downloadcontext-1bda0d9ea4d65df72ed3382039a6d061c3e1073f.tar.gz
2015-01-08 15:01:00
Diffstat (limited to 'tex/context/base/char-ini.lua')
-rw-r--r--tex/context/base/char-ini.lua126
1 files changed, 90 insertions, 36 deletions
diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index f7b5f8871..267b51b46 100644
--- a/tex/context/base/char-ini.lua
+++ b/tex/context/base/char-ini.lua
@@ -891,46 +891,104 @@ lpegpatterns.toshape = toshape -- old ones ... will be overloaded
-- function characters.upper (str) return lpegmatch(toupper,str) end
-- function characters.shaped(str) return lpegmatch(toshape,str) end
-local lhash = { }
-local uhash = { }
-local shash = { }
-
-for k, v in next, characters.data do
- -- if k < 0x11000 then
- local l = v.lccode
- if l then
- if type(l) == "number" then
- lhash[utfchar(k)] = utfchar(l)
- elseif #l == 2 then
- lhash[utfchar(k)] = utfchar(l[1]) .. utfchar(l[2])
- else
- inspect(v)
+
+-- local superscripts = allocate() characters.superscripts = superscripts
+-- local subscripts = allocate() characters.subscripts = subscripts
+
+-- if storage then
+-- storage.register("characters/superscripts", superscripts, "characters.superscripts")
+-- storage.register("characters/subscripts", subscripts, "characters.subscripts")
+-- end
+
+-- end
+
+if not characters.splits then
+
+ local char = allocate()
+ local compat = allocate()
+
+ local splits = {
+ char = char,
+ compat = compat,
+ }
+
+ characters.splits = splits
+
+ -- [0x013F] = { 0x004C, 0x00B7 }
+ -- [0x0140] = { 0x006C, 0x00B7 }
+
+ for unicode, data in next, characters.data do
+ local specials = data.specials
+ if specials and #specials > 2 then
+ local kind = specials[1]
+ if kind == "compat" then
+ compat[unicode] = { unpack(specials,2) }
+ elseif kind == "char" then
+ char [unicode] = { unpack(specials,2) }
end
- else
- local u = v.uccode
- if u then
- if type(u) == "number" then
- uhash[utfchar(k)] = utfchar(u)
- elseif #u == 2 then
- uhash[utfchar(k)] = utfchar(u[1]) .. utfchar(u[2])
+ end
+ end
+
+ if storage then
+ storage.register("characters/splits", splits, "characters.splits")
+ end
+
+end
+
+if not characters.lhash then
+
+ local lhash = allocate() characters.lhash = lhash -- nil if no conversion
+ local uhash = allocate() characters.uhash = uhash -- nil if no conversion
+ local shash = allocate() characters.shash = shash -- nil if no conversion
+
+ for k, v in next, characters.data do
+ -- if k < 0x11000 then
+ local l = v.lccode
+ if l then
+ if type(l) == "number" then
+ lhash[utfchar(k)] = utfchar(l)
+ elseif #l == 2 then
+ lhash[utfchar(k)] = utfchar(l[1]) .. utfchar(l[2])
else
inspect(v)
end
- end
- end
- local s = v.shcode
- if s then
- if type(s) == "number" then
- shash[utfchar(k)] = utfchar(s)
- elseif #s == 2 then
- shash[utfchar(k)] = utfchar(s[1]) .. utfchar(s[2])
else
- inspect(v)
+ local u = v.uccode
+ if u then
+ if type(u) == "number" then
+ uhash[utfchar(k)] = utfchar(u)
+ elseif #u == 2 then
+ uhash[utfchar(k)] = utfchar(u[1]) .. utfchar(u[2])
+ else
+ inspect(v)
+ end
+ end
end
- end
- -- end
+ local s = v.shcode
+ if s then
+ if type(s) == "number" then
+ shash[utfchar(k)] = utfchar(s)
+ elseif #s == 2 then
+ shash[utfchar(k)] = utfchar(s[1]) .. utfchar(s[2])
+ else
+ inspect(v)
+ end
+ end
+ -- end
+ end
+
+ if storage then
+ storage.register("characters/lhash", lhash, "characters.lhash")
+ storage.register("characters/uhash", lhash, "characters.uhash")
+ storage.register("characters/shash", lhash, "characters.shash")
+ end
+
end
+local lhash = characters.lhash
+local uhash = characters.uhash
+local shash = characters.shash
+
local utf8lowercharacter = utfchartabletopattern(lhash) / lhash
local utf8uppercharacter = utfchartabletopattern(uhash) / uhash
local utf8shapecharacter = utfchartabletopattern(shash) / shash
@@ -947,10 +1005,6 @@ lpegpatterns.utf8lower = utf8lower -- string
lpegpatterns.utf8upper = utf8upper -- string
lpegpatterns.utf8shape = utf8shape -- string
-characters.lhash = lhash -- nil if no conversion
-characters.uhash = uhash -- nil if no conversion
-characters.shash = shash -- nil if no conversion
-
function characters.lower (str) return lpegmatch(utf8lower,str) end
function characters.upper (str) return lpegmatch(utf8upper,str) end
function characters.shaped(str) return lpegmatch(utf8shape,str) end