[luatex] Behaviour of pdf.print changed?

Paul Isambert zappathustra at free.fr
Wed May 22 12:40:06 CEST 2013


Arno Trautmann <Arno.Trautmann at gmx.de> a écrit:
> Hi all,
> 
> the following code is written after an article by Paul Isambert in the 
> TUGboat some time ago. The article was about drawing in LuaTeX using 
> direct pdf commands in the following way:
> 
> function pdf_print (...)
>    for _, str in ipairs({...}) do
>      pdf.print(str .. " ")
>    end
>    pdf.print("\\string\n")
> end
> 
> function line (p1,p2)
>    pdf_print(p1,p2,"l")
> end
> 
> Until yesterday, I used the line
> 
>    pdf.print("\string\n")
> 
> with a single backslash in front of the "string". This still works with 
> a TeX Live 2012 system with LuaTeX 0.70.2. However, with the latest TL 
> pretest and LuaTeX 0.77.0 (rev 4635), this results in
> 
> ./placeat.sty:21: LuaTeX error ./placeat.lua:19: invalid escape sequence 
> near '\
> s'
> stack traceback:
> 	[C]: in function 'dofile'
> 	[string "\directlua "]:1: in main chunk.
> l.21 ...ctlua{dofile(kpse.find_file("placeat.lua"))}
> 
> Now, I have to use the line like above with two backslashes:
> 
>    pdf.print("\\string\n")
> 
> which also seems to work with 0.70.2. Which behaviour is correct? 
> Unfortunately I don't really understand what the code does, so I cannot 
> guess how it should behave …

If the line

    pdf.print("\string\n")

is in a Lua file, there shouldn’t be any “\string” at all, which is useful only
with \directlua; here this results in the unexisting character “\s”
followed by “tring\n”.

So the code was wrong from the beginning, however you didn’t notice
the error because in Lua 5.1 “\s” is not an invalid sequence, whereas
it is in Lua 5.2.

Best,
Paul



More information about the luatex mailing list