T T wrote:
On 17 February 2010 11:08, Joseph Wright
<[email protected]> 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:

Yes. A somewhat more generic solution is this:

\directlua
  {
    tex.enableprimitives('',tex.extraprimitives ())
    lua.bytecode[1]=function ()
      function pdfstrcmp (A, B)
        if A == B then
          tex.write("0")
        elseif A < B then
          tex.write("-1")
        else
          tex.write("1")
        end
      end
    end
    lua.bytecode[1]()
  }
 \everyjob{\directlua{lua.bytecode[1]()}}
 \long\def\pdfstrcmp#1#2{%
  \directlua
    {%
      pdfstrcmp("\luaescapestring{#1}","\luaescapestring{#2}")%
    }%
 }


Reply via email to