diff options
| -rw-r--r-- | lstate.c | 18 |
1 files changed, 16 insertions, 2 deletions
| @@ -1,11 +1,11 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 1.37 2000/09/11 17:38:42 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.38 2000/09/11 19:42:57 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | #include <stdarg.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| 10 | #include "lua.h" | 10 | #include "lua.h" |
| 11 | 11 | ||
| @@ -25,6 +25,19 @@ void luaB_opentests (lua_State *L); | |||
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | /* | ||
| 29 | ** built-in implementation for ERRORMESSAGE. In a "correct" environment | ||
| 30 | ** ERRORMESSAGE should have an external definition, and so this function | ||
| 31 | ** would not be used. | ||
| 32 | */ | ||
| 33 | static int errormessage (lua_State *L) { | ||
| 34 | const char *s = lua_tostring(L, 1); | ||
| 35 | if (s == NULL) s = "(no message)"; | ||
| 36 | fprintf(stderr, "error: %s\n", s); | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 28 | lua_State *lua_open (int stacksize) { | 41 | lua_State *lua_open (int stacksize) { |
| 29 | struct lua_longjmp myErrorJmp; | 42 | struct lua_longjmp myErrorJmp; |
| 30 | lua_State *L = luaM_new(NULL, lua_State); | 43 | lua_State *L = luaM_new(NULL, lua_State); |
| @@ -57,6 +70,7 @@ lua_State *lua_open (int stacksize) { | |||
| 57 | luaS_init(L); | 70 | luaS_init(L); |
| 58 | luaX_init(L); | 71 | luaX_init(L); |
| 59 | luaT_init(L); | 72 | luaT_init(L); |
| 73 | lua_register(L, LUA_ERRORMESSAGE, errormessage); | ||
| 60 | #ifdef DEBUG | 74 | #ifdef DEBUG |
| 61 | luaB_opentests(L); | 75 | luaB_opentests(L); |
| 62 | #endif | 76 | #endif |
