diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-02 00:37:30 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-02 00:37:30 -0400 |
commit | ab7109065ced6feac485e3a5621c0f9c52f7aeec (patch) | |
tree | a242b446b39ab8d4dcd248ec2c5a75f2c45522c0 /src/util/shared.c | |
parent | update makefile (diff) | |
download | lazysphere-ab7109065ced6feac485e3a5621c0f9c52f7aeec.tar.gz lazysphere-ab7109065ced6feac485e3a5621c0f9c52f7aeec.tar.bz2 lazysphere-ab7109065ced6feac485e3a5621c0f9c52f7aeec.zip |
tac, ls fixes
Diffstat (limited to 'src/util/shared.c')
-rw-r--r-- | src/util/shared.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/util/shared.c b/src/util/shared.c index e207c6d..3e6fca3 100644 --- a/src/util/shared.c +++ b/src/util/shared.c @@ -20,6 +20,11 @@ void error(const char* format, ...) { FILE* get_file_s(const char* path, const char* type) { struct stat s; + if (streql("-", path) && type[0] == 'r') { + clearerr(stdin); + fflush(stdin); + return stdin; + } if (lstat(path, &s) < 0) { if (type[0] != 'r') goto read; fprintf(stderr, "error: failed to read %s: %s\n", path, strerror(errno)); @@ -40,10 +45,6 @@ read: } FILE* get_file(const char* path, const char* type) { - if (streql("-", path) && type[0] == 'r') { - clearerr(stdin); - return stdin; - } FILE* file = get_file_s(path, type); if (file == NULL) exit(EXIT_FAILURE); return file; |