[hackers] [PATCH 04/17] Move text to String type

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

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

---
 ed.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/ed.c b/ed.c
index ca55c61..2cf2708 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -54,10 +54,9 @@ static jmp_buf savesp;
 static char *lasterr;
 static size_t idxsize, lastidx;
 static struct hline *zero;
-static char *text;
+static String text;
 static char savfname[FILENAME_MAX];
 static char tmpname[FILENAME_MAX];
-static size_t sizetxt, memtxt;
 static int scratch;
 static int pflag, modflag, uflag, gflag;
 static size_t csize;
_AT_@ -236,11 +235,11 @@ gettxt(int line)
 	char *p;
 
 	lp = zero + getindex(line);
-	sizetxt = 0;
+	text.siz = 0;
 	off = lp->seek;
 
 	if (off == (off_t) -1)
-		return text = addchar('\0', text, &memtxt, &sizetxt);
+		return addchar_('\0', &text);
 
 repeat:
 	if (!csize || off < lasto || off - lasto >= csize) {
_AT_@ -254,14 +253,14 @@ repeat:
 	}
 	for (p = buf + off - lasto; p < buf + csize && *p != '\n'; ++p) {
 		++off;
-		text = addchar(*p, text, &memtxt, &sizetxt);
+		addchar_(*p, &text);
 	}
 	if (csize && p == buf + csize)
 		goto repeat;
 
-	text = addchar('\n', text, &memtxt, &sizetxt);
-	text = addchar('\0', text, &memtxt, &sizetxt);
-	return text;
+	addchar_('\n', &text);
+	addchar_('\0', &text);
+	return text.str;
 }
 
 static void
-- 
2.14.2
Received on Tue Mar 06 2018 - 12:57:56 CET

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