OSDN Git Service

Fixed several bugs caused by the previous commit
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 14 Mar 2013 03:44:50 +0000 (12:44 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 14 Mar 2013 03:44:50 +0000 (12:44 +0900)
たぶんまだバグがたくさん残っています.後でチェックします.

src/ltj-jfmglue.lua
src/ltj-stack.lua
src/luatexja-core.sty

index 7f4b95c..8d8a7b7 100644 (file)
@@ -161,7 +161,9 @@ local function check_box(box_ptr, box_end)
               first_char = p; find_first_char = false
            end
            last_char = p; found_visible_node = true; p=node_next(p)
               first_char = p; find_first_char = false
            end
            last_char = p; found_visible_node = true; p=node_next(p)
-           if (not p) or p==box_end then return found_visible_node end
+           if (not p) or p==box_end then 
+               return found_visible_node 
+            end
         until p.id~=id_glyph
         pid = p.id -- p must be non-nil
       end
         until p.id~=id_glyph
         pid = p.id -- p must be non-nil
       end
@@ -220,7 +222,7 @@ function check_box_high(Nx, box_ptr, box_end)
    if check_box(box_ptr, box_end) then
       local first_char = first_char
       if first_char then
    if check_box(box_ptr, box_end) then
       local first_char = first_char
       if first_char then
-         if first_char.id==glyph_node then
+         if first_char.id==id_glyph then
            if first_char.font == (has_attr(first_char, attr_curjfnt) or -1) then 
               set_np_xspc_jachar(Nx, first_char)
            else
            if first_char.font == (has_attr(first_char, attr_curjfnt) or -1) then 
               set_np_xspc_jachar(Nx, first_char)
            else
@@ -278,7 +280,7 @@ end
 
 
 local calc_np_auxtable = {
 
 
 local calc_np_auxtable = {
-   [id_glyph] = function (lp) 
+   [id_glyph] = function (lp)
                   Np.first, Np.nuc = (Np.first or lp), lp;
                   Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
                   --set_attr_icflag_processed(lp) treated in ltj-setwidth.lua
                   Np.first, Np.nuc = (Np.first or lp), lp;
                   Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
                   --set_attr_icflag_processed(lp) treated in ltj-setwidth.lua
@@ -354,7 +356,7 @@ local calc_np_auxtable = {
                  if lp.subtype==2 then
                     set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
                     set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
                  if lp.subtype==2 then
                     set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
                     set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
-                    set_attr(lp, attr_icflag, PROCESSED); Np = node_next(lp)
+                    set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
                     set_attr(lp, attr_icflag, PROCESSED); Np.nuc = lp
                     Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
                     return true, check_next_ickern(node_next(lp)); 
                     set_attr(lp, attr_icflag, PROCESSED); Np.nuc = lp
                     Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
                     return true, check_next_ickern(node_next(lp)); 
@@ -392,7 +394,7 @@ function calc_np(lp, last)
    for k = 1,#Bp do Bp[k] = nil end
    while lp ~= last do
       local lpa = has_attr(lp, attr_icflag) or 0
    for k = 1,#Bp do Bp[k] = nil end
    while lp ~= last do
       local lpa = has_attr(lp, attr_icflag) or 0
-      -- unbox 由来ノードの検出
+       -- unbox 由来ノードの検出
       if lpa>=PACKED then
          if lpa == BOXBDD then
            local lq = node_next(lp) 
       if lpa>=PACKED then
          if lpa == BOXBDD then
            local lq = node_next(lp) 
@@ -443,7 +445,7 @@ do
    function set_np_xspc_alchar(Nx, c,x, lig)
       if c~=-1 then
          local xc, xs = x.components, x.subtype
    function set_np_xspc_alchar(Nx, c,x, lig)
       if c~=-1 then
          local xc, xs = x.components, x.subtype
-        if lig == ligature_head then
+        if lig == 1 then
            while xc and xs and xs%4>=2 do
               x = xc; xc, xs = x.components, x.subtype
            end
            while xc and xs and xs%4>=2 do
               x = xc; xc, xs = x.components, x.subtype
            end
@@ -484,7 +486,7 @@ do
    function after_hlist(Nx)
       local s = Nx.last_char
       if s then
    function after_hlist(Nx)
       local s = Nx.last_char
       if s then
-        if s.id==glyph_node then
+        if s.id==id_glyph then
            if s.font == (has_attr(s, attr_curjfnt) or -1) then 
               set_np_xspc_jachar(Nx, s)
            else
            if s.font == (has_attr(s, attr_curjfnt) or -1) then 
               set_np_xspc_jachar(Nx, s)
            else
@@ -960,7 +962,8 @@ function main(ahead, mode)
    end
    lp = calc_np(lp, last)
    while Np do
    end
    lp = calc_np(lp, last)
    while Np do
-      extract_np(); adjust_nq()
+      extract_np();
+      adjust_nq(); 
       local pid, pm = Np.id, Np.met
       -- 挿入部
       if pid == id_jglyph then 
       local pid, pm = Np.id, Np.met
       -- 挿入部
       if pid == id_jglyph then 
@@ -1024,4 +1027,4 @@ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback,
 luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
                            "luatexja.beginpar.np_info_after", 1)
 
 luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
                            "luatexja.beginpar.np_info_after", 1)
 
-end
\ No newline at end of file
+end
index 3dfe2bb..2a2d73a 100644 (file)
@@ -15,32 +15,12 @@ luatexja.load_module('base');      local ltjb = luatexja.base
 local node_new = node.new
 local id_whatsit = node.id('whatsit')
 local sid_user = node.subtype('user_defined')
 local node_new = node.new
 local id_whatsit = node.id('whatsit')
 local sid_user = node.subtype('user_defined')
-local hmode = 118 -- in luatexref-t.pdf, this must be 127
+hmode = 0 -- dummy 
 
 charprop_stack_table={}; 
 local charprop_stack_table = charprop_stack_table
 charprop_stack_table[0]={}
 
 
 charprop_stack_table={}; 
 local charprop_stack_table = charprop_stack_table
 charprop_stack_table[0]={}
 
--- modified from table.fastcopy
-local next = next
-local function stack_table_copy_aux(old) 
-   local new = {}
-   for i,v in next, old do
-      new[i] = v
-   end
-   return new
-end
-local function stack_table_copy(old) 
-   if old then 
-      local new = {}
-      for i,v in next, old do
-        new[i] = stack_table_copy_aux(v)
-      end
-      return new
-   else
-      return {}
-   end 
-end
 
 function get_stack_level()
    local i = tex.getcount('ltj@@stack')
 
 function get_stack_level()
    local i = tex.getcount('ltj@@stack')
@@ -54,7 +34,7 @@ function get_stack_level()
       for k,v in pairs(charprop_stack_table) do -- clear the stack above i
         if k>=i then charprop_stack_table[k]=nil end
       end
       for k,v in pairs(charprop_stack_table) do -- clear the stack above i
         if k>=i then charprop_stack_table[k]=nil end
       end
-      charprop_stack_table[i] = stack_table_copy(charprop_stack_table[i-1])
+      charprop_stack_table[i] = table.fastcopy(charprop_stack_table[i-1])
       tex.setcount('ltj@@stack', i)
       if gd>0 then tex.globaldefs = gd end
       if tex.nest[tex.nest.ptr].mode == hmode or
       tex.setcount('ltj@@stack', i)
       if gd>0 then tex.globaldefs = gd end
       if tex.nest[tex.nest.ptr].mode == hmode or
@@ -83,7 +63,6 @@ end
 
 -- EXT
 function set_stack_table(g,m,c,p,lb,ub)
 
 -- EXT
 function set_stack_table(g,m,c,p,lb,ub)
-   print(g,m,c)
    local i = get_stack_level()
    if type(p)~='number' or p<lb or p>ub then
       ltjb.package_error('luatexja',
    local i = get_stack_level()
    if type(p)~='number' or p<lb or p>ub then
       ltjb.package_error('luatexja',
index f0eedea..853872e 100644 (file)
   \input ltj-base.sty %
 \fi                             %</LaTeX>
 
   \input ltj-base.sty %
 \fi                             %</LaTeX>
 
-
 %%%%%%%% \asluastring
 \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
 
 %%%%%%%% \asluastring
 \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
 
 \newcount\ltj@@stack \newcount\ltj@@group@level
 \ltj@@group@level=0 \ltj@@stack=0
 
 \newcount\ltj@@stack \newcount\ltj@@group@level
 \ltj@@group@level=0 \ltj@@stack=0
 
+\setbox0\hbox{%
+  \directlua{% This value depends on the version of LuaTeX.
+    luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode
+  }
+}
+
 % prebreakpenalty = {<char_code>, <penalty>}
 \define@key[ltj]{japaram}{kcatcode}{%
   \expandafter\ltj@@set@stack#1:{KCAT}{0}{0x7FFFFFFF}}
 % prebreakpenalty = {<char_code>, <penalty>}
 \define@key[ltj]{japaram}{kcatcode}{%
   \expandafter\ltj@@set@stack#1:{KCAT}{0}{0x7FFFFFFF}}