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;
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