shithub: riscv

Download patch

ref: f83dab12c69877853a58c2246a4468787ee637f0
parent: 6ddbe25d19bfa5a8c305e9e4292fa3ed0d24426a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Dec 12 16:18:31 EST 2014

acme/win: fix mistake

have to save partial reminder before null terminating current
event buffer :)

--- a/acme/bin/source/win/fs.c
+++ b/acme/bin/source/win/fs.c
@@ -94,7 +94,7 @@
 			nb = EVENTSIZE - partial;
 
 		/* fill buffer */
-		ep = e[n % nelem(e)];
+		ep = e[n++ % nelem(e)];
 		memmove(ep->b+partial, s, nb);
 		partial += nb;
 		s += nb;
@@ -118,18 +118,15 @@
 			ep->nb += wid;
 		}
 
+		/* put partial reminder onto next buffer */
+		if(partial > 0)
+			memmove(e[n % nelem(e)]->b, p, partial);
+
 		/* send buffer when not empty */
 		if(ep->nb > 0){
 			ep->b[ep->nb] = '\0';
 			sendp(win->cevent, ep);
 			recvp(writechan);
-		}
-		n++;
-
-		/* put partial reminder onto next buffer */
-		if(partial > 0){
-			ep = e[n % nelem(e)];
-			memmove(ep->b, p, partial);
 		}
 	}