[hackers] [PATCH 06/17] Move join() to use String type

From: quinq <quinq_AT_fifth.space>
Date: Tue, 6 Mar 2018 12:57:58 +0100

From: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>

---
 ed.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ed.c b/ed.c
index 5d85b52..8951d4b 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -833,22 +833,22 @@ join(void)
 {
 	int i;
 	char *t, c;
-	size_t len = 0, cap = 0;
-	static char *s;
+	static String s;
 
-	free(s);
-	for (s = NULL, i = line1;; i = nextln(i)) {
+	free(s.str);
+	s.siz = s.cap = 0;
+	for (i = line1;; i = nextln(i)) {
 		for (t = gettxt(i); (c = *t) != '\n'; ++t)
-			s = addchar(*t, s, &cap, &len);
+			addchar_(*t, &s);
 		if (i == line2)
 			break;
 	}
 
-	s = addchar('\n', s, &cap, &len);
-	s = addchar('\0', s, &cap, &len);
+	addchar_('\n', &s);
+	addchar_('\0', &s);
 	delete(line1, line2);
-	inject(s, 1);
-	free(s);
+	inject(s.str, 1);
+	free(s.str);
 }
 
 static void
-- 
2.14.2
Received on Tue Mar 06 2018 - 12:57:58 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 06 2018 - 13:01:58 CET