mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Code reformat
This commit is contained in:
parent
bf6419d6af
commit
aa7f5256c4
29
src/nnn.c
29
src/nnn.c
|
@ -389,18 +389,18 @@ static char * const utils[] = {
|
||||||
#define STR_NOHOME_ID 1
|
#define STR_NOHOME_ID 1
|
||||||
#define STR_INPUT_ID 2
|
#define STR_INPUT_ID 2
|
||||||
#define STR_INVBM_KEY 3
|
#define STR_INVBM_KEY 3
|
||||||
#define STR_COPY_ID 4
|
#define STR_DATE_ID 4
|
||||||
#define STR_DATE_ID 5
|
#define STR_UNSAFE 5
|
||||||
#define STR_UNSAFE 6
|
#define STR_TMPFILE 6
|
||||||
|
|
||||||
static const char messages[][16] = {
|
static const char messages[][16] = {
|
||||||
"nftw failed",
|
"nftw failed",
|
||||||
"HOME not set",
|
"HOME not set",
|
||||||
"no traversal",
|
"no traversal",
|
||||||
"invalid key",
|
"invalid key",
|
||||||
"copy not set",
|
|
||||||
"%F %T %z",
|
"%F %T %z",
|
||||||
"unsafe cmd",
|
"unsafe cmd",
|
||||||
|
"/.nnnXXXXXX",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
|
@ -694,15 +694,15 @@ static char *xbasename(char *path)
|
||||||
/* Writes buflen char(s) from buf to a file */
|
/* Writes buflen char(s) from buf to a file */
|
||||||
static void writecp(const char *buf, const size_t buflen)
|
static void writecp(const char *buf, const size_t buflen)
|
||||||
{
|
{
|
||||||
|
static FILE *fp;
|
||||||
|
|
||||||
if (cfg.pickraw)
|
if (cfg.pickraw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!g_cppath[0]) {
|
if (!g_cppath[0])
|
||||||
printmsg(messages[STR_COPY_ID]);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
FILE *fp = fopen(g_cppath, "w");
|
fp = fopen(g_cppath, "w");
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fwrite(buf, 1, buflen, fp);
|
fwrite(buf, 1, buflen, fp);
|
||||||
|
@ -767,7 +767,7 @@ static bool showcplist()
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (g_tmpfpath[0])
|
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 {
|
else {
|
||||||
printmsg(messages[STR_NOHOME_ID]);
|
printmsg(messages[STR_NOHOME_ID]);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -904,13 +904,13 @@ static bool quote_run_sh_cmd(const char *cmd, const char *arg, const char *path)
|
||||||
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
if (r >= CMD_LEN_MAX - 4) { /* space for at least 4 chars - space'c' */
|
if (r >= CMD_LEN_MAX - 4) { /* space for at least 4 chars - space'c' */
|
||||||
printmsg(messages[6]);
|
printmsg(messages[STR_UNSAFE]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ptr = arg; *ptr; ++ptr)
|
for (ptr = arg; *ptr; ++ptr)
|
||||||
if (*ptr == '\'') {
|
if (*ptr == '\'') {
|
||||||
printmsg(messages[6]);
|
printmsg(messages[STR_UNSAFE]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,7 +918,7 @@ static bool quote_run_sh_cmd(const char *cmd, const char *arg, const char *path)
|
||||||
g_buf[r] = '\'';
|
g_buf[r] = '\'';
|
||||||
r += xstrlcpy(g_buf + r + 1, arg, CMD_LEN_MAX - 1 - r);
|
r += xstrlcpy(g_buf + r + 1, arg, CMD_LEN_MAX - 1 - r);
|
||||||
if (r >= CMD_LEN_MAX - 1) {
|
if (r >= CMD_LEN_MAX - 1) {
|
||||||
printmsg(messages[6]);
|
printmsg(messages[STR_UNSAFE]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1929,7 +1929,7 @@ static bool show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
char *p, *begin = g_buf;
|
char *p, *begin = g_buf;
|
||||||
|
|
||||||
if (g_tmpfpath[0])
|
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 {
|
else {
|
||||||
printmsg(messages[STR_NOHOME_ID]);
|
printmsg(messages[STR_NOHOME_ID]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2080,7 +2080,7 @@ static bool handle_archive(char *fpath, char *arg, char *dir)
|
||||||
static bool show_help(char *path)
|
static bool show_help(char *path)
|
||||||
{
|
{
|
||||||
if (g_tmpfpath[0])
|
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 {
|
else {
|
||||||
printmsg(messages[STR_NOHOME_ID]);
|
printmsg(messages[STR_NOHOME_ID]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -3450,6 +3450,7 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
||||||
|
DPRINTF_S(newpath);
|
||||||
spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
|
spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
|
||||||
break;
|
break;
|
||||||
case SEL_SHELL:
|
case SEL_SHELL:
|
||||||
|
|
Loading…
Reference in a new issue