apply -0 to stdin/-i as well
while i was initially against this since it can be done via `xargs -0`. the problem with this approach is that there's a limit to how many args a command can recieve, leading to problem like this [0] when opening large (1k~) amount of images. there's no limit on how big stdin can be, so being able to read a null-separated list from stdin doesn't have this problem. [0]: https://github.com/ranger/ranger/pull/2307#issuecomment-818683515
This commit is contained in:
parent
4a282da692
commit
2df33208d7
14
main.c
14
main.c
|
@ -105,6 +105,14 @@ void cleanup(void)
|
||||||
win_close(&win);
|
win_close(&win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool xgetline(char **lineptr, size_t *n)
|
||||||
|
{
|
||||||
|
ssize_t len = getdelim(lineptr, n, options->using_null ? '\0' : '\n', stdin);
|
||||||
|
if (!options->using_null && len > 0 && (*lineptr)[len-1] == '\n')
|
||||||
|
(*lineptr)[len-1] = '\0';
|
||||||
|
return len > 0;
|
||||||
|
}
|
||||||
|
|
||||||
void check_add_file(char *filename, bool given)
|
void check_add_file(char *filename, bool given)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -853,7 +861,6 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, start;
|
int i, start;
|
||||||
size_t n;
|
size_t n;
|
||||||
ssize_t len;
|
|
||||||
char *filename;
|
char *filename;
|
||||||
const char *homedir, *dsuffix = "";
|
const char *homedir, *dsuffix = "";
|
||||||
struct stat fstats;
|
struct stat fstats;
|
||||||
|
@ -889,11 +896,8 @@ int main(int argc, char *argv[])
|
||||||
if (options->from_stdin) {
|
if (options->from_stdin) {
|
||||||
n = 0;
|
n = 0;
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
while ((len = getline(&filename, &n, stdin)) > 0) {
|
while (xgetline(&filename, &n))
|
||||||
if (filename[len-1] == '\n')
|
|
||||||
filename[len-1] = '\0';
|
|
||||||
check_add_file(filename, true);
|
check_add_file(filename, true);
|
||||||
}
|
|
||||||
free(filename);
|
free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
nsxiv.1
2
nsxiv.1
|
@ -128,7 +128,7 @@ Set zoom level to ZOOM percent.
|
||||||
.TP
|
.TP
|
||||||
.B \-0
|
.B \-0
|
||||||
Use NULL-separator. With this option output of \-o and file-list sent to the
|
Use NULL-separator. With this option output of \-o and file-list sent to the
|
||||||
key-handler will be seperated by a NULL character.
|
key-handler and the input of \-i will be seperated by a NULL character.
|
||||||
.SH KEYBOARD COMMANDS
|
.SH KEYBOARD COMMANDS
|
||||||
.SS General
|
.SS General
|
||||||
The following keyboard commands are available in both image and thumbnail mode:
|
The following keyboard commands are available in both image and thumbnail mode:
|
||||||
|
|
Loading…
Reference in a new issue