summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--client.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/client.c b/client.c
index 4f315c8..30174e9 100644
--- a/client.c
+++ b/client.c
@@ -358,21 +358,22 @@ void clientRecv(struct Client *client) {
 	}
 	client->len += read;
 
-	char *crlf;
+	char *lf;
 	char *line = client->buf;
 	for (;;) {
-		crlf = memmem(line, &client->buf[client->len] - line, "\r\n", 2);
-		if (!crlf) break;
+		lf = memchr(line, '\n', &client->buf[client->len] - line);
+		if (!lf) break;
 		if (verbose) {
-			fprintf(stderr, "\x1B[33m%.*s\x1B[m\n", (int)(crlf - line), line);
+			fprintf(stderr, "\x1B[33m%.*s\x1B[m\n", (int)(lf - line), line);
 		}
-		if (client->need || intercept(line, crlf - line)) {
-			crlf[0] = '\0';
+		if (client->need || intercept(line, lf - line)) {
+			lf[0] = '\0';
+			if (lf - line && lf[-1] == '\r') lf[-1] = '\0';
 			clientParse(client, line);
 		} else {
-			serverSend(line, crlf + 2 - line);
+			serverSend(line, lf + 1 - line);
 		}
-		line = crlf + 2;
+		line = lf + 1;
 	}
 	client->len -= line - client->buf;
 	memmove(client->buf, line, client->len);
2:51 -0500'>2019-02-08Add hi -nJune McEnroe 2019-02-08Elaborate hi man pageJune McEnroe 2019-02-08Use set for parent in hiJune McEnroe 2019-02-08Switch back to semantic keyword grouping in hiJune McEnroe 2019-02-08Match only the basename in hiJune McEnroe 2019-02-07Add mdoc syntax to hiJune McEnroe 2019-02-07Support multi-line C macros in hiJune McEnroe 2019-02-07Detect .mk files as makeJune McEnroe 2019-02-07Add make syntax to hiJune McEnroe 2019-02-07Add IRC output to hiJune McEnroe 2019-02-07Improve C syntax accuracy and add Format classJune McEnroe 2019-02-07Factor out hi checkJune McEnroe Fix subexpression bounds check and compile pattends. 2019-02-07Add Escape class to hiJune McEnroe 2019-02-07Add Todo class and parent syntax constraintJune McEnroe