sim

the sim text editor
git clone git://ssnf.xyz/sim
Log | Files | Refs | README

commit 2615c4e01b82bbffabcfa444f618ed3da42ca17e
parent 9d424413ffb6aa49e3af6e0f876b95cc3431ece3
Author: ssnf <ssnf@ssnf.xyz>
Date:   Sat, 24 Jun 2023 15:45:46 +0000

take into account the NUL character in the str functions

Diffstat:
Msim.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sim.c b/sim.c @@ -1065,9 +1065,10 @@ str_addc(String* p, int c) static void str_adds(String* p, char* s, ulong n) { - str_insure(p, p->n + n); + str_insure(p, p->n + n + 1); memmove(p->s + p->n, s, n); p->n += n; + p->s[p->n] = '\0'; } static void @@ -1080,10 +1081,11 @@ str_delc(String* p) static void str_insert(String* p, String* q, Posn p0) { - str_insure(p, p->n + q->n); + str_insure(p, p->n + q->n + 1); memmove(p->s + p0 + q->n, p->s + p0, p->n - p0); memmove(p->s + p0, q->s, q->n); p->n += q->n; + p->s[p->n] = '\0'; } static void