`panic' function configurable via API

This commit is contained in:
Roberto Ierusalimschy
2002-04-16 14:08:28 -03:00
parent 13230c451b
commit c11d374c59
5 changed files with 29 additions and 7 deletions

View File

@@ -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;