sed: Print better error message when open fails
This commit is contained in:
parent
2ee4c13433
commit
9a17de569a
17
sed.c
17
sed.c
|
@ -370,12 +370,17 @@ compile(char *s, int isfile)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (!isfile && !*s) /* empty string script */
|
if (isfile) {
|
||||||
return;
|
f = fopen(s, "r");
|
||||||
|
if (!f)
|
||||||
f = isfile ? fopen(s, "r") : fmemopen(s, strlen(s), "r");
|
eprintf("fopen %s:", s);
|
||||||
if (!f)
|
} else {
|
||||||
eprintf("fopen/fmemopen:");
|
if (!*s) /* empty string script */
|
||||||
|
return;
|
||||||
|
f = fmemopen(s, strlen(s), "r");
|
||||||
|
if (!f)
|
||||||
|
eprintf("fmemopen:");
|
||||||
|
}
|
||||||
|
|
||||||
/* NOTE: get arg functions can't use genbuf */
|
/* NOTE: get arg functions can't use genbuf */
|
||||||
while (read_line(f, &genbuf) != EOF) {
|
while (read_line(f, &genbuf) != EOF) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user