shithub: mc

Download patch

ref: 225486558c1552baf09cae2a17d313b061ee6edd
parent: b3124cebe026211ed88adc1dc1d7f09f74f45d35
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 10 17:31:28 EDT 2016

Fix 9front wait parser.

	It's not an empty string, it's ''. We were interpreting it wrong.

--- a/lib/std/wait+plan9.myr
+++ b/lib/std/wait+plan9.myr
@@ -13,6 +13,8 @@
 use "striter"
 use "syswrap"
 use "utf"
+use "sleq"
+use "fmt"
 
 pkg std =
 	type waitstatus = union
@@ -63,11 +65,12 @@
 }
 
 const parsestatus = {status	-> (waitstatus, pid)
-	var st : waitstatus, xpid, sp
+	var st : waitstatus
+	var spbuf : byte[:][5]
+	var xpid, sp
 
-	sp = strsplit(status, " ")
+	sp = bstrsplit(spbuf[:], status, " ")
 	if sp.len == 0
-		slfree(sp)
 		-> (`Wfailure, -1)
 	;;
 
@@ -74,9 +77,10 @@
 	match intparse(sp[0])
 	| `Some pid:
 		xpid = pid
-		if sp.len == 4 || (sp.len == 5 && sp[4].len > 0)	/* we exited with nil */
+		/* exits(nil) => sp[0] either not present or equal to '' */
+		if sp.len == 4 || (sp.len == 5 && sleq(sp[4], "''"))
 			st = `Wsuccess
-		elif sp.len == 5	/* we have a status */
+		elif sp.len == 5
 			st = `Wfailure
 		else	/* we have a malformed await message */
 			st = `Waiterror
@@ -86,7 +90,6 @@
 		st = `Waiterror
 	;;
 
-	slfree(sp)
 	-> (st, xpid)
 
 }