+2015-12-30 Benno Schulenberg <bensberg@justemail.net>
+ * src/nano.c (main), src/files.c (open_buffer): Don't try to position
+ the cursor when opening a buffer failed (because the user specified a
+ directory, for example). This fixes Savannah bug #46778.
+
2015-12-29 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/{c,objc,asm}.nanorc: Disable the regex for multiline
strings as it colours some things wrong and is a glutton on time.
/* If it's not "", filename is a file to open. We make a new buffer, if
* necessary, and then open and read the file, if applicable. */
-void open_buffer(const char *filename, bool undoable)
+bool open_buffer(const char *filename, bool undoable)
{
bool quiet = FALSE;
bool new_buffer = (openfile == NULL
if (check_operating_dir(filename, FALSE)) {
statusbar(_("Can't insert file from outside of %s"),
operating_dir);
- return;
+ return FALSE;
}
#endif
else
statusbar(_("\"%s\" is not a normal file"), filename);
beep();
- return;
+ return FALSE;
}
}
#ifndef DISABLE_MULTIBUFFER
if (openfile->next) {
close_buffer(TRUE);
- return;
+ return FALSE;
}
#endif
} else if (lockstatus == 0) {
if (new_buffer)
color_update();
#endif
+ return TRUE;
}
#ifndef DISABLE_SPELLER
if (i < argc - 1 && argv[i][0] == '+')
parse_line_column(&argv[i][1], &iline, &icol);
else {
- open_buffer(argv[i], FALSE);
+ /* If opening fails, don't try to position the cursor. */
+ if (!open_buffer(argv[i], FALSE))
+ continue;
/* If a position was given on the command line, go there. */
if (iline > 0 || icol > 0) {
/* All functions in files.c. */
void make_new_buffer(void);
void initialize_buffer_text(void);
-void open_buffer(const char *filename, bool undoable);
+bool open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
void replace_buffer(const char *filename);
#endif