diff options
| author | Nakidai <nakidai@disroot.org> | 2025-04-15 15:13:30 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-04-15 15:13:30 +0300 |
| commit | f86c865eb27b143b36813b7ea7d26003ce107a3a (patch) | |
| tree | 2ce3a4a0f300fe3f98d9138fba8da7e12ce4709d | |
| parent | 7f25ea2102a178c2b59230c36c962124b55505ba (diff) | |
| download | 3cl-f86c865eb27b143b36813b7ea7d26003ce107a3a.tar.gz 3cl-f86c865eb27b143b36813b7ea7d26003ce107a3a.zip | |
Treat empty files as valid
Though with -v set warning is printed
| -rw-r--r-- | main.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main.c b/main.c index ff1d56e..301c59b 100644 --- a/main.c +++ b/main.c @@ -72,7 +72,9 @@ int main(int argc, char **argv) #endif /* __OpenBSD__ */ int bytes_read = fread(file.buffer, 1, file.size, f); - if (ferror(f) || bytes_read != file.size || !bytes_read) + if (!bytes_read) + return (verbose ? warnx("reading empty file") : 0, 0); + else if (ferror(f) || bytes_read != file.size) errx(1, "couldn't read %s", *argv); fclose(f); |