}
/* Write selected file paths to fd, linefeed separated */
-static size_t seltofile(int fd, uint *pcount, bool tgt)
+static size_t seltofile(int fd, uint *pcount)
{
uint lastpos, count = 0;
char *pbuf = pselbuf;
size_t pos = 0;
- ssize_t len, prefixlen, initlen;
+ ssize_t len, prefixlen = 0, initlen = 0;
if (pcount)
*pcount = 0;
lastpos = selbufpos - 1;
- if (tgt) {
+ if (listpath) {
prefixlen = (ssize_t)xstrlen(prefixpath);
initlen = (ssize_t)xstrlen(initpath);
}
DPRINTF_S(pbuf);
len = (ssize_t)xstrlen(pbuf);
- if (!tgt || (strncmp(initpath, pbuf, initlen) != 0)) {
+ if (!listpath || strncmp(initpath, pbuf, initlen) != 0) {
if (write(fd, pbuf, len) != len)
return pos;
} else {
return;
}
- seltofile(fd, NULL, FALSE);
+ seltofile(fd, NULL);
if (close(fd)) {
DPRINTF_S(strerror(errno));
printwarn(NULL);
return -1;
}
- seltofile(fd, NULL, FALSE);
+ seltofile(fd, NULL);
if (close(fd)) {
DPRINTF_S(strerror(errno));
return -1;
if (!count)
goto finish;
} else
- seltofile(fd, &count, FALSE);
+ seltofile(fd, &count);
close(fd);
for (i = 0; i < ndents; ++i)
appendfpath(dents[i].name, NAME_MAX);
- seltofile(fd1, &count, FALSE);
- seltofile(fd2, NULL, FALSE);
+ seltofile(fd1, &count);
+ seltofile(fd2, NULL);
close(fd2);
if (dir) /* Don't retain dir entries in selection */
{
char *arg = NULL;
char *session = NULL;
- int opt, sort = 0;
+ int fd, opt, sort = 0;
#ifndef NOMOUSE
mmask_t mask;
char *middle_click_env = xgetenv(env_cfg[NNN_MCLICK], "\0");
break;
cfg.picker = 1;
- if (optarg[0] == '-' && optarg[1] == '\0') {
+ if (optarg[0] == '-' && optarg[1] == '\0')
cfg.pickraw = 1;
- if (!isatty(STDOUT_FILENO)) {
- fprintf(stderr, "stdout !tty\n");
- return _FAILURE;
- }
- } else {
- int fd = open(optarg, O_WRONLY | O_CREAT, 0600);
-
+ else {
+ fd = open(optarg, O_WRONLY | O_CREAT, 0600);
if (fd == -1) {
xerror();
return _FAILURE;
if (cfg.pickraw || cfg.picker) {
if (selbufpos) {
- int fd = cfg.pickraw ? 1 : open(selpath, O_WRONLY | O_CREAT, 0600);
-
- if ((fd == -1) || (seltofile(fd, NULL, TRUE) != (size_t)(selbufpos)))
+ fd = cfg.pickraw ? 1 : open(selpath, O_WRONLY | O_CREAT, 0600);
+ if ((fd == -1) || (seltofile(fd, NULL) != (size_t)(selbufpos)))
xerror();
if (fd > 1)