diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-01-26 14:52:47 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-01-26 14:52:47 -0200 |
| commit | 19290a8e92a9b22f448b82c2bcb67ea635dee6ad (patch) | |
| tree | c80bf06e01de92bbd9aa01f3e0d218fb0a8ec007 | |
| parent | d845963349dbf5956cb527f3416af0bd1894d8f7 (diff) | |
| download | lua-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.c | 10 |
1 files changed, 8 insertions, 2 deletions
| @@ -5,7 +5,7 @@ | |||
| 5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | char *rcs_inout="$Id: inout.c,v 2.26 1996/01/22 17:40:00 roberto Exp roberto $"; | 8 | char *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) | |||
| 122 | void lua_internaldofile (void) | 122 | void 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(); |
