lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Peter and Michael,

As you probably guessed I'm trying to match the asterisks and their
content but only capture what's between the asterisks. If I
mis-interpreted the manual, do any of you know the correct way to
capture what I have in mind? At the moment I'm using a post
processing pass over the parse tree: (...)

I interpret the manual like you, it should work. And it works
correctly with lpeg 0.4 but not with 0.5! So I think it's a bug in
the 0.5 version.

This is a known bug with a known fix.
Here's the script that I use to compile a patched lpeg...

--snip--snip--

rm -Rfv ~/usrc/lpeg-0.5/
tar -C  ~/usrc/ -xvzf $S/http/www.inf.puc-rio.br/~roberto/lpeg-0.5.tar.gz
cd      ~/usrc/lpeg-0.5/

chmod 644 lpeg.c
# http://lua-users.org/lists/lua-l/2007-03/msg00616.html
# http://lua-users.org/lists/lua-l/2007-03/msg00620.html
patch -p0 lpeg.c <<'%%%'
470c470,471
<           capture[captop - 1].siz = s - capture[captop - 1].s + 1;
---
          /* capture[captop - 1].siz = s - capture[captop - 1].s + 1; */
          capture[captop - 1].siz = (s - getoff(p)) - capture[captop - 1].s + 1;
%%%

export LUA51SRC=~/usrc/lua-5.1.2
gcc -g -Wall -shared -I$LUA51SRC/src \
 -o lpeg.so lpeg.c   2>&1 | tee og
lua51 test.lua

--snip--snip--

Cheers,
 Eduardo Ochs
 eduardoochs@gmail.com
 http://angg.twu.net/