hash manager for lua
This commit is contained in:
21
hash.c
21
hash.c
@@ -2,10 +2,10 @@
|
||||
** hash.c
|
||||
** hash manager for lua
|
||||
** Luiz Henrique de Figueiredo - 17 Aug 90
|
||||
** Modified by Waldemar Celes Filho
|
||||
** 12 May 93
|
||||
*/
|
||||
|
||||
char *rcs_hash="$Id: $";
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -184,12 +184,26 @@ static void firstnode (Hash *a, int h)
|
||||
int i;
|
||||
for (i=h; i<nhash(a); i++)
|
||||
{
|
||||
if (list(a,i) != NULL && tag(&list(a,i)->val) != T_NIL)
|
||||
if (list(a,i) != NULL)
|
||||
{
|
||||
if (tag(&list(a,i)->val) != T_NIL)
|
||||
{
|
||||
lua_pushobject (&list(a,i)->ref);
|
||||
lua_pushobject (&list(a,i)->val);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Node *next = list(a,i)->next;
|
||||
while (next != NULL && tag(&next->val) == T_NIL) next = next->next;
|
||||
if (next != NULL)
|
||||
{
|
||||
lua_pushobject (&next->ref);
|
||||
lua_pushobject (&next->val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pushnil();
|
||||
@@ -257,3 +271,4 @@ void lua_next (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user