shithub: mc

Download patch

ref: 1d4eded8eeec929b5d376c675421ee79a09bf216
parent: b040d8ccff7557ea1a33428020ae1c484081eab6
parent: 1397150d077b13445250c0470e2a96052523c0b7
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 16 19:21:35 EST 2016

Merge pull request #45 from andrewchambers/mktempfix

fixes to mktemp

--- a/lib/std/mktemp.myr
+++ b/lib/std/mktemp.myr
@@ -20,7 +20,7 @@
 const Retries = 100
 
 const mktemp = {base, opt, mode
-	var tmpdir, path, uniq
+	var tmpdir, path
 
 	match std.getenv("TMPDIR")
 	| `std.Some d:	tmpdir = d
@@ -28,21 +28,18 @@
 	;;
 
 	for var i = 0; i < Retries; i++
-		uniq = randpath(tmpdir, base)
-		path = pathcat(tmpdir, uniq)
+		path = randpath(tmpdir, base)
 		match std.openmode(path, opt | Ocreat, mode)
 		| `Fail e:
 			if e != Eexist
-				std.slfree(uniq)
+				std.slfree(path)
 				std.slfree(tmpdir)
 				-> `Fail e
 			;;
 		| `Ok fd:
-			std.slfree(uniq)
 			std.slfree(tmpdir)
 			-> `Ok (fd, path)
 		;;
-		std.slfree(uniq)
 		std.slfree(path)
 	;;
 	std.slfree(tmpdir)