shithub: mc

Download patch

ref: aa7e3e0a6facd876fea2235ccb6f1ee27e016d3a
parent: b0b5a28b5fe1346d7957786b505219e2a0e28a4e
author: Ori Bernstein <[email protected]>
date: Mon Jan 27 13:46:07 EST 2014

Add missing symbols to bitset.

--- a/libstd/bitset.myr
+++ b/libstd/bitset.myr
@@ -1,7 +1,8 @@
 use "alloc.use"
+use "extremum.use"
 use "mk.use"
+use "slfill.use"
 use "types.use"
-use "extremum.use"
 
 pkg std =
 	type bitset = struct
@@ -27,8 +28,6 @@
 	const bsiter	: (bs : bitset# -> bitset#)
 ;;
 
-const Szbits = 8*sizeof(size)
-
 const mkbitset = {
 	-> zalloc()
 }
@@ -42,12 +41,17 @@
 	free(bs)
 }
 
+const bsclear = {bs
+	slfill(bs.bits, 0)
+	-> bs
+}
+
 generic bsput = {bs, v
 	var idx
 	var off
 
-	idx = (v castto(size)) / Szbits
-	off = (v castto(size)) % Szbits
+	idx = (v castto(size)) / (8*sizeof(size))
+	off = (v castto(size)) % (8*sizeof(size))
 	ensurespace(bs, idx)
 	bs.bits[idx] |= (1 << off)
 }
@@ -56,8 +60,8 @@
 	var idx
 	var off
 
-	idx = (v castto(size)) / Szbits
-	off = (v castto(size)) % Szbits
+	idx = (v castto(size)) / (8*sizeof(size))
+	off = (v castto(size)) % (8*sizeof(size))
 	ensurespace(bs, idx)
 	bs.bits[idx] &= ~(1 << off)
 }
@@ -66,8 +70,8 @@
 	var idx
 	var off
 
-	idx = (v castto(size)) / Szbits
-	off = (v castto(size)) % Szbits
+	idx = (v castto(size)) / (8*sizeof(size))
+	off = (v castto(size)) % (8*sizeof(size))
 	ensurespace(bs, idx)
 	-> (bs.bits[idx] & (1 << off)) != 0
 }
@@ -124,7 +128,7 @@
 }
 
 const ensurespace = {bs, v
-	if bs.bits.len*Szbits <= v
+	if bs.bits.len*(8*sizeof(size)) <= v
 		bs.bits = slzgrow(bs.bits, v + 1)
 	;;
 }