From ec79f25286a4ac843280ae7377ec1e5b39a70cea Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 May 1995 14:23:58 -0300 Subject: new lua function "getstack"; new interface to function luaI_reportbug. --- inout.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'inout.c') diff --git a/inout.c b/inout.c index 9ea0fd82..afb0ee52 100644 --- a/inout.c +++ b/inout.c @@ -5,7 +5,7 @@ ** Also provides some predefined lua functions. */ -char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $"; +char *rcs_inout="$Id: inout.c,v 2.19 1995/05/02 18:43:03 roberto Exp roberto $"; #include #include @@ -19,6 +19,14 @@ char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $"; #include "tree.h" #include "lua.h" + +#ifndef MAXFUNCSTACK +#define MAXFUNCSTACK 100 +#endif + +#define MAXMESSAGE MAXFUNCSTACK*80 + + /* Exported variables */ Word lua_linenumber; Bool lua_debug; @@ -145,10 +153,12 @@ void lua_popfunction (void) } /* -** Report bug building a message. +** Report bug building a message and pushing it on the stack. */ -void luaI_reportbug (char *msg, int size) +void luaI_reportbug (char *s, int err) { + char msg[MAXMESSAGE]; + strcpy (msg, s); if (lua_debugline != 0) { if (funcStack) @@ -163,7 +173,7 @@ void luaI_reportbug (char *msg, int size) lua_constant[func->function]->str, func->file, line); line = func->line; func = func->next; - lua_popfunction(); + if (err) lua_popfunction(); } while (func); } else @@ -173,6 +183,7 @@ void luaI_reportbug (char *msg, int size) lua_debugline, lua_filename()); } } + lua_pushstring(msg); } @@ -288,3 +299,10 @@ void luaI_error (void) lua_error(s); } +void luaI_getstack (void) +{ + char *s = lua_getstring(lua_getparam(1)); + if (s == NULL) s = ""; + luaI_reportbug(s, 0); +} + -- cgit v1.2.3-55-g6feb