• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: Commit

ソースコードの管理場所


Commit MetaInfo

Revision0c148464df4d78c8edeef6aaf560fdf8805dff68 (tree)
Time2022-08-17 17:44:17
AuthorHironori Kitagawa <h_kitagawa2001@yaho...>
CommiterHironori Kitagawa

Log Message

ltj-stack.lua: use getglue()

Change Summary

Incremental Difference

--- a/src/ltj-adjust.lua
+++ b/src/ltj-adjust.lua
@@ -398,7 +398,6 @@ local adjust_width
398398 do
399399 local myaw_step1, myaw_step2, myaw_step1_last
400400 local dummy = function(p,t,n) return t, false end
401- local ltjs_fast_get_stack_skip = ltjs.fast_get_stack_skip
402401 function adjust_width(head)
403402 if not head then return head end
404403 local last_p
--- a/src/ltj-charrange.lua
+++ b/src/ltj-charrange.lua
@@ -3,7 +3,7 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.charrange',
6- date = '2020-08-17',
6+ date = '2022-08-17',
77 description = 'Handling the range of Japanese characters',
88 })
99 luatexja.charrange = {}
--- a/src/ltj-stack.lua
+++ b/src/ltj-stack.lua
@@ -3,7 +3,7 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.stack',
6- date = '2020-07-30',
6+ date = '2022-08-17',
77 description = 'LuaTeX-ja stack system',
88 })
99 luatexja.stack = {}
@@ -20,9 +20,11 @@ local STCK = luatexja.userid_table.STCK
2020 local fastcopy = table.fastcopy
2121 local setcount, getcount = tex.setcount, tex.getcount
2222 local scan_int, scan_keyword = token.scan_int, token.scan_keyword
23+local tex_nest = tex.nest
2324 ltjs.hmode = 0 -- dummy
2425
2526 local charprop_stack_table={};
27+
2628 ltjs.charprop_stack_table = charprop_stack_table
2729 charprop_stack_table[0]={}
2830
@@ -41,7 +43,7 @@ local function get_stack_level()
4143 charprop_stack_table[i] = fastcopy(charprop_stack_table[i-1])
4244 setcount('ltj@@stack', i)
4345 if gd~=0 then tex.globaldefs = gd end
44- if tex.nest[tex.nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ
46+ if tex_nest[tex_nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ
4547 local g = node_new(id_whatsit, sid_user)
4648 g.user_id=STCK; g.type=100; g.value=j; node.write(g)
4749 end
@@ -54,9 +56,7 @@ local function set_stack_table(m, p)
5456 local i = get_stack_level()
5557 charprop_stack_table[i][m] = p
5658 if luatexja.isglobal=='global' then
57- for j,v in pairs(charprop_stack_table) do
58- charprop_stack_table[j][m] = p
59- end
59+ for j,v in pairs(charprop_stack_table) do v[m] = p end
6060 end
6161 end
6262 ltjs.set_stack_table = set_stack_table
@@ -90,25 +90,21 @@ function ltjs.set_stack_font(m,c,p)
9090 end
9191
9292 -- EXT: sp: glue_spec
93+local getglue = node.getglue
9394 function ltjs.set_stack_skip(m,sp)
9495 local i = get_stack_level()
9596 if not sp then return end
9697 if not charprop_stack_table[i][m] then
9798 charprop_stack_table[i][m] = {}
9899 end
99- charprop_stack_table[i][m].width = sp.width
100- charprop_stack_table[i][m].stretch = sp.stretch
101- charprop_stack_table[i][m].shrink = sp.shrink
102- charprop_stack_table[i][m].stretch_order = sp.stretch_order
103- charprop_stack_table[i][m].shrink_order = sp.shrink_order
100+ local w,st,sh,sto,sho = getglue(sp)
101+ local c = charprop_stack_table[i][m]
102+ c.width, c.stretch, c.shrink, c.stretch_order, c.shrink_order = w, st, sh, sto, sho
104103 if luatexja.isglobal=='global' then
105104 for j,v in pairs(charprop_stack_table) do
106- if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end
107- charprop_stack_table[j][m].width = sp.width
108- charprop_stack_table[j][m].stretch = sp.stretch
109- charprop_stack_table[j][m].shrink = sp.shrink
110- charprop_stack_table[j][m].stretch_order = sp.stretch_order
111- charprop_stack_table[j][m].shrink_order = sp.shrink_order
105+ if not v[m] then v[m] = {} end
106+ local c = v[m]
107+ c.width, c.stretch, c.shrink, c.stretch_order, c.shrink_order = w, st, sh, sto, sho
112108 end
113109 end
114110 end
@@ -119,23 +115,21 @@ local orig_char_table = {}
119115 ltjs.orig_char_table = orig_char_table
120116 ltjs.list_dir = nil -- dummy
121117 ltjs.table_current_stack = nil -- dummy
118+local dummy_skip_table = { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
122119 function ltjs.report_stack_level(bsl)
123120 ltjs.table_current_stack = charprop_stack_table[bsl]
124121 return bsl
125122 end
126123 function ltjs.fast_get_stack_skip(m)
127- return ltjs.table_current_stack[m]
128- or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
124+ return ltjs.table_current_stack[m] or dummy_skip_table
129125 end
130126
131127 -- For other situations, use the following instead:
132128 function ltjs.get_stack_skip(m, idx)
133- return charprop_stack_table[idx][m]
134- or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
129+ return charprop_stack_table[idx][m] or dummy_skip_table
135130 end
136131 function ltjs.get_stack_table(mc, d, idx)
137- local i = charprop_stack_table[idx][mc]
138- return i or d
132+ return charprop_stack_table[idx][mc] or d
139133 end
140134
141135
--- a/src/luatexja.lua
+++ b/src/luatexja.lua
@@ -406,7 +406,7 @@ do
406406 else
407407 t[0] = {}; tex.print(cat_lp, '\\input ltj-kinsoku.tex\\relax')
408408 end
409- luatexja.load_kinsoku=nil
409+ luatexja.load_kinsoku=nil; ltjs.charprop_stack_table = nil
410410 end
411411 end
412412
Show on old repository browser