[hackers] [sbase] sed: Print better error message when open fails || Michael Forney

From: <git_AT_suckless.org>
Date: Thu, 13 Jun 2019 22:43:37 +0200 (CEST)

commit 9a17de569a49b376068a210073885c97530a79cd
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Thu Jun 13 13:07:52 2019 -0700
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Thu Jun 13 13:08:16 2019 -0700

    sed: Print better error message when open fails

diff --git a/sed.c b/sed.c
index 532361f..1062ddd 100644
--- a/sed.c
+++ b/sed.c
_AT_@ -370,12 +370,17 @@ compile(char *s, int isfile)
 {
         FILE *f;
 
- if (!isfile && !*s) /* empty string script */
- return;
-
- f = isfile ? fopen(s, "r") : fmemopen(s, strlen(s), "r");
- if (!f)
- eprintf("fopen/fmemopen:");
+ if (isfile) {
+ f = fopen(s, "r");
+ if (!f)
+ 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 */
         while (read_line(f, &genbuf) != EOF) {
Received on Thu Jun 13 2019 - 22:43:37 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 13 2019 - 22:48:24 CEST