correction of function 'nextvar'

This commit is contained in:
Roberto Ierusalimschy
1994-11-16 14:03:48 -02:00
parent 86b35cf4f6
commit 94686ce585
5 changed files with 41 additions and 54 deletions

17
tree.c
View File

@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
char *rcs_tree="$Id: tree.c,v 1.3 1994/11/10 20:41:37 roberto Exp roberto $";
char *rcs_tree="$Id: tree.c,v 1.4 1994/11/14 21:40:14 roberto Exp roberto $";
#include <stdlib.h>
@@ -169,9 +169,18 @@ static TreeNode *tree_next (TreeNode *node, char *str)
}
}
char *lua_varnext (char *n)
TreeNode *lua_varnext (char *n)
{
TreeNode *result = tree_next(constant_root, n);
return result != NULL ? result->str : NULL;
TreeNode *result;
char *name = n;
while (1)
{ /* repeat until a valid (non nil) variable */
result = tree_next(constant_root, name);
if (result == NULL) return NULL;
if (result->varindex != UNMARKED_STRING &&
s_tag(result->varindex) != LUA_T_NIL)
return result;
name = result->str;
}
}