From: Hironori Kitagawa Date: Thu, 23 Jan 2014 13:35:26 +0000 (+0900) Subject: typo in ltj-jfmglue.lua X-Git-Tag: 20140204.0~8^2~7 X-Git-Url: http://git.osdn.net/view?p=luatex-ja%2Fluatexja.git;a=commitdiff_plain;h=d0195904de0b350a978341dd014d80ac2f739ccb typo in ltj-jfmglue.lua --- diff --git a/src/ltj-adjust.lua b/src/ltj-adjust.lua index 01d6d7b..44258ed 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -10,6 +10,7 @@ module('luatexja.adjust', package.seeall) luatexja.load_module('jfont'); local ltjf = luatexja.jfont luatexja.load_module('jfmglue'); local ltjj = luatexja.jfmglue +luatexja.load_module('stack'); local ltjs = luatexja.stack local Dnode = node.direct or node @@ -87,8 +88,7 @@ local function get_stretched(q, go, gs) end local res = {} - --- local new_ks, new_xs +local is_skip_normal = {} local function get_total_stretched(p) local go, gf, gs = getfield(p, 'glue_order'), getfield(p, 'glue_set'), getfield(p, 'glue_sign') @@ -101,11 +101,12 @@ local function get_total_stretched(p) if type(res[ic]) == 'number' then -- kanjiskip, xkanjiskip は段落内で spec を共有しているが, -- それはここでは望ましくないので,各 glue ごとに異なる spec を使う. + -- (この仮定でメモリリークを起こしている!) -- JFM グルーはそれぞれ異なる glue_spec を用いているので,問題ない. res[ic] = res[ic] + a - if ic == KANJI_SKIP or ic == XKANJI_SKIP then + if (ic == KANJI_SKIP or ic == XKANJI_SKIP) and getsubtype(q)==0 then local qs = getfield(q, 'spec') - if qs ~= spec_zero_glue then + if is_skip_normal[ic] and qs ~= spec_zero_glue then setfield(q, 'spec', node_copy(qs)) end end @@ -237,6 +238,8 @@ end function adjust_width(head) if not head then return head end + is_skip_normal[KANJI_SKIP] = (ltjs.fast_get_skip_table('kanjiskip').width ~= 1073741823) + is_skip_normal[XKANJI_SKIP] = (ltjs.fast_get_skip_table('xkanjiskip').width ~= 1073741823) for p in node_traverse_id(id_hlist, to_direct(head)) do local res = get_total_stretched(p) if res then diff --git a/src/ltj-charrange.lua b/src/ltj-charrange.lua index 2209255..e3b6e7a 100644 --- a/src/ltj-charrange.lua +++ b/src/ltj-charrange.lua @@ -15,15 +15,20 @@ local Dnode = node.direct or node local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end local has_attr = Dnode.has_attribute local has_attr_node = node.has_attribute +local tex_getattr = tex.getattribute ATTR_RANGE = 7 local floor = math.floor local pow = math.pow local kcat_attr_table = {} local pow_table = {} +local fn_table = {} -- used in is_ucs_in_japanese_char_direct for i = 0, 31*ATTR_RANGE-1 do kcat_attr_table[i] = luatexbase.attributes['ltj@kcat'..floor(i/31)] pow_table[i] = pow(2, i%31) + fn_table[i] = function(p) + return floor(has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk + end end pow_table[31*ATTR_RANGE] = pow(2, 31) @@ -71,11 +76,10 @@ function char_to_range(c) -- return the external range number end function get_range_setting(i) -- i: internal range number - return floor(tex.getattribute(kcat_attr_table[i])/pow_table[i])%2 + return floor(tex_getattr(kcat_attr_table[i])/pow_table[i])%2 end -- glyph_node p は和文文字か? - function is_ucs_in_japanese_char_node(p) local c = p.char if c<0x80 then @@ -93,12 +97,15 @@ function is_ucs_in_japanese_char_direct(p) if c<0x80 then return false else - local i=jcr_table_main[c] - return (floor( - has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk) + return fn_table[jcr_table_main[c]] end end +function is_japanese_char_curlist(c) -- assume that c>=0x80 + local i=jcr_table_main[c] + return get_range_setting(i)~= jcr_noncjk +end + -- EXT function toggle_char_range(g, i) -- i: external range number if type(i)~='number' then @@ -111,7 +118,7 @@ function toggle_char_range(g, i) -- i: external range number if i>0 then kc=0 else kc=1; i=-i end if i>=7*ATTR_RANGE then i=0 end local attr = kcat_attr_table[i] - local a = tex.getattribute(attr) + local a = tex_getattr(attr) tex.setattribute(g,attr,(floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i]) end end diff --git a/src/ltj-inputbuf.lua b/src/ltj-inputbuf.lua index f900472..cfef819 100644 --- a/src/ltj-inputbuf.lua +++ b/src/ltj-inputbuf.lua @@ -11,7 +11,7 @@ local node_new = node.new local node_free = node.free local id_glyph = node.id('glyph') local getcatcode = tex.getcatcode -local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char +local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist local FFFFF = string.char(0xF3,0xBF,0xBF,0xBF) --- the following function is modified from jafontspec.lua (by K. Maeda). @@ -31,12 +31,9 @@ local function add_comment(buffer) -- Is the catcode of endline character is 5 (end-of-line)? -- Is the catcode of U+FFFFF (new comment char) is 14 (comment)? if ((ct==11) or (ct==12)) and ctl then - local p = node_new(id_glyph) - p.char = c - if ltjc_is_ucs_in_japanese_char(p) then + if ltjc_is_japanese_char_curlist(c) then buffer = buffer .. FFFFF -- U+FFFFF end - node_free(p) end end end diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index 4b8aa17..7df300f 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -316,7 +316,7 @@ local calc_np_auxtable = { [id_whatsit] = function(lp) local lps = getsubtype(lp) if lps==sid_user then - if getsubtype(lp, 'user_id')==luatexja.userid_table.IHB then + if getfield(lp, 'user_id')==luatexja.userid_table.IHB then local lq = node_next(lp); head = node_remove(head, lp); node_free(lp); ihb_flag = true return false, lq; diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 139615a..ef97f3f 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -65,7 +65,7 @@ \expandafter\let\csname ifltj@in@latex\expandafter\endcsname \csname iftrue\endcsname \NeedsTeXFormat{LaTeX2e} - \ProvidesPackage{luatexja-core}[2014/01/13 Core of LuaTeX-ja] + \ProvidesPackage{luatexja-core}[2014/01/24 Core of LuaTeX-ja] \fi % %% Load prerequisite packages. @@ -101,10 +101,10 @@ {Package loading is aborted now.\MessageBreak} \expandafter\endinput\fi\relax - \@PackageInfo{luatexja-core} - {This LuaTeX-ja uses\space% + \@PackageInfoNoLine{luatexja-core} + {using\space% \directlua{if node.direct==node then tex.write('traditional node') - else tex:write('DIRECT') end} access model for accessing nodes.} + else tex.write('DIRECT') end} node access model} %! なお、luatexbase-compat の説明に従うと、LuaTeX 拡張プリミティブは %! plain/LaTeX の両方で \luatex 付の名前(\directlua はそのまま)