nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] do not write to stderr on magic errors


From: Mike Frysinger
Subject: [Nano-devel] [PATCH] do not write to stderr on magic errors
Date: Fri, 4 Jan 2013 14:33:01 -0500

If the magic db has errors such that magic_load() fails, the current
code dumps to stderr which messes up the ncurses terminal control.

The error message is also vague to the point where it's confusing.
I thought nano had problems writing to the file I was editing.

Instead, use statusbar() and clarify the messages.

Signed-off-by: Mike Frysinger <address@hidden>
---
 src/color.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/color.c b/src/color.c
index e5d3348..3ddd9d6 100644
--- a/src/color.c
+++ b/src/color.c
@@ -161,19 +161,19 @@ void color_update(void)
 
 #ifdef HAVE_LIBMAGIC
 
-    if (strcmp(openfile->filename,"") && stat(openfile->filename, &fileinfo) 
== 0) {
+    if (stat(openfile->filename, &fileinfo) == 0) {
        m = magic_open(MAGIC_SYMLINK |
 #ifdef DEBUG
                        MAGIC_DEBUG | MAGIC_CHECK |
 #endif /* DEBUG */
                        MAGIC_ERROR);
        if (m == NULL || magic_load(m, NULL) < 0)
-           fprintf(stderr, "something went wrong: %s [%s]\n", strerror(errno), 
openfile->filename);
+           statusbar("magic_load() failed: %s", strerror(errno));
        else {
            magicstring = magic_file(m,openfile->filename);
            if (magicstring == NULL) {
                magicerr = magic_error(m);
-               fprintf(stderr, "something went wrong: %s [%s]\n", magicerr, 
openfile->filename);
+               statusbar("magic_file(%s) failed: %s", openfile->filename, 
magicerr);
             }
 #ifdef DEBUG
            fprintf(stderr, "magic string returned: %s\n", magicstring);
-- 
1.8.0.2




reply via email to

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