shithub: mc

Download patch

ref: 0893bfe6bde2b9498a32354894b003adc13a9ea9
parent: 4078198dee11c72b6e735e704d21a2c0f39cb575
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 14 19:25:13 EST 2017

Back to a 9front C subset.

--- a/util/bitset.c
+++ b/util/bitset.c
@@ -109,6 +109,9 @@
 inline static int firstbit(size_t b)
 {
 	int n;
+	static const char bits[] = {
+		4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
+	};
 
 	n = 0;
 	if (!(b & 0xffffffff)) {
@@ -127,7 +130,7 @@
 		n += 4;
 		b >>= 4;
 	}
-	n += (char[16]){4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0}[b & 0xf];
+	n += bits[b & 0xf];
 	return n;
 }
 
--- a/util/htab.c
+++ b/util/htab.c
@@ -279,11 +279,13 @@
 	uint32_t m = 0x5bd1e995;
 	uint32_t r = 24;
 	uint32_t h, k, n;
-	uint8_t *p;
+	uint8_t *p, *end;
 	
 	h = Seed ^ len;
 	n = len & ~0x3ull;
-	for (p = ptr; p != ptr + n; p += 4) {
+	end = ptr;
+	end += n;
+	for (p = ptr; p != end; p += 4) {
 		k = (p[0] <<  0) |
 			(p[1] <<  8) |
 			(p[2] << 16) |