diff options
author | dzwdz | 2022-07-27 21:32:39 +0200 |
---|---|---|
committer | dzwdz | 2022-07-27 21:32:39 +0200 |
commit | c8998127732765aabba020ece5e42befc6f1e305 (patch) | |
tree | 75e1c51ec57054e2f438cd3e88eadebfc2f83f2d /src/user/app | |
parent | 004a6fcd1a7d40564310c8348813d12ac0ea9de9 (diff) |
user/libc: a shitty fgets()
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/shell/shell.c | 13 |
1 files changed, 2 insertions, 11 deletions
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); } } |