- local Dnode_remove, Dnode_next, Dnode_prev = Dnode.remove, Dnode.getnext, Dnode.getprev
- local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
- local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
- function luatexja.Dnode_remove (head, current)
- if head==current then
- local q, r = Dnode_next(current), Dnode_prev(current)
- setfield(current, 'next', nil)
- if q then setfield(q, 'prev', r) end
- if r and Dnode_next(r) == current then -- r is "real prev"
- setfield(r, 'next', q)
- end
- return q, q
- else
- return Dnode_remove(head, current)
+ if Dnode~=node then
+ local Dnode_remove, setfield = Dnode.remove, Dnode.setfield
+ local Dnode_next, Dnode_prev = Dnode.getnext, Dnode.getprev
+ function luatexja.Dnode_remove (head, current)
+ if head==current then
+ local q, r = Dnode_next(current), Dnode_prev(current)
+ if q then setfield(q, 'prev', r) end
+ if r and Dnode_next(r) == current then
+ setfield(r, 'next', q)
+ end
+ return q, q
+ else
+ return Dnode_remove(head, current)
+ end