aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-01-26 14:52:47 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-01-26 14:52:47 -0200
commit19290a8e92a9b22f448b82c2bcb67ea635dee6ad (patch)
treec80bf06e01de92bbd9aa01f3e0d218fb0a8ec007
parentd845963349dbf5956cb527f3416af0bd1894d8f7 (diff)
downloadlua-19290a8e92a9b22f448b82c2bcb67ea635dee6ad.tar.gz
lua-19290a8e92a9b22f448b82c2bcb67ea635dee6ad.tar.bz2
lua-19290a8e92a9b22f448b82c2bcb67ea635dee6ad.zip
"dofile" issues an error when called with non string arguments, and
runs stdin when called without arguments.
-rw-r--r--inout.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/inout.c b/inout.c
index 23d69158..d76bff8c 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.26 1996/01/22 17:40:00 roberto Exp roberto $"; 8char *rcs_inout="$Id: inout.c,v 2.27 1996/01/26 14:05:28 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
@@ -122,7 +122,13 @@ void lua_internaldostring (void)
122void lua_internaldofile (void) 122void lua_internaldofile (void)
123{ 123{
124 lua_Object obj = lua_getparam (1); 124 lua_Object obj = lua_getparam (1);
125 if (lua_isstring(obj) && !lua_dofile(lua_getstring(obj))) 125 char *fname = NULL;
126 if (lua_isstring(obj))
127 fname = lua_getstring(obj);
128 else if (obj != LUA_NOOBJECT)
129 lua_error("invalid argument to function `dofile'");
130 /* else fname = NULL */
131 if (!lua_dofile(fname))
126 lua_pushnumber(1); 132 lua_pushnumber(1);
127 else 133 else
128 lua_pushnil(); 134 lua_pushnil();