Don't exit on the first file that can't be opened for head and fold
This commit is contained in:
parent
7add068ade
commit
d9abff1e84
9
fold.c
9
fold.c
|
@ -1,8 +1,10 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -45,8 +47,11 @@ main(int argc, char *argv[])
|
||||||
if(argc == 0) {
|
if(argc == 0) {
|
||||||
fold(stdin, width);
|
fold(stdin, width);
|
||||||
} else for(; argc > 0; argc--, argv++) {
|
} else for(; argc > 0; argc--, argv++) {
|
||||||
if(!(fp = fopen(argv[0], "r")))
|
if(!(fp = fopen(argv[0], "r"))) {
|
||||||
eprintf("fopen %s:", argv[0]);
|
fprintf(stderr, "fopen %s: %s\n", argv[0],
|
||||||
|
strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
fold(fp, width);
|
fold(fp, width);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
8
head.c
8
head.c
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -33,8 +34,11 @@ main(int argc, char *argv[])
|
||||||
if(argc == 0) {
|
if(argc == 0) {
|
||||||
head(stdin, "<stdin>", n);
|
head(stdin, "<stdin>", n);
|
||||||
} else for(; argc > 0; argc--, argv++) {
|
} else for(; argc > 0; argc--, argv++) {
|
||||||
if(!(fp = fopen(argv[0], "r")))
|
if(!(fp = fopen(argv[0], "r"))) {
|
||||||
eprintf("fopen %s:", argv[0]);
|
fprintf(stderr, "fopen %s: %s\n", argv[0],
|
||||||
|
strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
head(fp, argv[0], n);
|
head(fp, argv[0], n);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user