diff options
author | dzwdz | 2022-08-07 00:04:54 +0200 |
---|---|---|
committer | dzwdz | 2022-08-07 00:04:54 +0200 |
commit | 93ce4f4248999adeb85c6859dc2b5c54d7a8d7b7 (patch) | |
tree | d2ed20a632cdaf782facce76c870413a47c3f60e /src/user/lib/stdlib.c | |
parent | 809f9a9899b219e33ec839b3f9bee644fcfecacc (diff) |
user/libc: strchr
Diffstat (limited to 'src/user/lib/stdlib.c')
-rw-r--r-- | src/user/lib/stdlib.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 11ca7b6..857b40e 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -36,11 +36,9 @@ int execv(const char *path, char *const argv[]) { fseek(file, 2, SEEK_SET); if (fgets(buf, sizeof buf, file)) { const char *argv [] = {buf, path, NULL}; - // TODO strchr - char *s = buf; - while (*s && *s != '\n') s++; - *s = '\0'; - execv(argv[0], (void*)argv); + char *endl = strchr(buf, '\n'); + if (endl) *endl = '\0'; + execv(buf, (void*)argv); } } |