[luatex] node.isert_before() bug?

Paul Isambert zappathustra at free.fr
Mon Jun 20 07:45:52 CEST 2011


Le 19/06/2011 23:40, Taco Hoekwater a écrit :
> Hi,
>
> On 19 jun. 2011, at 21:44, Khaled Hosny<khaledhosny at eglug.org>  wrote:
>
>> Hi all,
>> I just found that when node.insert_before() is executed on the very
>> first node in an hlist no nodes get inserted, I'm not sure if this is a
>> bug, feature or some dumb thing in the code I wrote. Tested with luatex
>> 0.70.1 and 0.67.0.
>
> I write this 'blind' now, but iirc node.insert_before() has  a return value. But if not, remeber that variables do not auto-update themselves in side-effects in lua, so if you need to alter a list head, you will need to do something like
>
>    head = newdir_var
>
> somewhere.

To say it otherwise, the new node is correctly inserted before the head 
(i.e. prev and next pointers are right), but the container (the box) 
still points to the original head; hence the new node is in the list but 
before its starting point, and thus ignored. Thus node.insert_before() 
should be used as:

head = node.insert_before(head, head, n)

if the head is returned somewhere, or even more explicitely otherwise, e.g:

tex.box[0].head = node.insert_before(tex.box[0].head, tex.box[0].head, n)

Best,
Paul


More information about the luatex mailing list