From: mdw Date: Fri, 30 Sep 2005 16:45:54 +0000 (+0000) Subject: Accept `-' as a name for standard input. X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/commitdiff_plain/d7e6bc667592a29ab0b9aa8631cdd6162e3f94a1 Accept `-' as a name for standard input. --- diff --git a/hashsum.c b/hashsum.c index c9bb3ec..85fc6f4 100644 --- a/hashsum.c +++ b/hashsum.c @@ -211,7 +211,7 @@ static int fhash(const char *file, unsigned f, const gchash *gch, void *buf) ghash *h; int e; - if (!file) + if (!file || strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, f & f_binary ? "rb" : "r")) == 0) return (-1); @@ -441,7 +441,7 @@ static int checkhash(const char *file, unsigned f, unsigned long n = 0, nfail = 0; octet *buf = xmalloc(2 * gch->hashsz); - if (!file) + if (!file || strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, f & f_raw ? "r" : "rb")) == 0) { moan("couldn't open `%s': %s", file, strerror(errno)); @@ -571,7 +571,7 @@ static int hashfiles(const char *file, unsigned f, int rc = 0; int rrc; - if (!file) + if (!file || strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, f & f_raw ? "r" : "rb")) == 0) { moan("couldn't open `%s': %s", file, strerror(errno));