--
luatexbase.provides_module({
name = 'luatexja.charrange',
--
luatexbase.provides_module({
name = 'luatexja.charrange',
local kcat_attr_table = {}
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 kcat_attr_table = {}
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)], 1/pow(2, i%31)
+ local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 1/(2^(i%31))
- kcat_attr_table[i], pow_table[i] = ka, pow(2, i%31)
+ kcat_attr_table[i], pow_table[i] = ka, 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
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
-- jcr_table_main[chr_code] = index
-- index : internal 0, 1, 2, ..., 216 0: 'other'
-- external 217, 1 2 216, 217 and (out of range): 'other'
-- initialize
-- jcr_table_main[chr_code] = index
-- index : internal 0, 1, 2, ..., 216 0: 'other'
-- external 217, 1 2 216, 217 and (out of range): 'other'
-- initialize
for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end
-- EXT: add characters to a range
for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end
-- EXT: add characters to a range
if not ind or ind<0 or ind>31*ATTR_RANGE then -- 0 はエラーにしない(隠し)
ltjb.package_error('luatexja',
"invalid character range number (" .. ind .. ")",
if not ind or ind<0 or ind>31*ATTR_RANGE then -- 0 はエラーにしない(隠し)
ltjb.package_error('luatexja',
"invalid character range number (" .. ind .. ")",
local r = jcr_table_main[ltjb.in_unicode(c, false)] or 217
return (r~=0) and r or 217
end
local r = jcr_table_main[ltjb.in_unicode(c, false)] or 217
return (r~=0) and r or 217
end
if type(i)~='number' then
ltjb.package_error('luatexja',
"invalid character range number (" .. tostring(i).. ")",
if type(i)~='number' then
ltjb.package_error('luatexja',
"invalid character range number (" .. tostring(i).. ")",