- Make goal a ssize_t instead of an int, since fill is now a
ssize_t, and the position at which a line is broken can be
greater than COLS. (DLR)
+ main()
+ - Tweak the command line parsing routine so that multiple +LINE
+ flags are properly interpreted in multibuffer mode. (DLR)
- nano.h:
- Add WIDTH_OF_TAB #define, containing the default width of a
tab. (DLR)
if (tabsize == -1)
tabsize = WIDTH_OF_TAB;
- /* If there's a +LINE flag, it is the first non-option argument. */
- if (0 < optind && optind < argc && argv[optind][0] == '+') {
- startline = atoi(&argv[optind][1]);
- optind++;
- }
-
/* Back up the old terminal settings so that they can be restored. */
tcgetattr(0, &oldterm);
fprintf(stderr, "Main: open file\n");
#endif
+ /* If there's a +LINE flag here, it is the first non-option
+ * argument, and it is followed by at least one other argument, the
+ * filename it applies to. */
+ if (0 < optind && optind < argc - 1 && argv[optind][0] == '+') {
+ startline = atoi(&argv[optind][1]);
+ optind++;
+ }
+
#ifdef ENABLE_MULTIBUFFER
old_multibuffer = ISSET(MULTIBUFFER);
SET(MULTIBUFFER);
/* Read all the files after the first one on the command line into
* new buffers. */
{
- int i;
- for (i = optind + 1; i < argc; i++)
- load_buffer(argv[i]);
+ int i = optind + 1, iline = 0;
+ for (; i < argc; i++) {
+ /* If there's a +LINE flag here, it is followed by at least
+ * one other argument, the filename it applies to. */
+ if (i < argc - 1 && argv[i][0] == '+' && iline == 0) {
+ iline = atoi(&argv[i][1]);
+ } else {
+ load_buffer(argv[i]);
+ if (iline > 0) {
+ do_gotoline(iline, FALSE);
+ iline = 0;
+ }
+ }
+ }
}
#endif