From 733ca94f8e3ce493435d7fc08af1e85a83beba79 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Fri, 11 Jul 2014 11:16:15 +0000 Subject: [PATCH] 2014-07-11 Chris Allegretta * src/files.c (do_lockfile, open_file): If locking fails, allow the lock failure message to be preserved AND preserve the filename passed on the cmdline. Fixes Savannah bug #42668. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5059 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 12 +++++++++--- src/files.c | 20 +++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14f1b99b..53b9b883 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,14 @@ +2014-07-11 Chris Allegretta + * src/files.c (do_lockfile, open_file): If locking fails, + allow the lock failure message to be preserved AND + preserve the filename passed on the cmdline. Fixes + Savannah bug #42668. + 2014-07-02 Chris Allegretta * src/files.c (do_lockfile): Check whether the directory - of the file we're trying to lock exists, and make the - resulting error message more intuitive. Fixes - Savannah bug #42639 reported by Benno Schulenberg. + of the file we're trying to lock exists, and make the + resulting error message more intuitive. Fixes + Savannah bug #42639 reported by Benno Schulenberg. 2014-07-02 Mark Majeres * src/text.c (undo_cut, redo_cut, update_undo): Handle the diff --git a/src/files.c b/src/files.c index 11a5051d..6d8c3062 100644 --- a/src/files.c +++ b/src/files.c @@ -301,7 +301,7 @@ int do_lockfile(const char *filename) if (stat(lockfiledir, &fileinfo) == -1) { statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"), lockfiledir); - return -1; + return 0; } } @@ -891,7 +891,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw int open_file(const char *filename, bool newfie, FILE **f) { struct stat fileinfo, fileinfo2; - int fd; + int fd, quiet = 0; char *full_filename; assert(filename != NULL && f != NULL); @@ -907,22 +907,28 @@ int open_file(const char *filename, bool newfie, FILE **f) #ifndef NANO_TINY - if (ISSET(LOCKING)) - if (do_lockfile(full_filename) < 0) - return -1; + 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. */ if ((fd = open(filename, O_RDONLY)) != -1) { - statusbar(_("Reading File")); + if (!quiet) + statusbar(_("Reading File")); free(full_filename); return 0; } if (newfie) { - statusbar(_("New File")); + if (!quiet) + statusbar(_("New File")); return -2; } statusbar(_("\"%s\" not found"), filename); -- 2.39.5