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
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
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
|
||||||
|
|||||||
14
src/files.c
14
src/files.c
@@ -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
|
|||||||
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,21 +907,27 @@ 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);
|
||||||
|
if (lockstatus < 0)
|
||||||
return -1;
|
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) {
|
||||||
|
if (!quiet)
|
||||||
statusbar(_("Reading File"));
|
statusbar(_("Reading File"));
|
||||||
free(full_filename);
|
free(full_filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newfie) {
|
if (newfie) {
|
||||||
|
if (!quiet)
|
||||||
statusbar(_("New File"));
|
statusbar(_("New File"));
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user