]> Sergey Matveev's repositories - nnn.git/commitdiff
browse: fix nnn -e (#549)
authorDanh Doan <congdanhqx@gmail.com>
Sun, 3 May 2020 04:26:16 +0000 (04:26 +0000)
committerGitHub <noreply@github.com>
Sun, 3 May 2020 04:26:16 +0000 (09:56 +0530)
The current code will start editor if the mime doesn't start with
"text/". But, we want the opposite.

Simplify the check by using `strncmp` instead.

We may improve by writing a helper: `start_withs` in the future.

This change also cleans -Wstrict-aliasing on Ubuntu 16.04 LTS

src/nnn.c

index 656bc20e104b2092f1fd3e94fa41543205328bdc..59dacd2e1a2c4ad7b28761d64fb8e0a80572b04a 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5404,7 +5404,7 @@ nochange:
                                if (cfg.useeditor && (!sb.st_size ||
 #ifdef FILE_MIME_OPTS
                                    (get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
-                                   && !(((int *)g_buf)[0] == *(int *)"text" && g_buf[4] == '/')))) {
+                                   && !strncmp(g_buf, "text/", 5)))) {
 #else
                                    /* no mime option; guess from description instead */
                                    (get_output(g_buf, CMD_LEN_MAX, "file", "-b", newpath, FALSE)