aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1993-12-17 16:41:19 -0200
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1993-12-17 16:41:19 -0200
commitb405fb0ad740cc4ec21923989be220c64301569f (patch)
tree1a7418b832bf91ec80550b4c0e347cc015b87c95
parent212fdf861acfc0ecff0adec54501a0766183193d (diff)
downloadlua-b405fb0ad740cc4ec21923989be220c64301569f.tar.gz
lua-b405fb0ad740cc4ec21923989be220c64301569f.tar.bz2
lua-b405fb0ad740cc4ec21923989be220c64301569f.zip
hash manager for lua
-rw-r--r--hash.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/hash.c b/hash.c
index 8743d52c..fa1f3b8b 100644
--- a/hash.c
+++ b/hash.c
@@ -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
7char *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