# [Dev-luatex] possible bug: tokenlist_to_luastring

James Quirk jjq at galcit.caltech.edu
Fri Oct 5 00:29:47 CEST 2007

On Thu, 4 Oct 2007, Taco Hoekwater wrote:

> James Quirk wrote:
> > Hi,
> >
> > With luatex-beta-0.11.2 when I run:
> >
> > \directlua 0 {
> >    local t = node.new('whatsit',8)
> >    t.mode  = 1
> >    t.data  = "1 0 0 rgb"
> >    print (t.data)
> > }
> > \bye
> >
> > I get the output:
> >
> > \BAD.1 0 0 rgb
> >
> > After investigating the matter, it seems that the routine
> > tokenlist_to_luastring is trying to output the reference count set up by the
> > routine tokenlist_from_lua. Hence the appearance
> > of \BAD. Is this a bug? Or am I missing something?
> > If it's the latter then I apologise.
>
> I believe that is a bug. I'll check it out tomorrow.
If it helps you track down the problem, my band-aid to
the above was to change line 444 of luatoken.c from:

s = tokenlist_to_cstring(p,1,&l);

to:

I've checked to see what the knock-on affects are and it seems
to be safe, but I'm not really in a position to judge.

On a related note, I noticed that is not possible to
read or write the data field in a pdf_annot whatsit.
For instance, I was trying to define an annotation using:

\directlua 0 {
local t  = node.new('whatsit',15)
t.width  = mywidth
t.height = myheight
t.depth  = mydepth
t.objnum = myobjnum
t.data   = mydata
tex.setbox(0,t)
}
\box0

Is this an oversight, or have you simply not had the chance to plumb
this facility in yet. I recognize that you must be snowed under with work,
but it occurred to me that the above would be much quicker for
defining a /Widget annotation than to have to use the token interface.
As an experiment, I added the necessary read and write code to lnodelib.c
and tested how long it would take to create 10,000 annotations.
The node route was an order of magnitude quicker than the token route.
It would also be useful to have a routine in the pdf library
that would be able to reserve a pdfobj so one could write:

\directlua 0 {
local t  = node.new('whatsit',15)
t.width  = mywidth
t.height = myheight
t.depth  = mydepth
t.objnum = pdf.reserveobjnum()
t.data   = mydata
tex.setbox(0,t)
}

Anyhow, please don't think that I'm not appreciate of your
efforts. Because the deeper I delve into LuaTeX, the more
I'm excited by the possibilites it offers.

Best Regards,

James

>
> Best wishes,
> Taco
>