shithub: 9pro

Download patch

ref: c5c3a280df977057089d9c5574f01368def7c35c
parent: d31d35b20437bf82efdbbaa78d495146cc8b8304
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Jan 4 17:01:53 EST 2022

9gc: ignore empty lines (thanks grobe0ba)

--- a/9gc.c
+++ b/9gc.c
@@ -355,8 +355,8 @@
 chatrw(C9aux *a)
 {
 	struct timeval t;
+	int n, sz, sz0;
 	fd_set r, e;
-	int n, sz;
 	C9tag tag;
 	C9ctx *ctx;
 	char *s;
@@ -384,7 +384,7 @@
 		c9proc(ctx);
 	} else if (FD_ISSET(0, &r)) {
 		s = (char*)a->rdbuf;
-		sz = sprintf(s, "%s → ", nick);
+		sz = sz0 = sprintf(s, "%s → ", nick);
 		for (;;) {
 			if ((n = read(0, s+sz, sizeof(a->rdbuf)-sz)) > 0)
 				sz += n;
@@ -392,8 +392,9 @@
 				exit(0);
 			if (s[sz-1] != '\n'){
 				s[sz-1] = '\n';
-			}else{
-				c9write(ctx, &tag, Chatfid, 0, s, sz);
+			} else {
+				if (s[sz0] != '\n')
+					c9write(ctx, &tag, Chatfid, 0, s, sz);
 				break;
 			}
 		}