Browse Source

Remove redundant param

master
Arun Prakash Jana 4 years ago
parent
commit
f8d2be504a
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 26 additions and 31 deletions
  1. +26
    -31
      src/nnn.c

+ 26
- 31
src/nnn.c View File

@@ -701,7 +701,7 @@ static void move_cursor(int target, int ignore_scrolloff);
static inline bool getutil(char *util); static inline bool getutil(char *util);
static size_t mkpath(const char *dir, const char *name, char *out); static size_t mkpath(const char *dir, const char *name, char *out);
static char *xgetenv(const char *name, char *fallback); static char *xgetenv(const char *name, char *fallback);
static bool plugscript(const char *plugin, char *newpath, const char *path, uchar flags);
static bool plugscript(const char *plugin, const char *path, uchar flags);


/* Functions */ /* Functions */


@@ -4183,7 +4183,7 @@ static void show_help(const char *path)
unlink(g_tmpfpath); unlink(g_tmpfpath);
} }


static bool run_cmd_as_plugin(const char *path, const char *file, char *newpath, char *runfile)
static bool run_cmd_as_plugin(const char *path, const char *file, char *runfile)
{ {
uchar flags = F_CLI | F_CONFIRM; uchar flags = F_CLI | F_CONFIRM;
size_t len; size_t len;
@@ -4203,21 +4203,21 @@ static bool run_cmd_as_plugin(const char *path, const char *file, char *newpath,
return FALSE; return FALSE;
} }


xstrlcpy(newpath, file, PATH_MAX);
xstrlcpy(g_buf, file, PATH_MAX);


len = strlen(newpath);
if (len > 1 && newpath[len - 1] == '*') {
len = strlen(g_buf);
if (len > 1 && g_buf[len - 1] == '*') {
flags &= ~F_CONFIRM; /* Skip user confirmation */ flags &= ~F_CONFIRM; /* Skip user confirmation */
newpath[len - 1] = '\0'; /* Get rid of trailing no confirmation symbol */
g_buf[len - 1] = '\0'; /* Get rid of trailing no confirmation symbol */
--len; --len;
} }


if (is_suffix(newpath, " $nnn"))
newpath[len - 5] = '\0'; /* Set `\0` to clear ' $nnn' suffix */
if (is_suffix(g_buf, " $nnn"))
g_buf[len - 5] = '\0'; /* Set `\0` to clear ' $nnn' suffix */
else else
runfile = NULL; runfile = NULL;


spawn(newpath, runfile, NULL, path, flags);
spawn(g_buf, runfile, NULL, path, flags);
return TRUE; return TRUE;
} }


@@ -4236,13 +4236,13 @@ static bool plctrl_init(void)
return _SUCCESS; return _SUCCESS;
} }


static bool run_selected_plugin(char **path, const char *file, char *newpath, char *runfile, char **lastname, char **lastdir)
static bool run_selected_plugin(char **path, const char *file, char *runfile, char **lastname, char **lastdir)
{ {
int fd; int fd;
size_t len; size_t len;


if (*file == '_') if (*file == '_')
return run_cmd_as_plugin(*path, file, newpath, runfile);
return run_cmd_as_plugin(*path, file, runfile);


if (!(g_states & STATE_PLUGIN_INIT)) { if (!(g_states & STATE_PLUGIN_INIT)) {
plctrl_init(); plctrl_init();
@@ -4254,13 +4254,13 @@ static bool run_selected_plugin(char **path, const char *file, char *newpath, ch
return FALSE; return FALSE;


/* Generate absolute path to plugin */ /* Generate absolute path to plugin */
mkpath(plugindir, file, newpath);
mkpath(plugindir, file, g_buf);


if (runfile && runfile[0]) { if (runfile && runfile[0]) {
xstrlcpy(*lastname, runfile, NAME_MAX); xstrlcpy(*lastname, runfile, NAME_MAX);
spawn(newpath, *lastname, *path, *path, F_NORMAL);
spawn(g_buf, *lastname, *path, *path, F_NORMAL);
} else } else
spawn(newpath, NULL, *path, *path, F_NORMAL);
spawn(g_buf, NULL, *path, *path, F_NORMAL);


len = read(fd, g_buf, PATH_MAX); len = read(fd, g_buf, PATH_MAX);
g_buf[len] = '\0'; g_buf[len] = '\0';
@@ -4287,11 +4287,11 @@ static bool run_selected_plugin(char **path, const char *file, char *newpath, ch
return TRUE; return TRUE;
} }


static bool plugscript(const char *plugin, char *newpath, const char *path, uchar flags)
static bool plugscript(const char *plugin, const char *path, uchar flags)
{ {
mkpath(plugindir, plugin, newpath);
if (!access(newpath, X_OK)) {
spawn(newpath, NULL, NULL, path, flags);
mkpath(plugindir, plugin, g_buf);
if (!access(g_buf, X_OK)) {
spawn(g_buf, NULL, NULL, path, flags);
return TRUE; return TRUE;
} }


@@ -5417,8 +5417,7 @@ nochange:
rundir[0] = '\0'; rundir[0] = '\0';


if (!run_selected_plugin(&path, dents[cur].name, if (!run_selected_plugin(&path, dents[cur].name,
newpath, runfile, &lastname,
&lastdir)) {
runfile, &lastname, &lastdir)) {
DPRINTF_S("plugin failed!"); DPRINTF_S("plugin failed!");
} }


@@ -5706,7 +5705,7 @@ nochange:
endselection(); endselection();


if (!(getutil(utils[UTIL_BASH]) if (!(getutil(utils[UTIL_BASH])
&& plugscript(utils[UTIL_NMV], newpath, path, F_CLI))
&& plugscript(utils[UTIL_NMV], path, F_CLI))
#ifndef NOBATCH #ifndef NOBATCH
&& !batch_rename(path)) { && !batch_rename(path)) {
#else #else
@@ -5772,7 +5771,7 @@ nochange:
} }


if (cfg.x11) if (cfg.x11)
plugscript(utils[UTIL_CBCP], newpath, NULL, F_NOWAIT | F_NOTRACE);
plugscript(utils[UTIL_CBCP], NULL, F_NOWAIT | F_NOTRACE);


if (!nselected) if (!nselected)
unlink(selpath); unlink(selpath);
@@ -5848,7 +5847,7 @@ nochange:


writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */ writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
if (cfg.x11) if (cfg.x11)
plugscript(utils[UTIL_CBCP], newpath, NULL, F_NOWAIT | F_NOTRACE);
plugscript(utils[UTIL_CBCP], NULL, F_NOWAIT | F_NOTRACE);
continue; continue;
case SEL_SELEDIT: case SEL_SELEDIT:
r = editselection(); r = editselection();
@@ -5857,7 +5856,7 @@ nochange:
printwait(messages[r], &presel); printwait(messages[r], &presel);
} else { } else {
if (cfg.x11) if (cfg.x11)
plugscript(utils[UTIL_CBCP], newpath, NULL, F_NOWAIT | F_NOTRACE);
plugscript(utils[UTIL_CBCP], NULL, F_NOWAIT | F_NOTRACE);
cfg.filtermode ? presel = FILTER : statusbar(path); cfg.filtermode ? presel = FILTER : statusbar(path);
} }
goto nochange; goto nochange;
@@ -5911,11 +5910,8 @@ nochange:
clearfilter(); clearfilter();


/* Show notification on operation complete */ /* Show notification on operation complete */
if (cfg.x11) {
/* rundir is used as tmp var, note that we MUST clear it again */
plugscript(utils[UTIL_NTFY], rundir, NULL, F_NOWAIT | F_NOTRACE);
rundir[0] = '\0';
}
if (cfg.x11)
plugscript(utils[UTIL_NTFY], NULL, F_NOWAIT | F_NOTRACE);


if (newpath[0] && !access(newpath, F_OK)) if (newpath[0] && !access(newpath, F_OK))
xstrlcpy(lastname, xbasename(newpath), NAME_MAX+1); xstrlcpy(lastname, xbasename(newpath), NAME_MAX+1);
@@ -6140,8 +6136,7 @@ nochange:
} else } else
r = TRUE; r = TRUE;


if (!run_selected_plugin(&path, tmp, newpath,
(ndents ? dents[cur].name : NULL),
if (!run_selected_plugin(&path, tmp, (ndents ? dents[cur].name : NULL),
&lastname, &lastdir)) { &lastname, &lastdir)) {
printwait(messages[MSG_FAILED], &presel); printwait(messages[MSG_FAILED], &presel);
goto nochange; goto nochange;


Loading…
Cancel
Save