sbase

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

commit 35cf3c79f29f181a3fcb5da6a18140b7ce5bd79c
parent f5cb020f06786e3c802b45f0a0093204693b5e90
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  4 Mar 2018 14:06:24 +0100

Move text to String type

Diffstat:
Med.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

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