shithub: wired

Download patch

ref: 9147e8fd46653341e51a7c77f83fd42c06588d6a
parent: f5bdf0d83ce15094842bcb851488c5af35e51868
author: james palmer <james@biobuf.link>
date: Fri Jun 25 14:57:55 EDT 2021

prevent blank messages being sent.

this would be handled by the condition of the while loop
however if the input window only contains newlines and EOT chars,
the filtered message would be empty so the case must be handled explicitly.

--- a/main.c
+++ b/main.c
@@ -143,7 +143,15 @@
 	 * hopefully nobody needs a message that large */
 	fprint(win->addrfd, ",");
 	while((n = read(win->datafd, buf, sizeof(buf)-1)) > 0) {
-		buf[n] = '\0'; filter(buf); /* null terminate and filter */
+
+		/* null terminate and filter */
+		buf[n] = '\0'; 
+		filter(buf); 
+
+		/* no blank messages */
+		if(buf[0] == 0)
+			return;
+
 		fprint(fd, "%s %s\n", prefix, buf);
 	};