summaryrefslogtreecommitdiff
path: root/lbaselib.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 /lbaselib.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 'lbaselib.c')
-rw-r--r--lbaselib.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 4a979814..119d80f7 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.32 2001/04/06 18:25:00 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.33 2001/04/11 14:42:41 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -311,6 +311,7 @@ static int passresults (lua_State *L, int status, int oldtop) {
311 } 311 }
312} 312}
313 313
314
314static int luaB_dostring (lua_State *L) { 315static int luaB_dostring (lua_State *L) {
315 int oldtop = lua_gettop(L); 316 int oldtop = lua_gettop(L);
316 size_t l; 317 size_t l;
@@ -320,6 +321,14 @@ static int luaB_dostring (lua_State *L) {
320} 321}
321 322
322 323
324static int luaB_loadstring (lua_State *L) {
325 int oldtop = lua_gettop(L);
326 size_t l;
327 const l_char *s = luaL_check_lstr(L, 1, &l);
328 const l_char *chunkname = luaL_opt_string(L, 2, s);
329 return passresults(L, lua_loadbuffer(L, s, l, chunkname), oldtop);
330}
331
323static int luaB_dofile (lua_State *L) { 332static int luaB_dofile (lua_State *L) {
324 int oldtop = lua_gettop(L); 333 int oldtop = lua_gettop(L);
325 const l_char *fname = luaL_opt_string(L, 1, NULL); 334 const l_char *fname = luaL_opt_string(L, 1, NULL);
@@ -327,6 +336,14 @@ static int luaB_dofile (lua_State *L) {
327} 336}
328 337
329 338
339static int luaB_loadfile (lua_State *L) {
340 int oldtop = lua_gettop(L);
341 const l_char *fname = luaL_opt_string(L, 1, NULL);
342 return passresults(L, lua_loadfile(L, fname), oldtop);
343}
344
345
346
330#define LUA_PATH l_s("LUA_PATH") 347#define LUA_PATH l_s("LUA_PATH")
331 348
332#define LUA_PATH_SEP l_s(";") 349#define LUA_PATH_SEP l_s(";")
@@ -753,6 +770,8 @@ static const luaL_reg base_funcs[] = {
753 {l_s("getglobal"), luaB_getglobal}, 770 {l_s("getglobal"), luaB_getglobal},
754 {l_s("gettagmethod"), luaB_gettagmethod}, 771 {l_s("gettagmethod"), luaB_gettagmethod},
755 {l_s("globals"), luaB_globals}, 772 {l_s("globals"), luaB_globals},
773 {l_s("loadfile"), luaB_loadfile},
774 {l_s("loadstring"), luaB_loadstring},
756 {l_s("newtype"), luaB_newtype}, 775 {l_s("newtype"), luaB_newtype},
757 {l_s("newtag"), luaB_newtype}, /* for compatibility 4.0 */ 776 {l_s("newtag"), luaB_newtype}, /* for compatibility 4.0 */
758 {l_s("next"), luaB_next}, 777 {l_s("next"), luaB_next},