aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-22 16:13:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-22 16:13:12 -0300
commitd5feffdb607e4376bcea32c3642131962aa6857f (patch)
treecb540b7352a2086156e5679a347ef1d72accce81 /lapi.c
parentbb5627f3a4c9c8bf25b836f07708067b1170dde5 (diff)
downloadlua-d5feffdb607e4376bcea32c3642131962aa6857f.tar.gz
lua-d5feffdb607e4376bcea32c3642131962aa6857f.tar.bz2
lua-d5feffdb607e4376bcea32c3642131962aa6857f.zip
new function lua_nextvar
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index ae09baf4..65654138 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.35 1999/02/08 17:07:59 roberto Exp roberto $ 2** $Id: lapi.c,v 1.36 1999/02/12 19:23:02 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -426,10 +426,36 @@ void lua_settag (int tag)
426} 426}
427 427
428 428
429TaggedString *luaA_nextvar (TaggedString *g) {
430 if (g == NULL)
431 g = (TaggedString *)L->rootglobal.next; /* first variable */
432 else {
433 /* check whether name is in global var list */
434 luaL_arg_check((GCnode *)g != g->head.next, 1, "variable name expected");
435 g = (TaggedString *)g->head.next; /* get next */
436 }
437 while (g && g->u.s.globalval.ttype == LUA_T_NIL) /* skip globals with nil */
438 g = (TaggedString *)g->head.next;
439 return g;
440}
441
442
443char *lua_nextvar (char *varname) {
444 TaggedString *g = (varname == NULL) ? NULL : luaS_new(varname);
445 g = luaA_nextvar(g);
446 if (g) {
447 luaA_pushobject(&g->u.s.globalval);
448 return g->str;
449 }
450 else
451 return NULL;
452}
453
454
429 455
430/* 456/*
431** {====================================================== 457** {======================================================
432** To manipulate the implementation global variables 458** To manipulate some state information
433** ======================================================= 459** =======================================================
434*/ 460*/
435 461