aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Danh Doan <congdanhqx@gmail.com>2020-05-03 04:26:16 +0000
committerGravatar GitHub <noreply@github.com>2020-05-03 09:56:16 +0530
commite8e87f6ba2b72a8b7c2eb9a63d8a37a71f148882 (patch)
tree58752b3973f834dcef892440af0584ccb6d8d9e0
parentff568ea748c9103916b1fe32892cbde4a4fc4706 (diff)
downloadnnn-e8e87f6ba2b72a8b7c2eb9a63d8a37a71f148882.tar.gz
browse: fix nnn -e (#549)
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
-rw-r--r--src/nnn.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 656bc20..59dacd2 100644
--- 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)