- local db
- local dnh = getfield(dn, 'value')
- for x in traverse(dnh) do
- if has_attr(x, attr_dir)%dir_node_auto == new_dir then
- setfield(dn, 'value', to_node(node_remove(dnh, x)))
- db=x; break
- end
- end
- Dnode.flush_list(dnh)
- db = db or create_dir_node(b, box_dir, new_dir, false)
- local w = getfield(b, 'width')
- local h = getfield(b, 'height')
- local d = getfield(b, 'depth')
- nh, nb = insert_before(head, b, db), nil
- nh, nb = node_remove(nh, b)
- local db_head, db_tail = nil
- for _,v in ipairs(dir_node_aux[box_dir][new_dir][getid(b)]) do
- local cmd, arg, nn = v[1], v[2]
- if cmd=='kern' then
- nn = node_new(id_kern)
- setfield(nn, 'kern', arg(w, h, d))
- elseif cmd=='whatsit' then
- nn = node_new(id_whatsit, arg)
- elseif cmd=='rotate' then
- nn = node_new(id_whatsit, sid_matrix)
- setfield(nn, 'data', arg)
- elseif cmd=='box' then
- nn = b; setfield(b, 'next', nil)
- setfield(nn, 'shift', getfield(nn, 'shift') + arg(w,h,d))
- end
- if db_head then
- insert_after(db_head, db_tail, nn)
- db_tail = nn
- else
- db_head, db_tail = nn, nn
- end
- --end
- setfield(db, 'head', db_head)
- ret, flag = db, true
+ box_dir = box_dir%dir_math_mod
+ local db
+ local dnh = getfield(dn, 'value')
+ for x in traverse(dnh) do
+ if has_attr(x, attr_dir)%dir_math_mod == new_dir then
+ setfield(dn, 'value', to_node(node_remove(dnh, x)))
+ db=x; break
+ end