shithub: wired

Download patch

ref: f5bdf0d83ce15094842bcb851488c5af35e51868
parent: 14f9b603b69995c787579f2b66020748b0fd4e3b
author: james palmer <james@biobuf.link>
date: Fri Jun 25 12:44:49 EDT 2021

strip eot before newlines.

this prevents the message:

test
<EOT>

from sending multiple newlines

--- a/main.c
+++ b/main.c
@@ -99,15 +99,6 @@
 	int len;
 	int i, j;
 
-	len = strlen(s);
-	
-	/* strip trailing nl */
-	for(i = len-1; i > 0; i--)
-		if(s[i] == '\n')
-			s[i] = 0;
-		else
-			break;
-
 	/* strip eot */
 	j = 0; len = strlen(s);
 	for(i = 0; i < len; i++) {
@@ -117,6 +108,14 @@
 		}
 	}
 	s[j] = 0;
+	
+	/* strip trailing nl */
+	len = strlen(s);
+	for(i = len-1; i > 0; i--)
+		if(s[i] == '\n')
+			s[i] = 0;
+		else
+			break;
 }
 
 void