shithub: wired

Download patch

ref: 1abb9736d43ec046c91975abedadce884ecc98a6
parent: 783a075cd2cec169631759a815deaf3717edb925
author: james palmer <foura@biobuf.link>
date: Mon Jun 7 19:54:57 EDT 2021

fix strange behaviour on control-d

--- a/main.c
+++ b/main.c
@@ -58,9 +58,9 @@
 				
 			break;
 		case 'I':
-			if(strcmp(ev.text, "") == 0)
+			if(strchr(ev.text, '') != 0)
 				sendp(ctl, "send");
-				
+
 			break;
 		case 'l':
 		case 'L':
@@ -73,19 +73,22 @@
 readbody(AWin *w)
 {
 	Biobuf *fd;
+	int addr;
 	char *buf;
 	int i;
 	
-	fd = awinfsbopen(w, "body", OREAD);
+	sleep(10);
+	
+	addr = awinfsopen(w, "addr", OWRITE);
+	fd = awinfsbopen(w, "data", OREAD);
+
+	fprint(addr, ",");
 	buf = Brdstr(fd, '\0', 0);
-	Bterm(fd);
 	
-	awinclear(w);
-	
 	if(!buf)
 		return nil;
 	
-	for(i = strlen(buf)-1; i > 0; i--) {
+	for(i = strlen(buf)-1; i >= 0; i--) {
 		if(buf[i] == '' || buf[i] == '\n')
 			buf[i] = '\0';
 		else
@@ -92,6 +95,14 @@
 			break;
 	}
 	
+	if(buf[0] == '\0') {
+		awinclear(w);
+		return nil;
+	}
+	
+	awinclear(w);
+	Bterm(fd);
+	close(addr);
 	return buf;
 }