On 16/02/2010 11:13, Taco Hoekwater wrote:
Straight from pdftexmds:
\long\def\...@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.
Hello Taco,
Thanks for that (and to Manuel too): I was not sure if there were any
"pitfalls". Also, that simulates \pdfstrcmp itself, but I was wondering
about doing the entire functions (missing out all of the \ifnum and
\expandafter stuff). In partial pseudo-code (and using LaTeX3-style
function naming):
function strcmp:xxTF (A,B,C,D)
if A == B then
[Leave C on input stream]
else
[Leave D on input stream]
end
end
(Also, am I correct in thinking that there is no way to avoid needing
\unexpanded to get the string comparison "as is"?)
--
Joseph Wright