OSDN Git Service

Dnode -> node.direct (WIP)
[luatex-ja/luatexja.git] / src / ltj-charrange.lua
index ea86297..277b4dd 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.charrange',
-  date = '2014/05/08',
+  date = '2014/06/03',
   description = 'Handling the range of Japanese characters',
 })
 module('luatexja.charrange', package.seeall)
@@ -11,9 +11,8 @@ local err, warn, info, log = luatexbase.errwarinf(_NAME)
 
 luatexja.load_module('base');      local ltjb = luatexja.base
 
-local Dnode = node.direct or node
-local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
-local has_attr = Dnode.has_attribute
+local getchar = node.direct.getchar
+local has_attr = node.direct.has_attribute
 local has_attr_node = node.has_attribute
 local tex_getattr = tex.getattribute
 
@@ -26,11 +25,11 @@ local pow_table = {}
 local fn_table = {} -- used in is_ucs_in_japanese_char_direct
 local nfn_table = {} -- used in is_ucs_in_japanese_char_node
 for i = 0, 31*ATTR_RANGE-1 do
-   local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], pow(2, i%31)
+   local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 1/pow(2, i%31)
    local jcr_noncjk = jcr_noncjk
-   kcat_attr_table[i], pow_table[i] = ka, pw
-   fn_table[i] = function(p) return floor(has_attr(p, ka)/pw)%2 ~= jcr_noncjk end
-   nfn_table[i] = function(p) return floor(has_attr_node(p, ka)/pw)%2 ~= jcr_noncjk end
+   kcat_attr_table[i], pow_table[i] = ka, pow(2, i%31)
+   fn_table[i] = function(p) return floor(has_attr(p, ka)*pw)%2 ~= jcr_noncjk end
+   nfn_table[i] = function(p) return floor(has_attr_node(p, ka)*pw)%2 ~= jcr_noncjk end
 end
 fn_table[-1] = function() return false end -- for char --U+007F
 nfn_table[-1] = function() return false end -- for char --U+007F