[Dev-luatex] order of node linking matters
taco at elvenkind.com
Wed Dec 23 17:28:50 CET 2009
Paweł Jackowski wrote:
> someglyph.next = someother
> discretionary.pre = someglyph
> is not the same. Why?
Because a discretionary's pre, post, and replace lists are a bit
special: internally the discretionary does not just have a next and
a prev link for each of the head nodes, but also a 'tail' link.
That last one points to the last node in the list for each of
the three fields. That extra link is used during hyphenation and
at end-of-line situations (those parts of the code would be much
more complex == slower without it).
So, when in lua you assign to <disc>.pre, that assingment also has
to fix up that tail link (it does so by running the C equivalent
of the node.tail() function).
If the list you are assigning is well-formed, this is transparent.
But yours isn't yet at that point in the code, because 'b.next' still
points to 'd' at the moment the 'd.pre = b' is seen; and that confuses
the internal code into an assertion failure.
I admit this is obscure, but the general rule is simple: never
assign a list to a node field until you are sure its internal link
structure is correct. (a warning to this effect will be added to
More information about the dev-luatex