aboutsummaryrefslogtreecommitdiff
path: root/fallback.c
diff options
context:
space:
mode:
Diffstat (limited to 'fallback.c')
-rw-r--r--fallback.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/fallback.c b/fallback.c
index da7ed923..edec9184 100644
--- a/fallback.c
+++ b/fallback.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_fallback="$Id: fallback.c,v 2.8 1997/06/17 17:27:07 roberto Exp roberto $"; 6char *rcs_fallback="$Id: fallback.c,v 2.10 1997/07/03 22:06:06 roberto Exp $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <string.h> 9#include <string.h>
@@ -238,34 +238,19 @@ void luaI_settagmethod (void)
238} 238}
239 239
240 240
241static void stderrorim (void)
242{
243 lua_Object s = lua_getparam(1);
244 if (lua_isstring(s))
245 fprintf(stderr, "lua: %s\n", lua_getstring(s));
246}
247
248static TObject errorim = {LUA_T_CFUNCTION, {stderrorim}};
249
250
251TObject *luaI_geterrorim (void)
252{
253 return &errorim;
254}
255
256void luaI_seterrormethod (void) 241void luaI_seterrormethod (void)
257{ 242{
258 lua_Object func = lua_getparam(1); 243 lua_Object func = lua_getparam(1);
259 luaL_arg_check(lua_isnil(func) || lua_isfunction(func), 244 luaL_arg_check(lua_isnil(func) || lua_isfunction(func),
260 1, "function expected"); 245 1, "function expected");
261 luaI_pushobject(&errorim); 246 luaI_pushobject(&luaI_errorim);
262 errorim = *luaI_Address(func); 247 luaI_errorim = *luaI_Address(func);
263} 248}
264 249
265char *luaI_travfallbacks (int (*fn)(TObject *)) 250char *luaI_travfallbacks (int (*fn)(TObject *))
266{ 251{
267 int e; 252 int e;
268 if (fn(&errorim)) 253 if (fn(&luaI_errorim))
269 return "error"; 254 return "error";
270 for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) { /* ORDER IM */ 255 for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) { /* ORDER IM */
271 int t; 256 int t;
@@ -322,8 +307,8 @@ void luaI_setfallback (void)
322 luaL_arg_check(lua_isfunction(func), 2, "function expected"); 307 luaL_arg_check(lua_isfunction(func), 2, "function expected");
323 switch (luaI_findstring(name, oldnames)) { 308 switch (luaI_findstring(name, oldnames)) {
324 case 0: /* old error fallback */ 309 case 0: /* old error fallback */
325 oldfunc = errorim; 310 oldfunc = luaI_errorim;
326 errorim = *luaI_Address(func); 311 luaI_errorim = *luaI_Address(func);
327 replace = errorFB; 312 replace = errorFB;
328 break; 313 break;
329 case 1: /* old getglobal fallback */ 314 case 1: /* old getglobal fallback */