Commit 733ca94f authored by Chris Allegretta's avatar Chris Allegretta
Browse files

2014-07-11 Chris Allegretta <chrisa@asty.org>

        * 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
parent a9c3bbf8
Showing with 22 additions and 10 deletions
+22 -10
2014-07-11 Chris Allegretta <chrisa@asty.org>
* 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 <chrisa@asty.org> 2014-07-02 Chris Allegretta <chrisa@asty.org>
* src/files.c (do_lockfile): Check whether the directory * src/files.c (do_lockfile): Check whether the directory
of the file we're trying to lock exists, and make the of the file we're trying to lock exists, and make the
resulting error message more intuitive. Fixes resulting error message more intuitive. Fixes
Savannah bug #42639 reported by Benno Schulenberg. Savannah bug #42639 reported by Benno Schulenberg.
2014-07-02 Mark Majeres <mark@engine12.com> 2014-07-02 Mark Majeres <mark@engine12.com>
* src/text.c (undo_cut, redo_cut, update_undo): Handle the * src/text.c (undo_cut, redo_cut, update_undo): Handle the
......
...@@ -301,7 +301,7 @@ int do_lockfile(const char *filename) ...@@ -301,7 +301,7 @@ int do_lockfile(const char *filename)
if (stat(lockfiledir, &fileinfo) == -1) { if (stat(lockfiledir, &fileinfo) == -1) {
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"), statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
lockfiledir); lockfiledir);
return -1; return 0;
} }
} }
...@@ -891,7 +891,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw ...@@ -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) int open_file(const char *filename, bool newfie, FILE **f)
{ {
struct stat fileinfo, fileinfo2; struct stat fileinfo, fileinfo2;
int fd; int fd, quiet = 0;
char *full_filename; char *full_filename;
assert(filename != NULL && f != NULL); assert(filename != NULL && f != NULL);
...@@ -907,22 +907,28 @@ int open_file(const char *filename, bool newfie, FILE **f) ...@@ -907,22 +907,28 @@ int open_file(const char *filename, bool newfie, FILE **f)
#ifndef NANO_TINY #ifndef NANO_TINY
if (ISSET(LOCKING)) if (ISSET(LOCKING)) {
if (do_lockfile(full_filename) < 0) int lockstatus = do_lockfile(full_filename);
return -1; if (lockstatus < 0)
return -1;
else if (lockstatus == 0)
quiet = 1;
}
#endif #endif
if (stat(full_filename, &fileinfo) == -1) { if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS says it's /* Well, maybe we can open the file even if the OS says it's
* not there. */ * not there. */
if ((fd = open(filename, O_RDONLY)) != -1) { if ((fd = open(filename, O_RDONLY)) != -1) {
statusbar(_("Reading File")); if (!quiet)
statusbar(_("Reading File"));
free(full_filename); free(full_filename);
return 0; return 0;
} }
if (newfie) { if (newfie) {
statusbar(_("New File")); if (!quiet)
statusbar(_("New File"));
return -2; return -2;
} }
statusbar(_("\"%s\" not found"), filename); statusbar(_("\"%s\" not found"), filename);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment