summaryrefslogtreecommitdiff
path: root/src/util/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/shared.c')
-rw-r--r--src/util/shared.c9
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;