sed: Print better error message when open fails
This commit is contained in:
parent
2ee4c13433
commit
9a17de569a
15
sed.c
15
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");
|
||||||
|
|
||||||
f = isfile ? fopen(s, "r") : fmemopen(s, strlen(s), "r");
|
|
||||||
if (!f)
|
if (!f)
|
||||||
eprintf("fopen/fmemopen:");
|
eprintf("fopen %s:", s);
|
||||||
|
} else {
|
||||||
|
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