Not trying to position the cursor when opening a buffer failed.

This fixes Savannah bug #46778.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5514 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-12-30 10:11:20 +00:00
parent ae598e79a6
commit 37d8ad8687
4 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
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.

View File

@ -323,7 +323,7 @@ int do_lockfile(const char *filename)
/* 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
@ -343,7 +343,7 @@ void open_buffer(const char *filename, bool undoable)
if (check_operating_dir(filename, FALSE)) {
statusbar(_("Can't insert file from outside of %s"),
operating_dir);
return;
return FALSE;
}
#endif
@ -358,7 +358,7 @@ void open_buffer(const char *filename, bool undoable)
else
statusbar(_("\"%s\" is not a normal file"), filename);
beep();
return;
return FALSE;
}
}
@ -374,7 +374,7 @@ void open_buffer(const char *filename, bool undoable)
#ifndef DISABLE_MULTIBUFFER
if (openfile->next) {
close_buffer(TRUE);
return;
return FALSE;
}
#endif
} else if (lockstatus == 0) {
@ -421,6 +421,7 @@ void open_buffer(const char *filename, bool undoable)
if (new_buffer)
color_update();
#endif
return TRUE;
}
#ifndef DISABLE_SPELLER

View File

@ -2622,7 +2622,9 @@ int main(int argc, char **argv)
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) {

View File

@ -283,7 +283,7 @@ void do_uncut_text(void);
/* 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