From 44b71ca81696dbec561c0172d1b81533f1c2153e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 9 May 2000 11:50:16 -0300 Subject: [PATCH] defines for _ERRORMESSAGE and _ALERT --- lbuiltin.c | 14 +++++++------- ldo.c | 4 ++-- liolib.c | 6 +++--- lua.h | 6 +++++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lbuiltin.c b/lbuiltin.c index 060127f7..22b23e5a 100644 --- a/lbuiltin.c +++ b/lbuiltin.c @@ -1,5 +1,5 @@ /* -** $Id: lbuiltin.c,v 1.107 2000/04/25 16:55:09 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.108 2000/05/08 19:32:53 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -106,7 +106,7 @@ void luaB__ALERT (lua_State *L) { ** The library `liolib' redefines _ERRORMESSAGE for better error information. */ void luaB__ERRORMESSAGE (lua_State *L) { - lua_Object al = lua_rawgetglobal(L, "_ALERT"); + lua_Object al = lua_rawgetglobal(L, LUA_ALERT); if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */ const char *s = luaL_check_string(L, 1); char *buff = luaL_openspace(L, strlen(s)+sizeof("error: \n")); @@ -301,9 +301,9 @@ void luaB_call (lua_State *L) { int narg = (int)getnarg(L, arg); int i, status; if (err != LUA_NOOBJECT) { /* set new error method */ - lua_Object oldem = lua_getglobal(L, "_ERRORMESSAGE"); + lua_Object oldem = lua_getglobal(L, LUA_ERRORMESSAGE); lua_pushobject(L, err); - lua_setglobal(L, "_ERRORMESSAGE"); + lua_setglobal(L, LUA_ERRORMESSAGE); err = oldem; } /* push arg[1...n] */ @@ -313,7 +313,7 @@ void luaB_call (lua_State *L) { status = lua_callfunction(L, f); if (err != LUA_NOOBJECT) { /* restore old error method */ lua_pushobject(L, err); - lua_setglobal(L, "_ERRORMESSAGE"); + lua_setglobal(L, LUA_ERRORMESSAGE); } if (status != 0) { /* error in call? */ if (strchr(options, 'x')) { @@ -596,8 +596,8 @@ static void deprecated_funcs (lua_State *L) { /* }====================================================== */ static const struct luaL_reg builtin_funcs[] = { - {"_ALERT", luaB__ALERT}, - {"_ERRORMESSAGE", luaB__ERRORMESSAGE}, + {LUA_ALERT, luaB__ALERT}, + {LUA_ERRORMESSAGE, luaB__ERRORMESSAGE}, {"call", luaB_call}, {"collectgarbage", luaB_collectgarbage}, {"copytagmethods", luaB_copytagmethods}, diff --git a/ldo.c b/ldo.c index edbaab85..c65ac8d7 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.73 2000/04/14 18:12:35 roberto Exp roberto $ +** $Id: ldo.c,v 1.74 2000/05/08 19:32:53 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -223,7 +223,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) { static void message (lua_State *L, const char *s) { - const TObject *em = luaH_getglobal(L, "_ERRORMESSAGE"); + const TObject *em = luaH_getglobal(L, LUA_ERRORMESSAGE); if (*luaO_typename(em) == 'f') { *L->top = *em; incr_top; diff --git a/liolib.c b/liolib.c index 4ec56630..f8e6a9b5 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.61 2000/03/30 17:19:48 roberto Exp roberto $ +** $Id: liolib.c,v 1.62 2000/04/24 21:05:11 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -537,7 +537,7 @@ static void errorfb (lua_State *L) { char buff[MAXMESSAGE]; int level = 1; /* skip level 0 (it's this function) */ lua_Debug ar; - lua_Object alertfunc = lua_rawgetglobal(L, "_ALERT"); + lua_Object alertfunc = lua_rawgetglobal(L, LUA_ALERT); sprintf(buff, "error: %.200s\n", lua_getstring(L, lua_getparam(L, 1))); while (lua_getstack(L, level++, &ar)) { char buffchunk[60]; @@ -585,7 +585,7 @@ static void errorfb (lua_State *L) { static const struct luaL_reg iolib[] = { - {"_ERRORMESSAGE", errorfb}, + {LUA_ERRORMESSAGE, errorfb}, {"clock", io_clock}, {"date", io_date}, {"debug", io_debug}, diff --git a/lua.h b/lua.h index 92f50bb6..3aedc504 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.49 2000/05/08 19:32:53 roberto Exp roberto $ +** $Id: lua.h,v 1.50 2000/05/08 19:37:10 roberto Exp roberto $ ** Lua - An Extensible Extension Language ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** e-mail: lua@tecgraf.puc-rio.br @@ -16,6 +16,10 @@ #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" +#define LUA_ALERT "_ALERT" +#define LUA_ERRORMESSAGE "_ERRORMESSAGE" + + #define LUA_NOREF (-2) #define LUA_REFNIL (-1)