shithub: mc

Download patch

ref: ce9ec1e3fef7efe379448a80ef3e7a907481e903
parent: 72ae3e0d761d69bc3b374cc026715ef1dc4a6a24
author: Andrew Chambers <andrewchamberss@gmail.com>
date: Thu Jan 28 15:48:01 EST 2016

remove duplicate writeall

--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -20,6 +20,7 @@
 use "types"
 use "utf"
 use "varargs"
+use "writeall"
 
 pkg std =
 	/* write to fd */
@@ -98,14 +99,16 @@
 }
 
 const fputv = {fd, fmt, ap
-	var sb, s, n
+	var sb, s
 
 	sb = mksb()
 	sbfmtv(sb, fmt, ap)
 	s = sbfin(sb)
-	n = writeall(fd, s)
-	slfree(s)
-	-> n
+	match writeall(fd, s)
+	| (n, _):
+		slfree(s)
+		-> n
+	;;
 }
 
 const fmt = {fmt, args
@@ -542,24 +545,6 @@
 		sbputc(sb, b[j - 1])
 	;;
 }
-
-const writeall = {fd, buf
-	var len
-
-	len = 0
-	while true
-		match write(fd, buf[len:])
-		| `Fail err:	break
-		| `Ok n:
-			len += n
-			if n == 0 || len == buf.len
-				break
-			;;
-		;;
-	;;
-	-> len
-}
-
 
 /* would use std.get(), but that's a dependency loop */
 const getint = {s, msg