summaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-12 15:42:32 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-12 15:42:32 -0300
commit0b3b6850c90999ebf7217f51ee74184af732285d (patch)
tree2a5238ce7bbe73c8ecdb5e3790727108318b4f90 /lstate.c
parent5d033f33ebe1887ea19853b5158fba48d452ba0f (diff)
downloadlua-0b3b6850c90999ebf7217f51ee74184af732285d.tar.gz
lua-0b3b6850c90999ebf7217f51ee74184af732285d.tar.bz2
lua-0b3b6850c90999ebf7217f51ee74184af732285d.zip
`back-up' definition for ERRORMESSAGE
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lstate.c b/lstate.c
index 44a9fc96..b45e31ce 100644
--- a/lstate.c
+++ b/lstate.c
@@ -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*/
33static 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
28lua_State *lua_open (int stacksize) { 41lua_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