shithub: scc

Download patch

ref: 94fd29519bd9650953b1f9b67ae62c628678297d
parent: 7267f1845ababef928b82541085e574a20d29856
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed May 30 16:08:42 EDT 2012

Fixed bug calculating hash of identifiers

Instead of calculating hash as modulus, we were using the division.

--- a/lex.c
+++ b/lex.c
@@ -80,7 +80,7 @@
 
 	for (bp = keywords; bp->str; bp++) {
 		register struct keyword *aux, *ant;
-		h = hashfun(bp->str) % (NR_KWD_HASH - 1);
+		h = hashfun(bp->str) & (NR_KWD_HASH - 1);
 		if (!(aux = khash[h]) || strcmp(bp->str, aux->str) < 0) {
 			khash[h] = bp;
 			bp->next = aux;
@@ -142,7 +142,7 @@
 		;
 	} else {
 		switch (ch) {
-		case '&': case '|': 
+		case '&': case '|':
 			if ((c = getc(yyin)) == ch) {
 				yytext[1] = yytext[0] = ch;
 				yytext[2] = '\0';
@@ -152,7 +152,7 @@
 				ungetc(c, yyin);
 			}
 		case '^': case '=': case '<': case '>':
-		case '*': case '+': case '-': case '/': 
+		case '*': case '+': case '-': case '/':
 			if ((c = getc(yyin)) == '=') {
 				yytext[0] = ch;
 				yytext[1] = c;