From 6bdba0cb4f74bdd5db059869904a976c1351db64 Mon Sep 17 00:00:00 2001 From: Starnakin Date: Thu, 19 Dec 2024 00:22:02 +0100 Subject: [PATCH] clean: simplify code && maybe fix --- src/shell/exec.c | 6 ++---- src/terminal/put.c | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/shell/exec.c b/src/shell/exec.c index 2d973d9..ce7459f 100644 --- a/src/shell/exec.c +++ b/src/shell/exec.c @@ -86,7 +86,7 @@ static char *get_line(void) struct key_event ev; const size_t size = sizeof(screen->line); - while (1) { + do { ev = get_key(); if (!ev.scan_code) continue; @@ -105,9 +105,7 @@ static char *get_line(void) kprintf("%c", ev.c); buf[i++] = ev.c; } - if (i >= size) - break; - } + } while (i < size); kprintf("\n"); screen->line[i] = '\0'; return screen->line; diff --git a/src/terminal/put.c b/src/terminal/put.c index ed268ed..39d6c61 100644 --- a/src/terminal/put.c +++ b/src/terminal/put.c @@ -30,6 +30,7 @@ void terminal_initialize(void) screens[i].fg_color = screens[i].default_color; screens[i].backgound = &image_icon; screens[i].font = eating_pasta_regular_13_font; + memset(screens[i].line, 0, sizeof(screen->line)); } // draw_icon(0, 0, screen->backgound); }