*sum: support - when using -c
Signed-off-by: Mattias Andrée <maandree@kth.se>
diff --git a/libutil/crypt.c b/libutil/crypt.c
index 0de4269..3f849ba 100644
--- a/libutil/crypt.c
+++ b/libutil/crypt.c
@@ -89,13 +89,16 @@
mdchecklist(stdin, ops, md, sz, &formatsucks, &noread, &nonmatch);
} else {
for (; *argv; argc--, argv++) {
- if (!(fp = fopen(*argv, "r"))) {
+ if ((*argv)[0] == '-' && !(*argv)[1]) {
+ fp = stdin;
+ } else if (!(fp = fopen(*argv, "r"))) {
weprintf("fopen %s:", *argv);
ret = 1;
continue;
}
mdchecklist(fp, ops, md, sz, &formatsucks, &noread, &nonmatch);
- fclose(fp);
+ if (fp != stdin)
+ fclose(fp);
}
}