Move join() to use String type

This commit is contained in:
Roberto E. Vargas Caballero 2018-03-04 14:06:24 +01:00 committed by sin
parent 7c2eec7bd1
commit 8d59405ae0

18
ed.c
View File

@ -833,22 +833,22 @@ join(void)
{ {
int i; int i;
char *t, c; char *t, c;
size_t len = 0, cap = 0; static String s;
static char *s;
free(s); free(s.str);
for (s = NULL, i = line1;; i = nextln(i)) { s.siz = s.cap = 0;
for (i = line1;; i = nextln(i)) {
for (t = gettxt(i); (c = *t) != '\n'; ++t) for (t = gettxt(i); (c = *t) != '\n'; ++t)
s = addchar(*t, s, &cap, &len); addchar_(*t, &s);
if (i == line2) if (i == line2)
break; break;
} }
s = addchar('\n', s, &cap, &len); addchar_('\n', &s);
s = addchar('\0', s, &cap, &len); addchar_('\0', &s);
delete(line1, line2); delete(line1, line2);
inject(s, 1); inject(s.str, 1);
free(s); free(s.str);
} }
static void static void