From c11d374c592d10b8ed649ffe501191039ee18757 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 Apr 2002 14:08:28 -0300 Subject: `panic' function configurable via API --- lstate.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 7b7466d6..714fac6a 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 1.87 2002/03/11 12:45:00 roberto Exp roberto $ +** $Id: lstate.c,v 1.88 2002/03/20 12:52:32 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -25,6 +25,16 @@ static void close_state (lua_State *L); +/* +** you can change this function through the official API +** call `lua_setpanicf' +*/ +static int default_panic (lua_State *L) { + fprintf(stderr, "unable to recover; exiting\n"); + return 0; +} + + static void stack_init (lua_State *L, lua_State *OL) { L->stack = luaM_newvector(OL, BASIC_STACK_SIZE, TObject); L->stacksize = BASIC_STACK_SIZE; @@ -52,6 +62,7 @@ static void f_luaopen (lua_State *L, void *ud) { G(L)->strt.hash = NULL; G(L)->Mbuffer = NULL; G(L)->Mbuffsize = 0; + G(L)->panic = &default_panic; G(L)->rootproto = NULL; G(L)->rootcl = NULL; G(L)->roottable = NULL; -- cgit v1.2.3-55-g6feb