[luatex] prev field in discretionary nodes

Stephan Hennig mailing_list at arcor.de
Sun Jan 19 23:11:05 CET 2014


Am 18.01.2014 10:41, schrieb Stephan Hennig:

> What do the first prev fields in pre, post, replace sub-lists of
> discretionary nodes point to?

To expand a bit on the question and to give some context: I have been
trying to build a discretionary node and after doing the necessary
pointer handling, it seemed natural to hand-weave the discretionary into
an existing node list (without changing head) by doing something along
the lines

  disc.prev = <firstnodetoreplace>.prev
  disc.next = <lastnodetoreplace>.next
  disc.prev.next = disc
  disc.next.prev = disc

But that went massively wrong (don't remember details anymore).  Now,
what I actually did was replacing part of a node list with a
discretionary node where the replaced node list was put back into the
'replacement' sub-list of the discretionary node, i.e.,

  a x y z a   =>   a \discretionary{b b}{c c}{x y z} a

So, the fact that I reused sub-list xyz within the discretionary could
have been the reason for the failure, too.  (I did set x.prev as well as
z.next to nil.)

After some tinkering, I eventually refrained from reusing the cut node
list and used node.insert_before to insert the final discretionary node
instead of the hand-weaving, applying both changes at once.  That
worked, but let the original problem in the dark for me.  This leads me
to another question:

  What are best practices for node list manipulation?

Is reusing node lists in general safe?  When does one better operate on
node list copies?  Can nodes be linked manually by manipulating next and
prev fields?  Why do you better use node.insert_before/after even when
not changing head?  ...

And I'm still interested in my original question what the first prev
fields in discretionary sub-lists point to? :-)

Best regards,
Stephan Hennig


More information about the luatex mailing list