richterm

"terminal emulator" with support for text fonts and images for plan9
git clone git://nsmpr.xyz/richterm.git
Log | Files | Refs | README

commit 03262c40695a4e1e7d29804f13f721bfec77fe71
parent 96cb5ca71e6c263723c8a74679d9021ec8d4376b
Author: Pavel Renev <an2qzavok@gmail.com>
Date:   Sat,  7 Aug 2021 20:58:07 +0000

fix broken fs/ctl

Diffstat:
Mfs.c | 22++++++++++++----------
Mrichterm.h | 2++
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs.c b/fs.c @@ -13,20 +13,20 @@ Object *newobj; char * ctlcmd(char *buf) { - int n; + int n, i, j; char *args[256]; n = tokenize(buf, args, 256); if (n <= 0) return "expected a command"; if (strcmp(args[0], "remove") == 0) { - int i, j; for (i = 0; i < n; i++) { for (j = 0; j < rich.count; j++) { + if (rich.obj[j] == olast) continue; if (strcmp(rich.obj[j]->id, args[i]) == 0) { - Object *sp, *tp; + Object **sp, **tp; rmobjectftree(rich.obj[j]); free(rich.obj[j]); - sp = rich.obj[j]; - tp = rich.obj[j+1]; + sp = &rich.obj[j]; + tp = &rich.obj[j+1]; memcpy(sp, tp, (rich.count - j - 1) * sizeof(Object *)); rich.count--; break; @@ -34,12 +34,14 @@ ctlcmd(char *buf) } } } else if (strcmp(args[0], "clear") == 0) { - for (rich.count--; rich.count == 0; rich.count--) { - rmobjectftree(rich.obj[rich.count]); - free(rich.obj[rich.count]); + for (i = 0; i < rich.count; i++) { + if (rich.obj[i] == olast) continue; + rmobjectftree(rich.obj[i]); + free(rich.obj[i]); } - rich.count = 0; - rich.obj = realloc(rich.obj, 0); + rich.count = 1; + rich.obj = realloc(rich.obj, 1 * sizeof(Object *)); + rich.obj[0] = olast; } else return "unknown command"; return nil; } diff --git a/richterm.h b/richterm.h @@ -24,6 +24,8 @@ struct Object { Font *font; }; +extern Object *olast; + Object * mkobjectftree(Object *, File *); void rmobjectftree(Object *);