nsxivd0b5005
-0 sends NULL separated file-list to key-handler
with this change `-0` is turned into a more generic switch which can be used to send NULL-separated file-list to the key-handler as well. this also means `-0` no longer implicitly enables `-o`
+7 −8
5 files changed
- M commands.c +1 −1
- M main.c +1 −1
- M nsxiv.1 +2 −2
- M nsxiv.h +1 −1
- M options.c +2 −3
| @@ -59,7 +59,7 @@ bool cg_quit(arg_t _) | |||
| 59 | 59 | if (options->to_stdout && markcnt > 0) { | |
| 60 | 60 | for (i = 0; i < filecnt; i++) { | |
| 61 | 61 | if (files[i].flags & FF_MARK) | |
| 62 | − | printf("%s%c", files[i].name, options->stdout_separator); | |
| 62 | + | printf("%s%c", files[i].name, options->using_null ? '\0' : '\n'); | |
| 63 | 63 | } | |
| 64 | 64 | } | |
| 65 | 65 | exit(EXIT_SUCCESS); | |
| @@ -547,7 +547,7 @@ void run_key_handler(const char *key, unsigned int mask) | |||
| 547 | 547 | for (f = i = 0; f < fcnt; i++) { | |
| 548 | 548 | if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) { | |
| 549 | 549 | stat(files[i].path, &oldst[f]); | |
| 550 | − | fprintf(pfs, "%s\n", files[i].name); | |
| 550 | + | fprintf(pfs, "%s%c", files[i].name, options->using_null ? '\0' : '\n'); | |
| 551 | 551 | f++; | |
| 552 | 552 | } | |
| 553 | 553 | } | |
| @@ -127,8 +127,8 @@ The same as `\-z 100'. | |||
| 127 | 127 | Set zoom level to ZOOM percent. | |
| 128 | 128 | .TP | |
| 129 | 129 | .B \-0 | |
| 130 | − | Same as \-o, however the marked files are NULL separated. This option implies | |
| 131 | − | \-o. | |
| 130 | + | Use NULL-separator. With this option output of \-o and file-list sent to the | |
| 131 | + | key-handler will be seperated by a NULL character. | |
| 132 | 132 | .SH KEYBOARD COMMANDS | |
| 133 | 133 | .SS General | |
| 134 | 134 | The following keyboard commands are available in both image and thumbnail mode: | |
| @@ -256,7 +256,7 @@ struct opt { | |||
| 256 | 256 | char **filenames; | |
| 257 | 257 | bool from_stdin; | |
| 258 | 258 | bool to_stdout; | |
| 259 | − | char stdout_separator; | |
| 259 | + | bool using_null; | |
| 260 | 260 | bool recursive; | |
| 261 | 261 | int filecnt; | |
| 262 | 262 | int startnum; | |
| @@ -52,7 +52,7 @@ void parse_options(int argc, char **argv) | |||
| 52 | 52 | ||
| 53 | 53 | _options.from_stdin = false; | |
| 54 | 54 | _options.to_stdout = false; | |
| 55 | − | _options.stdout_separator = '\n'; | |
| 55 | + | _options.using_null = false; | |
| 56 | 56 | _options.recursive = false; | |
| 57 | 57 | _options.startnum = 0; | |
| 58 | 58 | ||
| @@ -181,8 +181,7 @@ void parse_options(int argc, char **argv) | |||
| 181 | 181 | _options.zoom = (float) n / 100.0; | |
| 182 | 182 | break; | |
| 183 | 183 | case '0': | |
| 184 | − | _options.stdout_separator = '\0'; | |
| 185 | − | _options.to_stdout = true; /* -0 implies -o */ | |
| 184 | + | _options.using_null = true; | |
| 186 | 185 | break; | |
| 187 | 186 | } | |
| 188 | 187 | } | |