[luatex] Getting the extra primitives?
T T
t34www at googlemail.com
Wed Feb 17 12:45:15 CET 2010
On 17 February 2010 11:08, Joseph Wright
<joseph.wright at morningstar2.co.uk> wrote:
> On 17/02/2010 09:27, Taco Hoekwater wrote:
>>
>> Lua stuff is not saved in the format unless you put in a lua bytecode
>> register (wrapped in a function). This is inconvenient, I know, but
>> serializing a whole lua state is a lot of work and therefore not done
>> (yet?).
>
> Okay, how would I do this? As it's only one function, I think some
> awkwardness setting things up is acceptable. AS I'm looking at this from a
> LaTeX-like point of view I'd like the format to be self-contained (no
> additional files required for it to at least load and function "as
> advertised").
Hi Joseph,
I had a quick stab at this (with essentially no prior experience in
LuaTeX programming). The following seemed to work for me and does what
you want:
\catcode `\{ = 1 \relax
\catcode `\} = 2 \relax
\catcode `\# = 6 \relax
\catcode `\^ = 7 \relax
\catcode `\^^I = 10 \relax
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
\else
\directlua
{
tex.enableprimitives('',tex.extraprimitives ())
lua.bytecode[1]=function (A, B)
if A == B then
tex.write("0")
elseif A < B then
tex.write("-1")
else
tex.write("1")
end
end
}
\long\def\pdfstrcmp#1#2{%
\directlua
{%
lua.bytecode[1]("\luaescapestring{#1}","\luaescapestring{#2}")%
}%
}
\fi
\dump
Cheers,
Tomek
More information about the luatex
mailing list