aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-17 12:30:05 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-17 12:30:05 -0200
commita66404aca612b68def99db6c7daba549a8bba4b8 (patch)
tree7567f225c54f3df3650752566eec63a426831142
parentd80659759bcbcabf8b964356e5c9c867cd55effd (diff)
downloadlua-a66404aca612b68def99db6c7daba549a8bba4b8.tar.gz
lua-a66404aca612b68def99db6c7daba549a8bba4b8.tar.bz2
lua-a66404aca612b68def99db6c7daba549a8bba4b8.zip
function "setfallback" now gives an error if called with wrong parameters.
-rw-r--r--fallback.c9
-rw-r--r--opcode.c8
2 files changed, 8 insertions, 9 deletions
diff --git a/fallback.c b/fallback.c
index ba88a22f..e7f6a8bf 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 1.15 1995/10/09 13:14:29 roberto Exp roberto $"; 6char *rcs_fallback="$Id: fallback.c,v 1.16 1995/10/17 11:52:38 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <string.h> 9#include <string.h>
@@ -48,10 +48,7 @@ void luaI_setfallback (void)
48 char *name = lua_getstring(lua_getparam(1)); 48 char *name = lua_getstring(lua_getparam(1));
49 lua_Object func = lua_getparam(2); 49 lua_Object func = lua_getparam(2);
50 if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func))) 50 if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func)))
51 { 51 lua_error("incorrect argument to function `setfallback'");
52 lua_pushnil();
53 return;
54 }
55 for (i=0; i<N_FB; i++) 52 for (i=0; i<N_FB; i++)
56 { 53 {
57 if (strcmp(luaI_fallBacks[i].kind, name) == 0) 54 if (strcmp(luaI_fallBacks[i].kind, name) == 0)
@@ -62,7 +59,7 @@ void luaI_setfallback (void)
62 } 59 }
63 } 60 }
64 /* name not found */ 61 /* name not found */
65 lua_pushnil(); 62 lua_error("incorrect argument to function `setfallback'");
66} 63}
67 64
68 65
diff --git a/opcode.c b/opcode.c
index fce78f72..9804f82b 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.44 1995/10/17 11:58:41 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.45 1995/10/17 14:12:45 roberto Exp $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdlib.h> 9#include <stdlib.h>
@@ -500,8 +500,10 @@ lua_Object lua_setfallback (char *name, lua_CFunction fallback)
500 stack[CBase].value.f = luaI_setfallback; 500 stack[CBase].value.f = luaI_setfallback;
501 lua_pushstring(name); 501 lua_pushstring(name);
502 lua_pushcfunction(fallback); 502 lua_pushcfunction(fallback);
503 do_protectedrun(1); 503 if (do_protectedrun(1) == 0)
504 return (Ref(top-1)); 504 return (Ref(top-1));
505 else
506 return LUA_NOOBJECT;
505} 507}
506 508
507 509