mirror of
https://github.com/lua/lua
synced 2024-11-22 21:01:26 +03:00
defines for _ERRORMESSAGE and _ALERT
This commit is contained in:
parent
bad6365540
commit
44b71ca816
14
lbuiltin.c
14
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},
|
||||
|
4
ldo.c
4
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;
|
||||
|
6
liolib.c
6
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},
|
||||
|
6
lua.h
6
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user