From: Hironori Kitagawa Date: Mon, 22 Aug 2022 08:07:41 +0000 (+0900) Subject: change the argument of getcount to the register number X-Git-Tag: 20221002.0~9^2~7 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=d68e277016a9797b6d7838fee38085d1aa1a4277;p=luatex-ja%2Fluatexja.git change the argument of getcount to the register number --- diff --git a/src/ltj-adjust.lua b/src/ltj-adjust.lua index 8d767bf..af5c5ca 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -501,28 +501,26 @@ luatexja.unary_pars.profile_hgap_factor = function(t) return luatexja.adjust.profile_hgap_factor end do - local insert = table.insert + local insert, texget = table.insert, tex.get local rangedimensions, max = node.direct.rangedimensions, math.max local function profile_inner(box, range, ind, vmirrored, adj) local w_acc, d_before = getshift(box), 0 local x = getlist(box); local xn = node_next(x) while x do local w, h, d - if xn then w, h, d= rangedimensions(box,x,xn) - else w, h, d= rangedimensions(box,x) end + if xn then w, h, d = rangedimensions(box,x,xn) + else w, h, d = rangedimensions(box,x) end if vmirrored then h=d end local w_new = w_acc + w - if w>=0 then - range:insert(ind, h, w_acc-adj, w_new) - else - range:insert(ind, h, w_new-adj, w_acc) + if w>=0 then range:insert(ind, h, w_acc-adj, w_new) + else range:insert(ind, h, w_new-adj, w_acc) end w_acc = w_new; x = xn; if x then xn = node_next(x) end end end function ltjl.p_profile(before, after, mirrored, bw) local range, tls - = init_range(), luatexja.adjust.profile_hgap_factor*tex.get('lineskip', false) + = init_range(), luatexja.adjust.profile_hgap_factor*texget('lineskip', false) profile_inner(before, range, 3, true, tls) profile_inner(after, range, 4, mirrored, tls) range = range:flatten() @@ -544,7 +542,7 @@ end do local ltja = luatexja.adjust - local copy_glue = ltjl.copy_glue + local copy_glue, texget = ltjl.copy_glue, tex.get local floor, max = math.floor, math.max function ltjl.l_step(dist, g, adj, normal, bw, loc) if loc=='alignment' then @@ -552,7 +550,7 @@ do end if dist < tex.lineskiplimit then local f = max(1, bw*ltja.step_factor) - copy_glue(g, 'baselineskip', 1, normal - f * floor((dist-tex.get('lineskip', false))/f)) + copy_glue(g, 'baselineskip', 1, normal - f * floor((dist-texget('lineskip', false))/f)) else copy_glue(g, 'baselineskip', 2, normal) end diff --git a/src/ltj-charrange.lua b/src/ltj-charrange.lua index 074ba3c..b5207ce 100644 --- a/src/ltj-charrange.lua +++ b/src/ltj-charrange.lua @@ -32,7 +32,7 @@ do end end for i = 31, 31*ATTR_RANGE-1 do - local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 2^(i%31) + local ka, pw = luatexbase.attributes['ltj@kcat'..(i//31)], 2^(i%31) kcat_attr_table[i], pow_table[i] = ka, pw fn_table[i] = function(p) return (get_attr(p, ka) or 0)&pw==0 end nfn_table[i] = function(p) return (get_attr_node(p, ka) or 0)&pw==0 end diff --git a/src/ltj-compat.lua b/src/ltj-compat.lua index c1ca005..25c9b88 100644 --- a/src/ltj-compat.lua +++ b/src/ltj-compat.lua @@ -4,7 +4,6 @@ luatexja.load_module 'base'; local ltjb = luatexja.base luatexja.load_module 'stack'; local ltjs = luatexja.stack -local stack_table_index = luatexja.stack_table_index -- load jisx0208 table local cache_ver = 3 @@ -18,20 +17,21 @@ end -- \kuten, \jis, \euc, \sjis, \ucs, \kansuji -local utfchar=utf.char +local utfchar, floor = utf.char, math.floor +local texwrite, getcount = tex.write, tex.getcount +local cnt_stack = luatexbase.registernumber 'ltj@@stack' +local KSJ = luatexja.stack_table_index.KSJ +local get_stack_table = ltjs.get_stack_table local function to_kansuji(num) if not num then num=0; return - elseif num<0 then - num = -num; tex.write '-' + elseif num<0 then num = -num; texwrite '-' end local s = "" repeat - s = utfchar( - ltjs.get_stack_table(luatexja.stack_table_index.KSJ + num%10, - '', tex.getcount 'ltj@@stack')) .. s - num=math.floor(num/10) + s = utfchar(get_stack_table(KSJ + num%10, '', getcount(cnt_stack))) .. s + num=num//10 until num==0 - tex.write(s) + texwrite(s) end local function error_invalid_charcode(i) @@ -43,16 +43,16 @@ end -- \ucs: 単なる identity local function from_ucs(i) if type(i)~='number' then error_invalid_charcode(i); i=0 end - tex.write(i) + texwrite(i) end -- \kuten: 面区点 (それぞれで16進2桁を使用)=> Unicode 符号位置 local function from_kuten(i) if type(i)~='number' then error_invalid_charcode(i); i=0 end if (i%256==0)or(i%256>94) then - tex.write '0' + texwrite '0' else - tex.write(tostring(jisx0208.table_jisx0208_uptex[math.floor(i/256)*94+(i%256)-94] or 0)) + texwrite(tostring(jisx0208.table_jisx0208_uptex[(i//256)*94+(i%256)-94] or 0)) end end @@ -75,10 +75,9 @@ end -- \sjis: Shift_JIS による符号位置 => Unicode 符号位置 local function from_sjis(i) if (type(i)~='number') or i>=0x10000 or i<0 then - error_invalid_charcode(i); tex.write '0'; return + error_invalid_charcode(i); texwrite '0'; return end - local c2 = math.floor(i/256) - local c1 = i%256 + local c2, c1 = i//256, i%256 local shift_jisx0213_s1a3_table = { { [false]= 1, [true]= 8}, { [false]= 3, [true]= 4}, @@ -113,7 +112,7 @@ luatexja.binary_pars.kansujichar = function(c, t) 'So I changed this one to zero.') c=0 end - return ltjs.get_stack_table(stack_table_index.KSJ + c, 0, t) + return get_stack_table(KSJ + c, 0, t) end diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 2fa74d6..1a7364a 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -46,7 +46,7 @@ local sid_user = node.subtype 'user_defined' local getnest = tex.getnest local tex_nest = tex.nest -local tex_getcount = tex.getcount +local getcount = tex.getcount local ensure_tex_attr = ltjb.ensure_tex_attr local PROCESSED = luatexja.icflag_table.PROCESSED local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG @@ -545,12 +545,13 @@ function get_box_dir(b, default) end do + local ltj_tempcnta = luatexbase.registernumber 'ltj@tempcnta' local getbox = tex.getbox local dir_backup function luatexja.direction.unbox_check_dir(is_copy) start_time_measure 'box_primitive_hook' local list_dir = get_dir_count()%dir_math_mod - local b = getbox(tex_getcount 'ltj@tempcnta') + local b = getbox(getcount(ltj_tempcnta)) if b and getlist(to_direct(b)) then local box_dir = get_box_dir(to_direct(b), dir_yoko) if box_dir%dir_math_mod ~= list_dir then @@ -587,7 +588,7 @@ do stop_time_measure 'box_primitive_hook' end function luatexja.direction.uncopy_restore_whatsit() - local b = getbox(tex_getcount 'ltj@tempcnta') + local b = getbox(getcount(ltj_tempcnta)) if b then local bd = to_direct(b) if dir_backup then diff --git a/src/ltj-inputbuf.lua b/src/ltj-inputbuf.lua index 12ac83a..dc6ec46 100644 --- a/src/ltj-inputbuf.lua +++ b/src/ltj-inputbuf.lua @@ -11,7 +11,7 @@ local utfchar = utf.char local id_glyph = node.id 'glyph' local getcatcode, getcount = tex.getcatcode, tex.getcount local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist - +local cnt_lineend = luatexbase.registernumber 'ltjlineendcomment' local substituter do local uchar = utf.char @@ -69,7 +69,7 @@ local function add_comment(buffer) if (te ~= -1) and (getcatcode(te)==5) then local ct = getcatcode(c) if (ct==11) or (ct==12) then - local lec = getcount 'ltjlineendcomment' + local lec = getcount(cnt_lineend) -- Is the catcode of \ltjlineendcomment (new comment char) is 14 (comment)? if ltjc_is_japanese_char_curlist(c) and (getcatcode(lec)==14) then stop_time_measure 'inputbuf'; return buffer .. utfchar(lec) diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index 515e823..822154e 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -1384,6 +1384,7 @@ do local getnest = tex.getnest local tex_getattr = tex.getattribute local get_current_jfont + local cnt_stack = luatexbase.registernumber 'ltj@@stack' do local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] local attr_curtfnt = luatexbase.attributes['ltj@curtfnt'] @@ -1401,9 +1402,9 @@ do local function insert_k_skip_common(ind, name, ica, icb) if abs(getnest().mode) ~= ltjs.hmode then return end local g = node_new(id_glue); set_attr(g, attr_icflag, SPECIAL_JAGLUE) - local is_late = scan_keyword("late") + local is_late = scan_keyword 'late' if not is_late then - local st = get_stack_skip(ind, getcount('ltj@@stack')) + local st = get_stack_skip(ind, getcount(cnt_stack)) if st[1]==1073741823 then local bk = ltjf_font_metric_table[get_current_jfont()][name] if bk then diff --git a/src/ltj-math.lua b/src/ltj-math.lua index bb3e414..451c7d0 100644 --- a/src/ltj-math.lua +++ b/src/ltj-math.lua @@ -34,7 +34,8 @@ local node_remove = node.direct.remove local node_free = node.direct.flush_node or node.direct.free local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute -local tex_getcount = tex.getcount +local getcount = tex.getcount +local cnt_stack = luatexbase.registernumber 'ltj@@stack' local attr_jchar_class = luatexbase.attributes['ltj@charclass'] local attr_dir = luatexbase.attributes['ltj@dir'] @@ -145,7 +146,7 @@ cjh_A = function (p, sty) elseif pid == id_mchar then local pc, fam = getchar (p), get_attr(p, attr_jfam) or -1 if (not is_math_letters[pc]) and is_ucs_in_japanese_char(p) and fam>=0 then - local f = ltjs.get_stack_table(MJT + 0x100 * sty + fam, -1, tex_getcount('ltj@@stack')) + local f = ltjs.get_stack_table(MJT + 0x100 * sty + fam, -1, getcount(cnt_stack)) if f ~= -1 then local q = node_new(id_sub_box) local r = node_new(id_glyph, 256); setnext(r, nil) diff --git a/src/ltj-pretreat.lua b/src/ltj-pretreat.lua index 9325628..23ca192 100644 --- a/src/ltj-pretreat.lua +++ b/src/ltj-pretreat.lua @@ -29,7 +29,7 @@ local node_remove = node.direct.remove local node_next = node.direct.getnext local node_free = node.direct.flush_node or node.direct.free local node_end_of_math = node.direct.end_of_math -local tex_getcount = tex.getcount +local getcount = tex.getcount local id_glyph = node.id('glyph') local id_math = node.id('math') @@ -142,6 +142,7 @@ local ltjs_report_stack_level = ltjs.report_stack_level local ltjf_font_metric_table = ltjf.font_metric_table local font_getfont = font.getfont local traverse_id = node.direct.traverse_id +local cnt_stack = luatexbase.registernumber 'ltj@@stack' function set_box_stack_level(head, mode) local box_set, cl = 0, tex.currentgrouplevel + 1 if mode then @@ -151,7 +152,7 @@ function set_box_stack_level(head, mode) else for _,p in pairs(wt) do node_free(p) end end - ltjs_report_stack_level(tex_getcount('ltj@@stack') + box_set) + ltjs_report_stack_level(getcount(cnt_stack) + box_set) for _,p in pairs(wtd) do node_free(p) end if ltjs.list_dir == dir_tate then for p in traverse_id(id_glyph,to_direct(head)) do diff --git a/src/ltj-ruby.lua b/src/ltj-ruby.lua index e580db1..a07f63a 100644 --- a/src/ltj-ruby.lua +++ b/src/ltj-ruby.lua @@ -195,9 +195,7 @@ end local function expand_3bits(num) local t = {}; local a = num - for i = 1, 10 do - t[i] = a%8; a = floor(a/8) - end + for i = 1, 10 do t[i], a = a%8, a//8 end return t end ---------------------------------------------------------------- @@ -267,7 +265,7 @@ local function texiface_low(rst, rtlr, rtlp) local wv = node_new(id_whatsit, sid_user) setfield(w, 'value', to_node(wv)) setfield(wv, 'type', 108) - setfield(wv, 'value', rst); rst.count = floor(#rtlr) + setfield(wv, 'value', rst); rst.count = #rtlr setfield(wv, 'user_id', RUBY_PRE) -- dummy local n = wv for i = 1, #rtlr do @@ -319,7 +317,7 @@ local function enlarge_parent(r, p, tmp_tbl, no_begin, no_end) local pre_intrusion, post_intrusion local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost - local intmode = floor(tmp_tbl.mode/4)%4 + local intmode = (tmp_tbl.mode//4)%4 if no_begin then mapre = mapre + tmp_tbl.before_jfmgk end if no_end then mapost = mapost + tmp_tbl.after_jfmgk end if (tmp_tbl.mode%4 >=2) and (tmp_tbl.pre<0) and (tmp_tbl.post<0) then @@ -342,7 +340,7 @@ local function enlarge_parent(r, p, tmp_tbl, no_begin, no_end) if n < sumprot then pre_intrusion = n/2; post_intrusion = n/2 else - pre_intrusion = floor(sumprot/2); post_intrusion = sumprot - pre_intrusion + pre_intrusion = sumprot//2; post_intrusion = sumprot - pre_intrusion end p = enlarge(p, rwidth, ppre, pmid, ppost, pre_intrusion, post_intrusion) pre_intrusion = min(mapre, pre_intrusion + round(ppre*getfield(p, 'glue_set')*65536)) @@ -375,8 +373,8 @@ local function new_ruby_box(r, p, tmp_tbl, no_begin, no_end) local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost local rpre, rmid, rpost, rsmash - imode = floor(tmp_tbl.mode/0x100000); rsmash = (imode%2 ==1) - imode = floor(imode/2); rpost = imode%8; + imode = tmp_tbl.mode//0x100000; rsmash = (imode%2 ==1) + imode = imode//2; rpost = imode%8; imode = (imode-rpost)/8; rmid = imode%8; imode = (imode-rmid)/8; rpre = imode%8 if getwidth(r) > getwidth(p) then -- change the width of p @@ -426,7 +424,7 @@ end local post_intrusion_backup, post_jfmgk_backup local max_allow_pre, max_allow_post - +local flush_list = node.direct.flush_list -- 中付き熟語ルビ,cmp containers -- 「文字の構成を考えた」やつはどうしよう local function pre_low_cal_box(w, cmp) @@ -481,7 +479,7 @@ local function pre_low_cal_box(w, cmp) -- w.value の node list 更新. local nt = wv - node.direct.flush_list(node_next(wv)) + flush_list(node_next(wv)) for i = 1, 2*cmp+1 do setnext(nt, kf[i]); nt = kf[i] end if cmp==1 then solve_1(coef) @@ -635,11 +633,12 @@ do end end +local traverse_id = node.direct.traverse_id local function post_high_break(head) local rs = {} -- rs: sequence of ruby_nodes, local rw = nil -- rw: main whatsit local cmp = -2 -- dummy - for h in node.direct.traverse_id(id_hlist, to_direct(head)) do + for h in traverse_id(id_hlist, to_direct(head)) do for i = 1, #rs do rs[i] = nil end local ha = getlist(h) while ha do diff --git a/src/ltj-stack.lua b/src/ltj-stack.lua index e25dbc0..ca83781 100644 --- a/src/ltj-stack.lua +++ b/src/ltj-stack.lua @@ -21,6 +21,8 @@ local fastcopy = table.fastcopy local setcount, getcount = tex.setcount, tex.getcount local scan_int, scan_keyword = token.scan_int, token.scan_keyword local getnest = tex.getnest +local cnt_stack = luatexbase.registernumber 'ltj@@stack' +local cnt_grplvl = luatexbase.registernumber 'ltj@@group@level' ltjs.hmode = 0 -- dummy local charprop_stack_table={} @@ -28,19 +30,19 @@ ltjs.charprop_stack_table = charprop_stack_table charprop_stack_table[0]={} local function get_stack_level() - local i = getcount 'ltj@@stack' + local i = getcount(cnt_stack) local j = tex.currentgrouplevel - if j > getcount 'ltj@@group@level' then + if j > getcount(cnt_grplvl) then i = i+1 -- new stack level local gd = tex.globaldefs if gd~=0 then tex.globaldefs = 0 end -- 'tex.globaldefs = 0' is local even if \globaldefs > 0. - setcount('ltj@@group@level', j) + setcount(cnt_grplvl, j) 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] = fastcopy(charprop_stack_table[i-1]) - setcount('ltj@@stack', i) + setcount(cnt_stack, i) if gd~=0 then tex.globaldefs = gd end if getnest().mode == -ltjs.hmode then -- rest. hmode のみ local g = node_new(id_whatsit, sid_user) diff --git a/src/ltjsarticle.cls b/src/ltjsarticle.cls index ea6dc8c..13f290d 100644 --- a/src/ltjsarticle.cls +++ b/src/ltjsarticle.cls @@ -38,7 +38,7 @@ %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{ltjsarticle} - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] \def\jsc@clsname{ltjsarticle} \def\Cjascale{0.924715} \RequirePackage{luatexja} @@ -249,13 +249,15 @@ option, since LuaTeX does not support \string\mag\MessageBreak in pdf output}% \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/ltjsbook.cls b/src/ltjsbook.cls index 43bedbc..43c80e6 100644 --- a/src/ltjsbook.cls +++ b/src/ltjsbook.cls @@ -38,7 +38,7 @@ %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{ltjsbook} - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] \def\jsc@clsname{ltjsbook} \def\Cjascale{0.924715} \RequirePackage{luatexja} @@ -257,13 +257,15 @@ option, since LuaTeX does not support \string\mag\MessageBreak in pdf output}% \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/ltjsclasses.dtx b/src/ltjsclasses.dtx index e190617..dff5001 100644 --- a/src/ltjsclasses.dtx +++ b/src/ltjsclasses.dtx @@ -44,7 +44,7 @@ %<*driver> \ProvidesFile{ltjsclasses.dtx} % - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] %<*driver> \IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{} \documentclass[disablejfam]{ltjsarticle} @@ -808,13 +808,15 @@ \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/ltjskiyou.cls b/src/ltjskiyou.cls index be94fcc..20518fa 100644 --- a/src/ltjskiyou.cls +++ b/src/ltjskiyou.cls @@ -38,7 +38,7 @@ %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{ltjskiyou} - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] \def\jsc@clsname{ltjskiyou} \def\Cjascale{0.924715} \RequirePackage{luatexja} @@ -248,13 +248,15 @@ option, since LuaTeX does not support \string\mag\MessageBreak in pdf output}% \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/ltjspf.cls b/src/ltjspf.cls index f4f11d0..5c40308 100644 --- a/src/ltjspf.cls +++ b/src/ltjspf.cls @@ -38,7 +38,7 @@ %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{ltjspf} - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] \def\jsc@clsname{ltjspf} \def\Cjascale{0.903375} \RequirePackage{luatexja} @@ -247,13 +247,15 @@ option, since LuaTeX does not support \string\mag\MessageBreak in pdf output}% \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/ltjsreport.cls b/src/ltjsreport.cls index 6f5a71a..cc794bf 100644 --- a/src/ltjsreport.cls +++ b/src/ltjsreport.cls @@ -38,7 +38,7 @@ %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{ltjsreport} - [2022/04/11 ltjsclasses ] + [2022/08/23 ltjsclasses ] \def\jsc@clsname{ltjsreport} \def\Cjascale{0.924715} \RequirePackage{luatexja} @@ -253,13 +253,15 @@ option, since LuaTeX does not support \string\mag\MessageBreak in pdf output}% \begingroup\catcode`\%=12\relax \directlua{ local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536 + local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@' + local print_scaled, sprint = luatexja.print_scaled, tex.sprint local t = lua.get_functions_table() t[\the\ltjs@@magnify@font@calc] = function() - tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@'))) + sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at))) end function luatexja.ltjs_unmagnify_fsize(a) - local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536)) - tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) + local s = print_scaled(floor(0.5+a/mpt*65536)) + sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s ) end } \endgroup diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 60e2835..b498551 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -147,8 +147,11 @@ \ltj@curjfnt\m@ne \ltj@curtfnt\m@ne -%%%%%%%% Attributes for character ranges \newcount\ltj@tempcnta +\newcount\ltj@@stack \newcount\ltj@@group@level +\ltj@@group@level\z@\ltj@@stack\z@ + +%%%%%%%% Attributes for character ranges \ltj@tempcnta\z@ \loop\ifnum\ltj@tempcnta<7 \expandafter\newattribute% @@ -298,9 +301,6 @@ } %%%%%%%% \ltjsetparameter -\newcount\ltj@@stack \newcount\ltj@@group@level -\ltj@@group@level\z@\ltj@@stack\z@ - \setbox\z@\hbox{% \directlua{% This value depends on the version of LuaTeX. luatexja.stack.hmode = -tex.getnest().mode diff --git a/src/luatexja.lua b/src/luatexja.lua index 3547090..4c504dc 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -164,11 +164,11 @@ local floor = math.floor local function print_scaled(s) local out, delta = '', 10 if s<0 then s, out = -s, out..'-' end - out=out..tostring(floor(s/65536)) .. '.' + out=out..tostring(s//65536) .. '.' s=10*(s%65536)+5 repeat if delta>65536 then s=s+32768-50000 end - out=out .. tostring(floor(s/65536)) + out=out .. tostring(s//65536) s=10*(s%65536); delta=delta*10 until s<=delta return out @@ -200,6 +200,8 @@ end ------------------------------------------------------------------------ -- CODE FOR GETTING/SETTING PARAMETERS ------------------------------------------------------------------------ +local getcount, texwrite = tex.getcount, tex.write +local cnt_stack = luatexbase.registernumber 'ltj@@stack' -- EXT: print parameters that don't need arguments do @@ -263,7 +265,7 @@ do function luatexja.ext_get_parameter_unary() local k= scan_arg() if unary_pars[k] then - tex.write(tostring(unary_pars[k](tex.getcount('ltj@@stack')))) + texwrite(tostring(unary_pars[k](getcount(cnt_stack)))) end ltjb.stop_time_measure('get_par') end @@ -318,7 +320,7 @@ do binary_pars.alxspmode = binary_pars.jaxspmode function luatexja.ext_get_parameter_binary(k, c) if binary_pars[k] then - tex.write(tostring(binary_pars[k](c,tex.getcount('ltj@@stack')))) + texwrite(tostring(binary_pars[k](c, getcount(cnt_stack)))) end ltjb.stop_time_measure('get_par') end