aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-04-11 15:39:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-04-11 15:39:37 -0300
commit6473f965ca699719b3b9908008f15da48cc2e6f1 (patch)
treebe13733e390e62f168995c82f9485a994b2e9464 /ldo.c
parent0e0e4a480e6d9b0125a96ca982a3e9571578a037 (diff)
downloadlua-6473f965ca699719b3b9908008f15da48cc2e6f1.tar.gz
lua-6473f965ca699719b3b9908008f15da48cc2e6f1.tar.bz2
lua-6473f965ca699719b3b9908008f15da48cc2e6f1.zip
new API functions to load (parse?) a chunk without running it.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/ldo.c b/ldo.c
index e676b68d..b2043b2b 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.132 2001/03/26 14:31:49 roberto Exp roberto $ 2** $Id: ldo.c,v 1.133 2001/04/06 19:26:06 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -255,7 +255,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
255} 255}
256 256
257 257
258static int parse_file (lua_State *L, const l_char *filename) { 258LUA_API int lua_loadfile (lua_State *L, const l_char *filename) {
259 ZIO z; 259 ZIO z;
260 int status; 260 int status;
261 int bin; /* flag for file mode */ 261 int bin; /* flag for file mode */
@@ -282,17 +282,8 @@ static int parse_file (lua_State *L, const l_char *filename) {
282} 282}
283 283
284 284
285LUA_API int lua_dofile (lua_State *L, const l_char *filename) { 285LUA_API int lua_loadbuffer (lua_State *L, const l_char *buff, size_t size,
286 int status; 286 const l_char *name) {
287 status = parse_file(L, filename);
288 if (status == 0) /* parse OK? */
289 status = lua_call(L, 0, LUA_MULTRET); /* call main */
290 return status;
291}
292
293
294static int parse_buffer (lua_State *L, const l_char *buff, size_t size,
295 const l_char *name) {
296 ZIO z; 287 ZIO z;
297 int status; 288 int status;
298 if (!name) name = l_s("?"); 289 if (!name) name = l_s("?");
@@ -302,19 +293,6 @@ static int parse_buffer (lua_State *L, const l_char *buff, size_t size,
302} 293}
303 294
304 295
305LUA_API int lua_dobuffer (lua_State *L, const l_char *buff, size_t size, const l_char *name) {
306 int status;
307 status = parse_buffer(L, buff, size, name);
308 if (status == 0) /* parse OK? */
309 status = lua_call(L, 0, LUA_MULTRET); /* call main */
310 return status;
311}
312
313
314LUA_API int lua_dostring (lua_State *L, const l_char *str) {
315 return lua_dobuffer(L, str, strlen(str), str);
316}
317
318 296
319/* 297/*
320** {====================================================== 298** {======================================================