diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -2,10 +2,10 @@ | |||
2 | ** hash.c | 2 | ** hash.c |
3 | ** hash manager for lua | 3 | ** hash manager for lua |
4 | ** Luiz Henrique de Figueiredo - 17 Aug 90 | 4 | ** Luiz Henrique de Figueiredo - 17 Aug 90 |
5 | ** Modified by Waldemar Celes Filho | ||
6 | ** 12 May 93 | ||
7 | */ | 5 | */ |
8 | 6 | ||
7 | char *rcs_hash="$Id: $"; | ||
8 | |||
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | 11 | ||
@@ -184,11 +184,25 @@ static void firstnode (Hash *a, int h) | |||
184 | int i; | 184 | int i; |
185 | for (i=h; i<nhash(a); i++) | 185 | for (i=h; i<nhash(a); i++) |
186 | { | 186 | { |
187 | if (list(a,i) != NULL && tag(&list(a,i)->val) != T_NIL) | 187 | if (list(a,i) != NULL) |
188 | { | 188 | { |
189 | lua_pushobject (&list(a,i)->ref); | 189 | if (tag(&list(a,i)->val) != T_NIL) |
190 | lua_pushobject (&list(a,i)->val); | 190 | { |
191 | return; | 191 | lua_pushobject (&list(a,i)->ref); |
192 | lua_pushobject (&list(a,i)->val); | ||
193 | return; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | Node *next = list(a,i)->next; | ||
198 | while (next != NULL && tag(&next->val) == T_NIL) next = next->next; | ||
199 | if (next != NULL) | ||
200 | { | ||
201 | lua_pushobject (&next->ref); | ||
202 | lua_pushobject (&next->val); | ||
203 | return; | ||
204 | } | ||
205 | } | ||
192 | } | 206 | } |
193 | } | 207 | } |
194 | } | 208 | } |
@@ -257,3 +271,4 @@ void lua_next (void) | |||
257 | } | 271 | } |
258 | } | 272 | } |
259 | } | 273 | } |
274 | |||