sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 8d59405ae01449e60e9aeb665de664467ee067fd
parent 7c2eec7bd1139813677e37c8acefdd4d9df90838
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  4 Mar 2018 14:06:24 +0100

Move join() to use String type

Diffstat:
Med.c | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ed.c b/ed.c @@ -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