OSDN Git Service

last commit contains a bug; lp may be nil
[luatex-ja/luatexja.git] / src / ltj-charrange.lua
index e2d97de..b142d35 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.charrange',
-  date = '2014/01/19',
+  date = '2014/05/08',
   description = 'Handling the range of Japanese characters',
 })
 module('luatexja.charrange', package.seeall)
@@ -31,6 +31,7 @@ for i = 0, 31*ATTR_RANGE-1 do
       return floor(has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk
    end
 end
+fn_table[-1]= function() return false end -- for char --U+007F
 pow_table[31*ATTR_RANGE] = pow(2, 31)
 
 -- jcr_table_main[chr_code] = index
@@ -42,6 +43,7 @@ jcr_table_main = {}
 local jcr_table_main = jcr_table_main
 local ucs_out = 0x110000
 
+for i=0x0 ,0x7F       do jcr_table_main[i]=-1 end
 for i=0x80 ,0xFF      do jcr_table_main[i]=1 end
 for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end
 
@@ -70,9 +72,9 @@ end
 function char_to_range(c) -- return the external range number
    c=ltjb.in_unicode(c, false)
    if c<0x80 then return -1
-   else 
+   else
       local r = jcr_table_main[c] or 217
-      return (r and r~=0) and r or 217 
+      return (r and r~=0) and r or 217
    end
 end
 
@@ -92,14 +94,10 @@ function is_ucs_in_japanese_char_node(p)
    end
 end
 is_ucs_in_japanese_char = is_ucs_in_japanese_char_node
+-- only ltj-otf.lua uses this version
 
-function is_ucs_in_japanese_char_direct(p)
-   local c = getchar(p)
-   if c<0x80 then
-      return false
-   else
-      return fn_table[jcr_table_main[c]](p)
-   end
+function is_ucs_in_japanese_char_direct(p ,c)
+   return fn_table[jcr_table_main[c or getchar(p)]](p)
 end
 
 function is_japanese_char_curlist(c) -- assume that c>=0x80