[luatex] Getting the extra primitives?

Taco Hoekwater taco at elvenkind.com
Tue Feb 16 12:13:21 CET 2010



Manuel Pégourié-Gonnard wrote:
> Hi Joseph,
> 
> Joseph Wright a écrit :
>> Next question, which is sort-of related (now I have some primitives!).
>> LuaTeX doesn't have \pdfstrcmp, so what is the best way to do
>> [...]
>> in LuaTeX? Obviously "using Lua", but I'm still trying to get the hang
>> of things.
> 
> You may want to have a look at Heiko's pdftexcmds package which does precisely this.

Straight from pdftexmds:

\long\def\pdf at strcmp#1#2{%
  \directlua0{%
    oberdiek.pdftexcmds.strcmp("\luaescapestring{#1}",%
        "\luaescapestring{#2}")%
  }%
}%

With:

function strcmp(A, B)
  if A == B then
    tex.write("0")
  elseif A < B then
    tex.write("-1")
  else
    tex.write("1")
  end
end

In lua, you can simply compare strings using the math operators.

Best wishes,
Taco



More information about the luatex mailing list