Accept `-' as a name for standard input.
authormdw <mdw>
Fri, 30 Sep 2005 16:45:54 +0000 (16:45 +0000)
committermdw <mdw>
Fri, 30 Sep 2005 16:45:54 +0000 (16:45 +0000)
hashsum.c

index c9bb3ec..85fc6f4 100644 (file)
--- 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));