#ifdef KEY_RESIZE
/* Clear the old prompt */
-static inline void clearoldprompt(void)
+static void clearoldprompt(void)
{
tolastln();
clrtoeol();
#endif
/* Messages show up at the bottom */
-static inline void printmsg(const char *msg)
+static void printmsg(const char *msg)
{
tolastln();
addstr(msg);
}
/* Finish selection procedure before an operation */
-static inline void endselection()
+static void endselection()
{
if (cfg.selmode)
cfg.selmode = 0;
return NULL;
}
-static inline void resetdircolor(int flags)
+static void resetdircolor(int flags)
{
if (cfg.dircolor && !(flags & DIR_OR_LINK_TO_DIR)) {
attroff(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
exit:
/* Should never be null */
- if (closedir(dirp) == -1) {
- dentfree();
+ if (closedir(dirp) == -1)
errexit();
- }
return n;
}
curscroll = MAX(curscroll, MAX(cur - (onscreen - 1), 0));
}
-static inline void handle_screen_move(enum action sel)
+static void handle_screen_move(enum action sel)
{
int onscreen;
static void browse(char *ipath, const char *session)
{
char newpath[PATH_MAX] __attribute__ ((aligned));
- char mark[PATH_MAX] __attribute__ ((aligned));
char rundir[PATH_MAX] __attribute__ ((aligned));
char runfile[NAME_MAX + 1] __attribute__ ((aligned));
- char *path, *lastdir, *lastname, *dir, *tmp;
+ char *path, *lastdir, *lastname, *dir, *tmp, *mark = NULL;
ino_t inode = 0;
enum action sel;
struct stat sb;
g_ctx[0].c_cfg = cfg; /* current configuration */
}
- newpath[0] = rundir[0] = runfile[0] = mark[0] = '\0';
+ newpath[0] = rundir[0] = runfile[0] = '\0';
presel = cfg.filtermode ? FILTER : 0;
redraw(path);
nochange:
/* Exit if parent has exited */
- if (getppid() == 1)
+ if (getppid() == 1) {
+ free(mark);
_exit(0);
+ }
/* If CWD is deleted or moved or perms changed, find an accessible parent */
if (access(path, F_OK)) {
}
/* If STDIN is no longer a tty (closed) we should exit */
- if (!isatty(STDIN_FILENO) && !cfg.picker)
+ if (!isatty(STDIN_FILENO) && !cfg.picker) {
+ free(mark);
return;
+ }
sel = nextsel(presel);
if (presel)
if (cfg.picker && sel == SEL_GOIN) {
appendfpath(newpath, mkpath(path, dents[cur].name, newpath));
writesel(pselbuf, selbufpos - 1);
+ free(mark);
return;
}
case SEL_CDROOT:
dir = "/";
break;
- default: /* case SEL_VISIT */
+ default: /* SEL_VISIT */
dir = mark;
break;
}
- if (dir[0] == '\0') {
+ if (!dir || !*dir) {
printwait(messages[MSG_NOT_SET], &presel);
goto nochange;
}
case '`': // fallthrough
case '-': // fallthrough
case '@':
+ case '.':
presel = fd;
goto nochange;
- case '.':
- cfg.showhidden ^= 1;
- setdirwatch();
- if (ndents)
- copycurname();
- goto begin;
}
if (!get_kv_val(bookmark, newpath, fd, BM_MAX, TRUE)) {
setdirwatch();
goto begin;
case SEL_PIN:
- xstrlcpy(mark, path, PATH_MAX);
+ free(mark);
+ mark = strdup(path);
printwait(mark, &presel);
goto nochange;
case SEL_FLTR:
/* Picker mode: reset buffer or clear file */
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE"))
cfg.picker ? selbufpos = 0 : write_lastdir(path);
+ free(mark);
return;
default:
if (xlines != LINES || xcols != COLS)