-local function concat(f, b)
- if f then
- if b then
- local h = getlist(f)
- setfield(node_tail(h), 'next', getlist(b))
- setfield(f, 'head', nil); node_free(f)
- setfield(b, 'head', nil); node_free(b)
- return Dnode.hpack(luatexja.jfmglue.main(h,false))
- else
- return f
+local concat
+do
+ local node_prev = node.direct.getprev
+ function concat(f, b)
+ if f then
+ if b then
+ local h, nh = getlist(f), getlist(b)
+ if getid(nh)==id_whatsit and getsubtype(nh)==sid_user then
+ nh=node_next(nh); node_free(node_prev(nh))
+ end
+ setfield(node_tail(h), 'next', nh)
+ setfield(f, 'head', nil); node_free(f)
+ setfield(b, 'head', nil); node_free(b)
+ local g = luatexja.jfmglue.main(h,false)
+ return node.direct.hpack(g)
+ else
+ return f
+ end
+ elseif b then
+ return b
+ else
+ local h = node_new(id_hlist)
+ setfield(h, 'subtype', 0)
+ setfield(h, 'width', 0)
+ setfield(h, 'height', 0)
+ setfield(h, 'depth', 0)
+ setfield(h, 'glue_set', 0)
+ setfield(h, 'glue_order', 0)
+ setfield(h, 'head', nil)
+ return h