Commit 4dd9aadf authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

startup: allow positioning the cursor also when reading standard input

A recent change (8dffb00f) removed this ability.  This change restores
it, and also allows reading from standard input multiple times -- maybe
not useful, but it works.
parent 5ecd81bd
Showing with 7 additions and 9 deletions
+7 -9
...@@ -2519,18 +2519,12 @@ int main(int argc, char **argv) ...@@ -2519,18 +2519,12 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: open file\n"); fprintf(stderr, "Main: open file\n");
#endif #endif
/* If one of the arguments is a dash, read text from standard input. */
if (optind < argc && !strcmp(argv[optind], "-")) {
stdin_pager();
optind++;
}
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
is_multibuffer = ISSET(MULTIBUFFER); is_multibuffer = ISSET(MULTIBUFFER);
SET(MULTIBUFFER); SET(MULTIBUFFER);
#endif #endif
/* Read the named files on the command line into new buffers. */ /* Read the files mentioned on the command line into new buffers. */
while (optind < argc && (!openfile || ISSET(MULTIBUFFER))) { while (optind < argc && (!openfile || ISSET(MULTIBUFFER))) {
ssize_t givenline = 0, givencol = 0; ssize_t givenline = 0, givencol = 0;
...@@ -2540,8 +2534,12 @@ int main(int argc, char **argv) ...@@ -2540,8 +2534,12 @@ int main(int argc, char **argv)
statusline(ALERT, _("Invalid line or column number")); statusline(ALERT, _("Invalid line or column number"));
} }
/* If opening fails, don't try to position the cursor. */ /* If the filename is a dash, read from standard input. Otherwise,
if (!open_buffer(argv[optind++], FALSE)) * open the file, but skip positioning the cursor if it failed. */
if (strcmp(argv[optind], "-") == 0) {
stdin_pager();
optind++;
} else if (!open_buffer(argv[optind++], FALSE))
continue; continue;
/* If a position was given on the command line, go there. */ /* If a position was given on the command line, go there. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment