From c8998127732765aabba020ece5e42befc6f1e305 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 27 Jul 2022 21:32:39 +0200 Subject: user/libc: a shitty fgets() --- src/user/app/shell/shell.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/user/app/shell/shell.c') diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c index 995ce53..7367a4b 100644 --- a/src/user/app/shell/shell.c +++ b/src/user/app/shell/shell.c @@ -10,15 +10,6 @@ int main(); -static int readline(char *buf, size_t max, FILE *f) { - char c = '\0'; - size_t pos = 0; - while (pos < (max-1) && c != '\n' && fread(&c, 1, 1, f)) - buf[pos++] = c; - buf[pos++] = '\0'; - return pos; -} - static void execp(char **argv) { if (!argv || !*argv) return; if (argv[0][0] == '/') { @@ -125,8 +116,8 @@ int main(int argc, char **argv) { for (;;) { if (f == stdin) printf("$ "); - readline(buf, 256, f); - if (feof(f)) return 0; + if (!fgets(buf, 256, f)) + return 0; run(buf); } } -- cgit v1.2.3