]> Sergey Matveev's repositories - nnn.git/commitdiff
Code reformat
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 17 Jan 2019 16:01:30 +0000 (21:31 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 17 Jan 2019 16:28:07 +0000 (21:58 +0530)
src/nnn.c

index fd80ab7c27273f8877298096b39f7d190f829054..d29d88f3d103c5635140dd0bdeb940427e86dd4e 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -389,18 +389,18 @@ static char * const utils[] = {
 #define STR_NOHOME_ID 1
 #define STR_INPUT_ID 2
 #define STR_INVBM_KEY 3
-#define STR_COPY_ID 4
-#define STR_DATE_ID 5
-#define STR_UNSAFE 6
+#define STR_DATE_ID 4
+#define STR_UNSAFE 5
+#define STR_TMPFILE 6
 
 static const char messages[][16] = {
        "nftw failed",
        "HOME not set",
        "no traversal",
        "invalid key",
-       "copy not set",
        "%F %T %z",
        "unsafe cmd",
+       "/.nnnXXXXXX",
 };
 
 /* Forward declarations */
@@ -694,15 +694,15 @@ static char *xbasename(char *path)
 /* Writes buflen char(s) from buf to a file */
 static void writecp(const char *buf, const size_t buflen)
 {
+       static FILE *fp;
+
        if (cfg.pickraw)
                return;
 
-       if (!g_cppath[0]) {
-               printmsg(messages[STR_COPY_ID]);
+       if (!g_cppath[0])
                return;
-       }
 
-       FILE *fp = fopen(g_cppath, "w");
+       fp = fopen(g_cppath, "w");
 
        if (fp) {
                fwrite(buf, 1, buflen, fp);
@@ -767,7 +767,7 @@ static bool showcplist()
                return FALSE;
 
        if (g_tmpfpath[0])
-               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
        else {
                printmsg(messages[STR_NOHOME_ID]);
                return -1;
@@ -904,13 +904,13 @@ static bool quote_run_sh_cmd(const char *cmd, const char *arg, const char *path)
 
        if (arg) {
                if (r >= CMD_LEN_MAX - 4) { /* space for at least 4 chars - space'c' */
-                       printmsg(messages[6]);
+                       printmsg(messages[STR_UNSAFE]);
                        return FALSE;
                }
 
                for (ptr = arg; *ptr; ++ptr)
                        if (*ptr == '\'') {
-                               printmsg(messages[6]);
+                               printmsg(messages[STR_UNSAFE]);
                                return FALSE;
                        }
 
@@ -918,7 +918,7 @@ static bool quote_run_sh_cmd(const char *cmd, const char *arg, const char *path)
                g_buf[r] = '\'';
                r += xstrlcpy(g_buf + r + 1, arg, CMD_LEN_MAX - 1 - r);
                if (r >= CMD_LEN_MAX - 1) {
-                       printmsg(messages[6]);
+                       printmsg(messages[STR_UNSAFE]);
                        return FALSE;
                }
 
@@ -1929,7 +1929,7 @@ static bool show_stats(char *fpath, char *fname, struct stat *sb)
        char *p, *begin = g_buf;
 
        if (g_tmpfpath[0])
-               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
        else {
                printmsg(messages[STR_NOHOME_ID]);
                return FALSE;
@@ -2080,7 +2080,7 @@ static bool handle_archive(char *fpath, char *arg, char *dir)
 static bool show_help(char *path)
 {
        if (g_tmpfpath[0])
-               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+               xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
        else {
                printmsg(messages[STR_NOHOME_ID]);
                return FALSE;
@@ -3450,6 +3450,7 @@ nochange:
                                }
 
                                mkpath(path, dents[cur].name, newpath, PATH_MAX);
+                               DPRINTF_S(newpath);
                                spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
                                break;
                        case SEL_SHELL: