~foura/wired

9147e8fd46653341e51a7c77f83fd42c06588d6a — james palmer 10 months ago f5bdf0d
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.
1 files changed, 9 insertions(+), 1 deletions(-)

M main.c
M main.c => main.c +9 -1
@@ 143,7 143,15 @@ writemessage(char *prefix, AWin *win)
	 * 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);
	};