diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2019-10-02 22:34:11 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2019-10-02 22:34:11 +0530 |
commit | 67c33a5e804ee53d2e374c348626ab4708ecc34e (patch) | |
tree | 8ed050f7dfc962da01b1bb5a4a6a5d0d7667944c /src | |
parent | 757a783d497c709a076f21ca9ed2258dfce81a21 (diff) | |
download | nnn-67c33a5e804ee53d2e374c348626ab4708ecc34e.tar.gz |
Code refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/nnn.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -391,8 +391,8 @@ static const char * const messages[] = { "invalid key", "%F %T %z", "/.nnnXXXXXX", - "empty selection", - "utility missing", + "0 selected", + "missing dep", }; /* Supported configuration environment variables */ @@ -775,7 +775,12 @@ static char *xbasename(char *path) static int create_tmp_file() { xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], TMP_LEN_MAX - g_tmpfplen); - return mkstemp(g_tmpfpath); + + int fd = mkstemp(g_tmpfpath); + if (fd == -1) { + DPRINTF_S(strerror(errno)); + } + return fd; } /* Writes buflen char(s) from buf to a file */ @@ -854,10 +859,8 @@ static bool listselbuf(void) return FALSE; fd = create_tmp_file(); - if (fd == -1) { - DPRINTF_S("mkstemp failed!"); + if (fd == -1) return FALSE; - } pos = seltofile(fd, NULL); @@ -2849,7 +2852,7 @@ static void printkv(kv *kvarr, int fd, uchar max) * the binary size by around a hundred bytes. This would only * have increased as we keep adding new options. */ -static bool show_help(const char *path) +static void show_help(const char *path) { int i, fd; const char *start, *end; @@ -2889,7 +2892,7 @@ static bool show_help(const char *path) fd = create_tmp_file(); if (fd == -1) - return FALSE; + return; start = end = helpstr; while (*end) { @@ -2931,7 +2934,6 @@ static bool show_help(const char *path) spawn(pager, g_tmpfpath, NULL, NULL, F_CLI); unlink(g_tmpfpath); - return TRUE; } static int sum_bsizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) @@ -4015,7 +4017,6 @@ nochange: { if (ndents) mkpath(path, dents[cur].name, newpath); - r = TRUE; switch (sel) { case SEL_ARCHIVELS: @@ -4037,7 +4038,7 @@ nochange: } break; case SEL_HELP: - r = show_help(path); + show_help(path); break; case SEL_RUNEDIT: spawn(editor, dents[cur].name, NULL, path, F_CLI); @@ -4050,11 +4051,6 @@ nochange: break; } - if (!r) { - printwait(messages[UTIL_MISSING], &presel); - goto nochange; - } - /* In case of successful operation, reload contents */ /* Continue in navigate-as-you-type mode, if enabled */ @@ -4617,9 +4613,9 @@ static void usage(void) " -H show hidden files\n" " -i nav-as-you-type mode\n" " -n version sort\n" - " -o press Enter to open files\n" - " -p file selection file (stdout if '-')\n" - " -r show cp, mv progress on Linux\n" + " -o open files on Enter\n" + " -p file selection file [stdout if '-']\n" + " -r use advcpmv patched cp, mv\n" " -s string filters [default: regex]\n" " -S du mode\n" " -t disable dir auto-select\n" |