ref: 7ae2f8e3d575dd2e918c3b389779415e63902d8b
parent: fec677da96689271e3be450a07961b56267f0afc
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Feb 9 06:09:25 EST 2012
Fixed bug inserting in keyword hash Code tested only that pointer of array hashing was null in order to insert directly in the queue, but it was falling of testing if first element if bigger than new element, because in this case we were creating a corrupted circular list
--- a/lex.c
+++ b/lex.c
@@ -78,14 +78,14 @@
for (bp = keywords; bp->str; bp++) {
register struct keyword *aux, *ant;
h = hashfun(bp->str);
- if (!(aux = khash[h])) {
+ if (!(aux = khash[h]) || strcmp(bp->str, aux->str) < 0) {
khash[h] = bp;
+ bp->next = aux;
continue;
}
- ant = aux;
- while (aux && strcmp(bp->str, aux->str) < 0) {
- ant = aux;
- aux = aux->next;
+ for (ant = aux; aux; ant = aux, aux = aux->next) {
+ if (strcmp(bp->str, aux->str) < 0)
+ break;
}
ant->next = bp;
bp->next = aux;