shithub: riscv

Download patch

ref: d010b87b1814a3bf4df3f13d0c4131fbd885b270
parent: e19308ee166dd085f7773621471a5fc589af45d4
author: ftrvxmtrx <ftrvxmtrx@gmail.com>
date: Tue Oct 18 16:27:08 EDT 2016

sam: corner cases are hard

--- a/sys/src/cmd/samterm/plan9.c
+++ b/sys/src/cmd/samterm/plan9.c
@@ -205,6 +205,7 @@
 			n += sprint(data+n, "f %s\n", addr);
 		n += sprint(data+n, "c\n");
 		s = memmove(data+n, m->data, m->ndata);
+		s--;
 		n += m->ndata;
 		if(data[n-1] != '\n')
 			data[n++] = '\n';
@@ -211,13 +212,11 @@
 		data[n] = 0;
 		replaced = 0;
 		for(;;){
-			s = strstr(s, ".\n");
+			s = strstr(s, "\n.\n");
 			if(s == nil)
 				break;
+			s[1] = '';
 			s += 2;
-			if(s[-3] != '\n')
-				continue;
-			s[0] = '';
 			replaced = 1;
 		}
 		n += sprint(data+n, ".\n");