[luatex] Getting the extra primitives?

luigi scarso luigi.scarso at gmail.com
Tue Feb 16 16:43:29 CET 2010


On Tue, Feb 16, 2010 at 1:14 PM, Joseph Wright <joseph.wright at uea.ac.uk> wrote:
> Hello all,
>
> Thanks for the help thus far. I'm now stuck on the next step, I'm afraid.
> With a file to build a format something like:
>
> \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
>  \long\def\pdfstrcmp#1#2{%
>    \directlua
>      {%
>        joseph.strcmp("\luaescapestring{#1}","\luaescapestring{#2}")%
>      }%
>  }
>  \directlua
>    {
>      tex.enableprimitives('',tex.extraprimitives ())
>      module("joseph",package.seeall)
>      function strcmp(A, B)
>        if A == B then
>          tex.write("0")
>        elseif A < B then
>          tex.write("-1")
>        else
>          tex.write("1")
>        end
>      end
>    }
> \fi
> \dump
>
> If I then try building the format and using it, with something as simple as
>
> \ifnum\pdfstrcmp{a}{b}=0\TRUE\else\FALSE\fi
>
> I get:
>
> ! LuaTeX error <\directlua >:1: attempt to index global 'joseph' (a nil
> value)
> stack traceback:
>        <\directlua >:1: in main chunk.
> \pdfstrcmp ...ring {#1}","\luaescapestring {#2}")}
>
> <*> \ifnum\pdfstrcmp{a}{b}
>                          =0 \TRUE\else\FALSE\fi
> ?
>
> Obviously I'm still getting something wrong.

joseph  = joseph  or { }

Next you need to implement strcmp function

function joseph.strcmp(A,B)
-- your implementation here

end

-- 
luigi



More information about the luatex mailing list