2015-01-13 Chris Allegretta <chrisa@asty.org>

* src/files.c (open_buffer): Check here for locking and properly
        handle choosing to not open a file when locked instead of in
        open_file().  Fixes Savannah bug 42373 reported by Benno Schulenberg



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5104 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2015-01-14 02:36:30 +00:00
parent 69429ce274
commit 6948d2e779
2 changed files with 22 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2015-01-13 Chris Allegretta <chrisa@asty.org>
* src/files.c (open_buffer): Check here for locking and properly
handle choosing to not open a file when locked instead of in
open_file(). Fixes Savannah bug 42373 reported by Benno Schulenberg
GNU nano 2.3.99pre1 - 2015.01.06
2015-01-03 Chris Allegretta <chrisa@asty.org>
* New formatter code to support syntaxes like

View File

@ -337,9 +337,25 @@ void open_buffer(const char *filename, bool undoable)
/* If we're loading into a new buffer, add a new entry to
* openfile. */
if (new_buffer)
if (new_buffer) {
make_new_buffer();
#ifndef NANO_TINY
if (ISSET(LOCKING) && filename[0] != '\0') {
int lockstatus = do_lockfile(filename);
if (lockstatus < 0) {
if (openfile->next) {
close_buffer();
statusbar(_("Cancelled"));
return;
} else
filename = "";
}
}
#endif
}
/* If the filename isn't blank, and we are not in NOREAD_MODE,
* open the file. Otherwise, treat it as a new file. */
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
@ -906,16 +922,6 @@ int open_file(const char *filename, bool newfie, FILE **f)
full_filename = mallocstrcpy(NULL, filename);
#ifndef NANO_TINY
if (ISSET(LOCKING)) {
int lockstatus = do_lockfile(full_filename);
if (lockstatus < 0)
return -1;
else if (lockstatus == 0)
quiet = 1;
}
#endif
if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS says it's
* not there. */