shithub: riscv

Download patch

ref: 21001d4294c0496a2fc8c23eead89df44bd85825
parent: f5c6a870bfb6d92f623aaa42bb60f074638e37fe
parent: 2fd35e9bf8077c6a4d2b86d9b456711b18d5f332
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 20 23:44:16 EDT 2018

merge

--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -625,23 +625,29 @@
 	p = buf;
 	e = buf + sizeof(buf);
 	while((n = read(consfd, p, e - p)) > 0){
-		x = buf + n;
-		while(p < x && fullrune(p, x - p)){
+		x = p + n;
+		p = buf;
+		while((n = x - p) > 0){
+			if(!fullrune(p, n)){
+				memmove(buf, p, n);
+				break;
+			}
 			p += chartorune(&r, p);
-			if(r){
-				if(r == 021 || r == 023)	/* XON/XOFF */
-					continue;
-				if(r == '\n' && cr){
-					cr = 0;
-					continue;
-				}
-				if(cr = (r == '\r'))
-					r = '\n';
-				send(runechan, &r);
+			if(r == 021 || r == 023)	/* XON/XOFF */
+				continue;
+			if(r == 0 || r == Runeerror){
+				cr = 0;
+				continue;
 			}
+			if(r == '\n' && cr){
+				cr = 0;
+				continue;
+			}
+			if(cr = (r == '\r'))
+				r = '\n';
+			send(runechan, &r);
 		}
-		n = x - p;
-		memmove(buf, p, n);
+		if(n < 0) n = 0;
 		p = buf + n;
 	}