ソースコードの管理場所
Revision | 56de3d1bdee072fe1428afcb164769cfeb56e198 (tree) |
---|---|
Time | 2022-08-03 18:14:17 |
Author | Hironori Kitagawa <h_kitagawa2001@yaho...> |
Commiter | Hironori Kitagawa |
small reformatting
@@ -92,11 +92,12 @@ end | ||
92 | 92 | |
93 | 93 | local get_dir_count, get_adjust_dir_count |
94 | 94 | do |
95 | + local node_attr = node.has_attribute | |
95 | 96 | local function get_dir_count_inner(h) |
96 | 97 | if h then |
97 | 98 | if h.id==id_whatsit and h.subtype==sid_user and h.user_id==DIR then |
98 | - return ((node.has_attribute(h, attr_icflag) or 0)<PROCESSED_BEGIN_FLAG) | |
99 | - and (node.has_attribute(h,attr_dir)%dir_node_auto) or 0 | |
99 | + return ((node_attr(h, attr_icflag) or 0)<PROCESSED_BEGIN_FLAG) | |
100 | + and (node_attr(h,attr_dir)%dir_node_auto) or 0 | |
100 | 101 | else |
101 | 102 | return 0 |
102 | 103 | end |
@@ -263,13 +264,12 @@ local function create_dir_whatsit(hd, gc, new_dir) | ||
263 | 264 | return hd |
264 | 265 | else |
265 | 266 | local w = dir_pool[new_dir]() |
266 | - setfield(w, 'next', hd) | |
267 | 267 | set_attr(w, attr_icflag, PROCESSED_BEGIN_FLAG) |
268 | 268 | set_attr(hd, attr_icflag, |
269 | 269 | get_attr_icflag(hd) + PROCESSED_BEGIN_FLAG) |
270 | 270 | ensure_tex_attr(attr_icflag, 0) |
271 | 271 | ensure_tex_attr(attr_dir, 0) |
272 | - return w | |
272 | + return insert_before(hd, hd, w) | |
273 | 273 | end |
274 | 274 | end |
275 | 275 |
@@ -329,11 +329,12 @@ do | ||
329 | 329 | end |
330 | 330 | end |
331 | 331 | if hd==wh[1] then |
332 | - ltjs.list_dir =has_attr(hd,attr_dir) | |
332 | + ltjs.list_dir = has_attr(hd, attr_dir) | |
333 | 333 | local x = node_next(hd) |
334 | 334 | while x and getid(x)==id_glue and getsubtype(x)==3 do |
335 | 335 | node_remove(hd,x); node_free(x); x = node_next(hd) |
336 | 336 | end |
337 | + if #wh>1 then wh[#wh], wh[1]=nil, wh[#wh] end | |
337 | 338 | end |
338 | 339 | for i=1,#wh do |
339 | 340 | hd = node_remove(hd, wh[i]); node_free(wh[i]); wh[i] = nil |
@@ -344,17 +345,14 @@ do | ||
344 | 345 | ensure_tex_attr(attr_icflag, 0) |
345 | 346 | end |
346 | 347 | return hd |
347 | - else | |
348 | + elseif gc=='vtop' then | |
348 | 349 | local n = node_next(hd) |
349 | - if gc=='vtop' then | |
350 | - local w = create_dir_whatsit(hd, gc, ltjs.list_dir) | |
351 | - -- move dir whatsit after hd | |
352 | - setfield(hd, 'next', w); setfield(w, 'next', n) | |
353 | - return hd | |
354 | - else | |
355 | - hd = create_dir_whatsit(hd, gc, ltjs.list_dir) | |
356 | - return hd | |
357 | - end | |
350 | + local w = create_dir_whatsit(hd, gc, ltjs.list_dir) | |
351 | + -- move dir whatsit after hd | |
352 | + setfield(hd, 'next', w); setfield(w, 'next', n) | |
353 | + return hd | |
354 | + else | |
355 | + return create_dir_whatsit(hd, gc, ltjs.list_dir) | |
358 | 356 | end |
359 | 357 | end |
360 | 358 | end |
@@ -1036,23 +1034,12 @@ do | ||
1036 | 1034 | end |
1037 | 1035 | |
1038 | 1036 | do |
1039 | - -- supply direction whatsit to the main vertical list "of the next page" | |
1040 | 1037 | local function dir_adjust_pre_output(h, gc) |
1038 | + -- ここがメモリリークの原因? けど削除すると縦書きができない | |
1041 | 1039 | return to_node(create_dir_whatsit_vbox(to_direct(h), gc)) |
1042 | 1040 | end |
1043 | - ltjb.add_to_callback('pre_output_filter', | |
1044 | - dir_adjust_pre_output, | |
1041 | + ltjb.add_to_callback('pre_output_filter', dir_adjust_pre_output, | |
1045 | 1042 | 'ltj.direction', 10000) |
1046 | - | |
1047 | - function luatexja.direction.remove_end_whatsit() | |
1048 | - local h=tex.lists.page_head | |
1049 | - if h and (not h.next) and | |
1050 | - h.id==id_whatsit and h.subtype==sid_user and | |
1051 | - h.user_id == DIR then | |
1052 | - tex.lists.page_head = nil | |
1053 | - node.free(h) | |
1054 | - end | |
1055 | - end | |
1056 | 1043 | end |
1057 | 1044 | |
1058 | 1045 | -- append_to_vlist filter: done in ltj-lineskip.lua |