OSDN Git Service

recent commits (around 6047ee0 and later) makes SyncTeX unusable, so I manually rever...
[luatex-ja/luatexja.git] / src / ltj-jfmglue.lua
index 0ef4093..8d564dc 100644 (file)
@@ -83,15 +83,8 @@ local BOXBDD       = luatexja.icflag_table.BOXBDD
 local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
 
 local attr_icflag = luatexbase.attributes['ltj@icflag']
-local kanji_skip = node_new(id_glue)
-local xkanji_skip = node_new(id_glue)
-do
-   local KANJI_SKIP   = luatexja.icflag_table.KANJI_SKIP
-   local XKANJI_SKIP   = luatexja.icflag_table.XKANJI_SKIP
-   set_attr(kanji_skip, attr_icflag, KANJI_SKIP)
-   set_attr(xkanji_skip, attr_icflag, XKANJI_SKIP)
-end
-
+local kanji_skip
+local xkanji_skip
 local table_current_stack
 local list_dir
 local capsule_glyph
@@ -694,18 +687,18 @@ end
 -- 和文文字間の JFM glue を node 化
 local function new_jfm_glue(m, bc, ac)
 -- bc, ac: char classes
-   local g, d = m.char_type[bc][ac], 0
-   local n
+   local g = m.char_type[bc][ac]
    if g then
-      n,d = node_copy(g[2]), g[3]
       if g[1] then
         local f = node_new(id_glue)
         set_attr(f, attr_icflag, g[4])
-        setfield(f, 'spec', n)
-        return f, d
+        setfield(f, 'spec', node_copy(g[2]))
+        return f, g[3]
+      else
+        return node_copy(g[2]), g[3]
       end
    end
-   return n, d
+   return nil, 0
 end
 
 -- Nq.last (kern w) .... (glue/kern g) Np.first
@@ -991,8 +984,7 @@ local function handle_list_tail(mode)
       -- Insert \jcharwidowpenalty
       Bp = widow_Bp; Np = widow_Np
       if Np.first then
-        handle_penalty_normal(0,
-                              table_current_stack[JWP] or 0)
+        handle_penalty_normal(0, table_current_stack[JWP] or 0)
       end
    else
       -- the current list is the contents of a hbox
@@ -1058,10 +1050,12 @@ do
       capsule_glyph = is_dir_tate and ltjw.capsule_glyph_tate or ltjw.capsule_glyph_yoko
       attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift
 
+      kanji_skip = node_new(id_glue); set_attr(kanji_skip, attr_icflag, KANJI_SKIP)
       setfield(kanji_skip, 'spec', skip_table_to_spec(KSK))
       get_kanjiskip = (getfield(getfield(kanji_skip, 'spec'), 'width') == 1073741823)
         and get_kanjiskip_jfm or get_kanjiskip_normal
 
+      xkanji_skip = node_new(id_glue); set_attr(xkanji_skip, attr_icflag, XKANJI_SKIP)
       setfield(xkanji_skip, 'spec', skip_table_to_spec(XSK))
       get_xkanjiskip = (getfield(getfield(xkanji_skip, 'spec'), 'width') == 1073741823)
         and get_xkanjiskip_jfm or get_xkanjiskip_normal
@@ -1084,12 +1078,11 @@ do
    end
 end
 
-local tex_set_attr = tex.setattribute
+local ensure_tex_attr = ltjb.ensure_tex_attr
 local function cleanup(mode)
    -- adjust attr_icflag for avoiding error
-   if tex.getattribute(attr_icflag)~=0 then tex_set_attr('global', attr_icflag, 0) end
-   node_free(getfield(kanji_skip, 'spec'))
-   node_free(getfield(xkanji_skip, 'spec'))
+   if tex.getattribute(attr_icflag)~=0 then ensure_tex_attr('global', attr_icflag, 0) end
+   node_free(kanji_skip); node_free(xkanji_skip)
    if mode then
       local h = node_next(head)
       if getid(h) == id_penalty and getfield(h, 'penalty') == 10000 then