lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
In Lua4.0 if there was an error in the text passed to lua_dostring an error message would be output and control would be returned to the calling application. With Lua5.0alpha the program simply exists so the calling application can not do anything.


This is a bug in 5.0a. Although lua_dostring is there for compatibility
only (as lhf pointed out), it should catch errors like the previous
version. (Otherwise it would be pointless, to be there for compatibility
but with such a different behavior.)

I think that the patch LHF sent to the list for my lua_dofile problem
fixes this also: (in lib/lauxlib.c)

----

static void callalert (lua_State *L, int status) {
  if (status != 0) {
    lua_getglobal(L, "_ALERT");
    if (lua_isfunction(L, -1)) {
      lua_insert(L, -2);
      lua_call(L, 1, 0);
    }
    else {  /* no _ALERT function; print it on stderr */
      fprintf(stderr, "%s\n", lua_tostring(L, -2));
      lua_pop(L, 2);  /* remove error message and _ALERT */
    }
  }
}
-------


			Eero