From: Hironori Kitagawa Date: Sat, 3 Dec 2011 03:13:50 +0000 (+0900) Subject: Reconsider the structure of the stack table. X-Git-Tag: 20120419.0~31 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=56fd6a35e686a9dfed438b75e3c41364b0365db0;hp=934e719aea361ab4b8294196d90fe43f2900b64a;p=luatex-ja%2Fluatexja.git Reconsider the structure of the stack table. --- diff --git a/src/luatexja-core.lua b/src/luatexja-core.lua index 673f581..3ebe54b 100644 --- a/src/luatexja-core.lua +++ b/src/luatexja-core.lua @@ -105,7 +105,7 @@ end function math.two_add(a,b) return a+b end function math.two_average(a,b) return (a+b)/2 end ----- table: charprop_stack_table [stack_level][chr_code].{pre|post|xsp} +---- table: charprop_stack_table [stack_level].{pre|post|xsp}[chr_code] ------------------------------------------------------------------------ -- CODE FOR GETTING/SETTING PARAMETERS diff --git a/src/luatexja/jfmglue.lua b/src/luatexja/jfmglue.lua index e716f23..d939719 100644 --- a/src/luatexja/jfmglue.lua +++ b/src/luatexja/jfmglue.lua @@ -455,7 +455,7 @@ local function handle_penalty_normal(post, pre, g) if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end p.penalty = a head = node_insert_before(head, Np.first, p) - Bp[1] = p; set_attr(p, attr_icflag, KINSOKU) + table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU) end else for i, v in pairs(Bp) do add_penalty(v,a) end end @@ -469,7 +469,7 @@ local function handle_penalty_always(post, pre, g) if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end p.penalty = a head = node_insert_before(head, Np.first, p) - Bp[1] = p; set_attr(p, attr_icflag, KINSOKU) + table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU) end else for i, v in pairs(Bp) do add_penalty(v,a) end end @@ -481,7 +481,7 @@ local function handle_penalty_suppress(post, pre, g) if g and g.id==id_glue then local p = node_new(id_penalty) p.penalty = 10000; head = node_insert_before(head, Np.first, p) - Bp[1] = p; set_attr(p, attr_icflag, KINSOKU) + table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU) end else for i, v in pairs(Bp) do add_penalty(v,a) end end diff --git a/src/luatexja/setwidth.lua b/src/luatexja/setwidth.lua index be779d0..a668f0f 100644 --- a/src/luatexja/setwidth.lua +++ b/src/luatexja/setwidth.lua @@ -107,7 +107,7 @@ function set_ja_width(ahead, dir) while p do if p.id==id_glyph then if is_japanese_glyph_node(p) then - local met = ltjf.font_metric_table[p.font] + local met = ltjf_font_metric_table[p.font] local class = has_attr(p, attr_jchar_class) char_data = ltjf.metrics[met.jfm].size_cache[met.size].char_type[class] if char_data then diff --git a/src/luatexja/stack.lua b/src/luatexja/stack.lua index 32e6845..80b7630 100644 --- a/src/luatexja/stack.lua +++ b/src/luatexja/stack.lua @@ -16,6 +16,7 @@ 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 +local table_fastcopy = table.fastcopy local charprop_stack_table={}; charprop_stack_table[0]={} @@ -31,7 +32,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 - charprop_stack_table[i] = table.fastcopy(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 @@ -43,6 +44,21 @@ function get_stack_level() return i end +-- local function table_to_str(v) +-- local s = '' +-- for i, a in pairs(v) do +-- s = s .. i .. "=" .. tostring(a) .. ', ' +-- end +-- return s +-- end +-- function print_stack_table(i) +-- print('\n>>> get_stack_level:') +-- for k, v in pairs(charprop_stack_table[i]) do +-- print(" " , k, type(k), table_to_str(v)); +-- end +-- end + + -- EXT function set_stack_table(g,m,c,p,lb,ub) local i = get_stack_level() @@ -59,14 +75,14 @@ function set_stack_table(g,m,c,p,lb,ub) "(-1 is used for denoting `math boundary')", 'So I changed this one to zero.'}) c=0 - elseif not charprop_stack_table[i][c] then - charprop_stack_table[i][c] = {} + elseif not charprop_stack_table[i][m] then + charprop_stack_table[i][m] = {} end - charprop_stack_table[i][c][m] = p + charprop_stack_table[i][m][c] = p if g=='global' then for j,v in pairs(charprop_stack_table) do - if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end - charprop_stack_table[j][c][m] = p + if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end + charprop_stack_table[j][m][c] = p end end end @@ -83,35 +99,35 @@ function set_stack_font(g,m,c,p) elseif not charprop_stack_table[i][c] then charprop_stack_table[i][c] = {} end - charprop_stack_table[i][c][m] = p + charprop_stack_table[i][m][c] = p if g=='global' then for j,v in pairs(charprop_stack_table) do - if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end - charprop_stack_table[j][c][m] = p + if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end + charprop_stack_table[j][m][c] = p end end end -- EXT: store \ltj@tempskipa -function set_stack_skip(g,c,sp) +function set_stack_skip(g,m,sp) local i = get_stack_level() if not sp then return end - if not charprop_stack_table[i][c] then - charprop_stack_table[i][c] = {} + if not charprop_stack_table[i][m] then + charprop_stack_table[i][m] = {} end - charprop_stack_table[i][c].width = sp.width - charprop_stack_table[i][c].stretch = sp.stretch - charprop_stack_table[i][c].shrink = sp.shrink - charprop_stack_table[i][c].stretch_order = sp.stretch_order - charprop_stack_table[i][c].shrink_order = sp.shrink_order + charprop_stack_table[i][m].width = sp.width + charprop_stack_table[i][m].stretch = sp.stretch + charprop_stack_table[i][m].shrink = sp.shrink + charprop_stack_table[i][m].stretch_order = sp.stretch_order + charprop_stack_table[i][m].shrink_order = sp.shrink_order if g=='global' then for j,v in pairs(charprop_stack_table) do - if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end - charprop_stack_table[j][c].width = sp.width - charprop_stack_table[j][c].stretch = sp.stretch - charprop_stack_table[j][c].shrink = sp.shrink - charprop_stack_table[j][c].stretch_order = sp.stretch_order - charprop_stack_table[j][c].shrink_order = sp.shrink_order + if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end + charprop_stack_table[j][m].width = sp.width + charprop_stack_table[j][m].stretch = sp.stretch + charprop_stack_table[j][m].shrink = sp.shrink + charprop_stack_table[j][m].stretch_order = sp.stretch_order + charprop_stack_table[j][m].shrink_order = sp.shrink_order end end end @@ -124,8 +140,8 @@ function get_skip_table(m, idx) end function get_penalty_table(m,c,d, idx) - local i = charprop_stack_table[idx][c] - if i then i=i[m] end + local i = charprop_stack_table[idx][m] + if i then i=i[c] end return i or d end