lua-users home
lua-l archive

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


> My first guess is that lstrlib.c:gmatch is storing the lua_State object (see
> prepstate) used when creating the closure. When the closure is invoked, it
> uses this original lua_State instead of the current lua_State invoking the
> closure. But the original lua_State is busy resuming the new lua_State.
> 
> The immediate solution might be to add
> 
> 	gm->ms.L = L

Seems right.


> to strlib.c:gmatch_aux. I haven't tested it. It might result in wrong error
> messages? Maybe not. I don't know why lua_State is being stored in
> MatchState except to reduce the number of arguments needed to invoke all the
> other routines in strlib.c.

That was the whole point of the original 'MatchState': to reduce the
number of arguments among the several routines in the regex engine.  It
was then hijacked by 'gmatch', which created this bug.

-- Roberto