bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/5] progs/tic.c (open_input): Clarify diagnostic messages.


From: G. Branden Robinson
Subject: [PATCH 3/5] progs/tic.c (open_input): Clarify diagnostic messages.
Date: Wed, 27 Sep 2023 07:29:56 -0500

When failing to open a file, say so.
---
 progs/tic.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/progs/tic.c b/progs/tic.c
index d8052648..6b1d2821 100644
--- a/progs/tic.c
+++ b/progs/tic.c
@@ -459,17 +459,20 @@ open_input(const char *filename, char *alt_file)
     if (!strcmp(filename, "-")) {
        fp = copy_input(stdin, STDIN_NAME, alt_file);
     } else if (stat(filename, &sb) == -1) {
-       fprintf(stderr, "%s: %s %s\n", _nc_progname, filename, strerror(errno));
+       fprintf(stderr, "%s: cannot open '%s': %s\n", _nc_progname,
+               filename, strerror(errno));
        ExitProgram(EXIT_FAILURE);
     } else if ((mode = (sb.st_mode & S_IFMT)) == S_IFDIR
               || (mode != S_IFREG && mode != S_IFCHR && mode != S_IFIFO)) {
-       fprintf(stderr, "%s: %s is not a file\n", _nc_progname, filename);
+       fprintf(stderr, "%s: cannot open '%s'; it is not a file\n",
+               _nc_progname, filename);
        ExitProgram(EXIT_FAILURE);
     } else {
        fp = safe_fopen(filename, "r");
 
        if (fp == NULL) {
-           fprintf(stderr, "%s: Can't open %s\n", _nc_progname, filename);
+           fprintf(stderr, "%s: cannot open '%s': %s\n", _nc_progname,
+                   filename, strerror(errno));
            ExitProgram(EXIT_FAILURE);
        }
        if (mode != S_IFREG) {
@@ -477,7 +480,8 @@ open_input(const char *filename, char *alt_file)
                FILE *fp2 = copy_input(fp, filename, alt_file);
                fp = fp2;
            } else {
-               fprintf(stderr, "%s: %s is not a file\n", _nc_progname, 
filename);
+               fprintf(stderr, "%s: cannot open '%s'; it is not a"
+                       " file\n", _nc_progname, filename);
                ExitProgram(EXIT_FAILURE);
            }
        }
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]