shithub: mc

Download patch

ref: e1d944bcfc4518724fb631940b99439947855f10
parent: ac713e58b7a309587fbbe4571c31f8f5683e2f67
author: Ori Bernstein <[email protected]>
date: Thu Jan 9 19:23:57 EST 2014

Fix slinsert()

    We had an off by one error.

--- a/libstd/htab.myr
+++ b/libstd/htab.myr
@@ -1,8 +1,9 @@
 use "alloc.use"
-use "option.use"
-use "types.use"
+use "die.use"
 use "extremum.use"
 use "fmt.use"
+use "option.use"
+use "types.use"
 
 pkg std =
 	type htab(@k, @v) = struct
--- a/libstd/slinsert.myr
+++ b/libstd/slinsert.myr
@@ -1,5 +1,6 @@
 use "types.use"
 use "alloc.use"
+use "die.use"
 use "fmt.use"
 
 pkg std =
@@ -12,8 +13,8 @@
 
 	len = sl.len
 	sl = slgrow(sl, sl.len + 1)
-	for i = 0; i < (len - idx); i++
-		sl[sl.len - i] = sl[len - i]
+	for i = len - 1; i >= idx; i--
+		sl[i + 1] = sl[i]
 	;;
 	sl[idx] = elt
 	-> sl