diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-16 14:03:48 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-16 14:03:48 -0200 |
commit | 94686ce58554a80374eeff115ee5b87c184ed173 (patch) | |
tree | 9b41f32a05a41f7063df180015c13c5d9ae1d4a0 /tree.c | |
parent | 86b35cf4f6a824880239069d0afe282e95806aaa (diff) | |
download | lua-94686ce58554a80374eeff115ee5b87c184ed173.tar.gz lua-94686ce58554a80374eeff115ee5b87c184ed173.tar.bz2 lua-94686ce58554a80374eeff115ee5b87c184ed173.zip |
correction of function 'nextvar'
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_tree="$Id: tree.c,v 1.3 1994/11/10 20:41:37 roberto Exp roberto $"; | 6 | char *rcs_tree="$Id: tree.c,v 1.4 1994/11/14 21:40:14 roberto Exp roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -169,9 +169,18 @@ static TreeNode *tree_next (TreeNode *node, char *str) | |||
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | char *lua_varnext (char *n) | 172 | TreeNode *lua_varnext (char *n) |
173 | { | 173 | { |
174 | TreeNode *result = tree_next(constant_root, n); | 174 | TreeNode *result; |
175 | return result != NULL ? result->str : NULL; | 175 | char *name = n; |
176 | while (1) | ||
177 | { /* repeat until a valid (non nil) variable */ | ||
178 | result = tree_next(constant_root, name); | ||
179 | if (result == NULL) return NULL; | ||
180 | if (result->varindex != UNMARKED_STRING && | ||
181 | s_tag(result->varindex) != LUA_T_NIL) | ||
182 | return result; | ||
183 | name = result->str; | ||
184 | } | ||
176 | } | 185 | } |
177 | 186 | ||