lua-users home
lua-l archive

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

> The data mode patch defines a new mode 'd' for loadfile which raises
> an error at the lexical stage if any loop construct or function
> definition has been found when loading the file.

A simpler solution, whic requires no further patch to the code,
might be to include this function in lapi.c:

int lua_reserve (lua_State *L, const char* s, int rnew) {
  TString *ts = luaS_new(L,s);
  int r= ts->tsv.extra;
  ts->tsv.extra = rnew;
  return r;

To unreserve a keyword, do
	int r=lua_reserve(L,"while",0);

To re-reserve an unreserved keyword, do
where r is the value returned by the previous call to lua_reserve.

Then write your own version of loadfile the first unreserves all keywords
that you deem dangerous, calls the original loadfile, and then restores
all unreserved keywords.