OSDN Git Service

Forgot to include change of luatexja.lua
[luatex-ja/luatexja.git] / src / luatexja.lua
index 3d83401..9f3bd36 100644 (file)
@@ -1,5 +1,6 @@
 
 require('lualibs')
+tableunpack = table.unpack
 
 ------------------------------------------------------------------------
 -- naming:
@@ -19,6 +20,16 @@ function luatexja.load_lua(fn)
    end
 end
 
+-- check token library
+if newtoken then
+   luatexja.token = newtoken
+else
+   local luatex_version = status.list().luatex_version
+   if luatex_version >80 then
+      luatexja.token = token
+   end
+end
+
 --- 以下は全ファイルで共有される定数
 local icflag_table = {}
 luatexja.icflag_table = icflag_table
@@ -120,6 +131,7 @@ local function print_scaled(s)
    until s<=delta
    return out
 end
+luatexja.print_scaled = print_scaled
 
 local function print_glue(d,order)
    local out=print_scaled(d)
@@ -284,8 +296,6 @@ do
    local nullfunc = function (n) return n end
    local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
    local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
-   local tex_set_attr = tex.setattribute
-   local tex_get_attr, node_copy = tex.getattribute, Dnode.copy
    local ensure_tex_attr = ltjb.ensure_tex_attr
 
    -- mode = true iff main_process is called from pre_linebreak_filter
@@ -309,25 +319,30 @@ do
    end
 
    -- callbacks
-   luatexbase.add_to_callback(
+   ltjb.add_to_callback(
       'pre_linebreak_filter',
       function (head,groupcode)
         return main_process(head, true, tex.textdir, groupcode)
-      end,'ltj.pre_linebreak_filter',
-      luatexbase.priority_in_callback('pre_linebreak_filter',
-                                     'luaotfload.node_processor') + 1)
-   luatexbase.add_to_callback(
+      end,'ltj.main',
+      luatexbase.priority_in_callback('pre_linebreak_filter', 'luaotfload.node_processor')+1)
+   ltjb.add_to_callback(
       'hpack_filter',
       function (head,groupcode,size,packtype, dir)
         return main_process(head, false, dir, groupcode)
-      end,'ltj.hpack_filter',
-      luatexbase.priority_in_callback('hpack_filter',
-                                     'luaotfload.node_processor') + 1)
-   luatexbase.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
-   luatexbase.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
+      end,'ltj.main',
+      luatexbase.priority_in_callback('hpack_filter', 'luaotfload.node_processor')+1)
+   ltjb.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
+   ltjb.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
 
 end
 
+-- cleanup process
+function luatexja.ext_cleanup()
+   ltjf.cleanup_size_cache()
+   ltjd.remove_end_whatsit()
+end
+
+
 -- debug
 
 do
@@ -465,12 +480,12 @@ local function debug_show_node_X(p,print_fn, limit)
             prefix, inner_depth = k, bid
          end
       else
-         s = s .. node.subtype(p.subtype)
+         s = s .. (node.subtype(p.subtype) or '')
         if p.subtype==1 then
            s = s .. ' stream=' .. p.stream
            print_fn(s)
            for i=1,#p.data do
-              print_fn(s .. '  [' .. i .. '] = ' .. tostring(token.command_name(p.data[i])))
+              print_fn(s .. '  [' .. i .. '] = ' .. tostring(p.data[i].csname))
            end
         else
            print_fn(s)