mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Remove redundant assignments
This commit is contained in:
parent
49e36a4707
commit
33f2a2f37b
42
src/nnn.c
42
src/nnn.c
|
@ -670,7 +670,6 @@ static haiku_nm_h haiku_hnd;
|
||||||
/* A faster version of xisdigit */
|
/* A faster version of xisdigit */
|
||||||
#define xisdigit(c) ((unsigned int) (c) - '0' <= 9)
|
#define xisdigit(c) ((unsigned int) (c) - '0' <= 9)
|
||||||
#define xerror() perror(xitoa(__LINE__))
|
#define xerror() perror(xitoa(__LINE__))
|
||||||
#define xconfirm(c) ((c) == 'y' || (c) == 'Y')
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
#define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
||||||
|
@ -812,6 +811,11 @@ static void printinfoln(const char *str)
|
||||||
mvaddstr(xlines - 2, xcols - strlen(str), str);
|
mvaddstr(xlines - 2, xcols - strlen(str), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool xconfirm(int c)
|
||||||
|
{
|
||||||
|
return (c == 'y' || c == 'Y');
|
||||||
|
}
|
||||||
|
|
||||||
static int get_input(const char *prompt)
|
static int get_input(const char *prompt)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -861,13 +865,11 @@ static void xdelay(useconds_t delay)
|
||||||
static char confirm_force(bool selection)
|
static char confirm_force(bool selection)
|
||||||
{
|
{
|
||||||
char str[32];
|
char str[32];
|
||||||
int r;
|
|
||||||
|
|
||||||
snprintf(str, 32, messages[MSG_FORCE_RM],
|
snprintf(str, 32, messages[MSG_FORCE_RM],
|
||||||
(selection ? xitoa(nselected) : "current"), (selection ? "(s)" : ""));
|
(selection ? xitoa(nselected) : "current"), (selection ? "(s)" : ""));
|
||||||
r = get_input(str);
|
|
||||||
|
|
||||||
if (xconfirm(r))
|
if (xconfirm(get_input(str)))
|
||||||
return 'f'; /* forceful */
|
return 'f'; /* forceful */
|
||||||
return 'i'; /* interactive */
|
return 'i'; /* interactive */
|
||||||
}
|
}
|
||||||
|
@ -1444,13 +1446,12 @@ static bool selsafe(void)
|
||||||
|
|
||||||
static void export_file_list(void)
|
static void export_file_list(void)
|
||||||
{
|
{
|
||||||
int fd, r = 0;
|
|
||||||
struct entry *pdent = dents;
|
|
||||||
|
|
||||||
if (!ndents)
|
if (!ndents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fd = create_tmp_file();
|
struct entry *pdent = dents;
|
||||||
|
int r = 0, fd = create_tmp_file();
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
DPRINTF_S(strerror(errno));
|
DPRINTF_S(strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
@ -1470,8 +1471,7 @@ static void export_file_list(void)
|
||||||
|
|
||||||
spawn(editor, g_tmpfpath, NULL, NULL, F_CLI);
|
spawn(editor, g_tmpfpath, NULL, NULL, F_CLI);
|
||||||
|
|
||||||
r = get_input(messages[MSG_RM_TMP]);
|
if (xconfirm(get_input(messages[MSG_RM_TMP])))
|
||||||
if (xconfirm(r))
|
|
||||||
unlink(g_tmpfpath);
|
unlink(g_tmpfpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3993,9 +3993,7 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
|
||||||
#else
|
#else
|
||||||
if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) {
|
if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) {
|
||||||
#endif
|
#endif
|
||||||
int r = get_input(messages[MSG_LAZY]);
|
if (!xconfirm(get_input(messages[MSG_LAZY])))
|
||||||
|
|
||||||
if (!xconfirm(r))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -4197,10 +4195,9 @@ static bool run_cmd_as_plugin(const char *path, const char *file, char *newpath,
|
||||||
--len;
|
--len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_suffix(newpath, " $nnn")) {
|
if (is_suffix(newpath, " $nnn"))
|
||||||
/* Set `\0` to clear ' $nnn' suffix */
|
newpath[len - 5] = '\0'; /* Set `\0` to clear ' $nnn' suffix */
|
||||||
newpath[len - 5] = '\0';
|
else
|
||||||
} else
|
|
||||||
runfile = NULL;
|
runfile = NULL;
|
||||||
|
|
||||||
spawn(newpath, runfile, NULL, path, flags);
|
spawn(newpath, runfile, NULL, path, flags);
|
||||||
|
@ -4689,7 +4686,7 @@ static void handle_screen_move(enum action sel)
|
||||||
|
|
||||||
static int handle_context_switch(enum action sel, char *newpath)
|
static int handle_context_switch(enum action sel, char *newpath)
|
||||||
{
|
{
|
||||||
int r = -1, input;
|
int r = -1;
|
||||||
|
|
||||||
switch (sel) {
|
switch (sel) {
|
||||||
case SEL_CYCLE: // fallthrough
|
case SEL_CYCLE: // fallthrough
|
||||||
|
@ -4715,8 +4712,7 @@ static int handle_context_switch(enum action sel, char *newpath)
|
||||||
|
|
||||||
(r == CTX_MAX - 1) ? (r = 0) : ++r;
|
(r == CTX_MAX - 1) ? (r = 0) : ++r;
|
||||||
snprintf(newpath, PATH_MAX, messages[MSG_CREATE_CTX], r + 1);
|
snprintf(newpath, PATH_MAX, messages[MSG_CREATE_CTX], r + 1);
|
||||||
input = get_input(newpath);
|
if (!xconfirm(get_input(newpath)))
|
||||||
if (!xconfirm(input))
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5937,8 +5933,7 @@ nochange:
|
||||||
|
|
||||||
mkpath(path, tmp, newpath);
|
mkpath(path, tmp, newpath);
|
||||||
if (access(newpath, F_OK) == 0) {
|
if (access(newpath, F_OK) == 0) {
|
||||||
fd = get_input(messages[MSG_OVERWRITE]);
|
if (!xconfirm(get_input(messages[MSG_OVERWRITE]))) {
|
||||||
if (!xconfirm(fd)) {
|
|
||||||
statusbar(path);
|
statusbar(path);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
@ -5995,8 +5990,7 @@ nochange:
|
||||||
if (faccessat(fd, tmp, F_OK, AT_SYMLINK_NOFOLLOW) != -1) {
|
if (faccessat(fd, tmp, F_OK, AT_SYMLINK_NOFOLLOW) != -1) {
|
||||||
if (sel == SEL_RENAME) {
|
if (sel == SEL_RENAME) {
|
||||||
/* Overwrite file with same name? */
|
/* Overwrite file with same name? */
|
||||||
r = get_input(messages[MSG_OVERWRITE]);
|
if (!xconfirm(get_input(messages[MSG_OVERWRITE]))) {
|
||||||
if (!xconfirm(r)) {
|
|
||||||
close(fd);
|
close(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue