nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 6d5b2fd9366fd71515ef8683d4afc128a92d52f4
parent 637b76b582af29099e387271f9935b9a5e1da3f2
Author: Chris Allegretta <chrisa@asty.org>
Date:   Thu,  3 Jul 2014 03:54:22 +0000

2014-07-02  Chris Allegretta <chrisa@asty.org>
        * 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 by bens.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5056 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 6++++++
Msrc/files.c | 12+++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2014-07-02 Chris Allegretta <chrisa@asty.org> + * 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 by bens. + 2014-07-02 Mark Majeres <mark@engine12.com> * src/text.c (undo_cut, redo_cut, update_undo): Handle the cases of cutting-from-cursor-to-end-of-line correctly. diff --git a/src/files.c b/src/files.c @@ -141,7 +141,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi mypid = getpid(); if (gethostname(myhostname, 31) < 0) { - statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno)); + statusbar(_("Couldn't determine hosttname for lock file: %s"), strerror(errno)); return -1; } @@ -247,6 +247,7 @@ int do_lockfile(const char *filename) size_t lockfilesize = strlen(filename) + strlen(locking_prefix) + strlen(locking_suffix) + 3; char *lockfilename = charalloc(lockfilesize); + char *lockfilecpy = NULL; char lockprog[12], lockuser[16]; struct stat fileinfo; int lockfd, lockpid; @@ -294,8 +295,17 @@ int do_lockfile(const char *filename) blank_statusbar(); return -1; } + } else { + lockfilecpy = mallocstrcpy(NULL, lockfilename); + lockfilecpy = dirname(lockfilecpy); + if (stat(lockfilename, &fileinfo) == -1) { + statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"), + lockfilecpy); + return -1; + } } + return write_lockfile(lockfilename, filename, FALSE); } #endif /* !NANO_TINY */