cmp: suppress file open error with sflag

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
Hiltjo Posthuma 2014-04-09 15:28:16 +02:00 committed by sin
parent 560340341f
commit 6dd138613e
1 changed files with 10 additions and 4 deletions

14
cmp.c
View File

@ -38,13 +38,19 @@ main(int argc, char *argv[])
usage(); usage();
fp[0] = fopen(argv[0], "r"); fp[0] = fopen(argv[0], "r");
if (!fp[0]) if (!fp[0]) {
enprintf(Error, "fopen %s:", argv[0]); if(!sflag)
weprintf("fopen %s:", argv[0]);
exit(Error);
}
fp[1] = stdin; fp[1] = stdin;
if (argc == 2) { if (argc == 2) {
if(!(fp[1] = fopen(argv[1], "r"))) if(!(fp[1] = fopen(argv[1], "r"))) {
enprintf(Error, "fopen %s:", argv[1]); if(!sflag)
weprintf("fopen %s:", argv[1]);
exit(Error);
}
} }
for(n = 1; ; n++) { for(n = 1; ; n++) {