nano

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

commit 242079435575fcdaa110791eac58598144fef9e3
parent d9ae1d6d6a126aa222ae95095b9ae91b6d93aa78
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Fri,  7 Apr 2006 03:59:12 +0000

in write_file(), if the original file is unreadable when we try to save
the backup, we can save the original file unless we're prepending, so do
it


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

Diffstat:
Msrc/files.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1336,9 +1336,15 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type statusbar(_("Error reading %s: %s"), realname, strerror(errno)); beep(); - /* If we can't open the original file, we won't be able - * to save it, so get out. */ - goto cleanup_and_exit; + /* If we can't read from the original file, and we're + * prepending, get out, since we won't be able to save + * either the backup or the original file. If we're not + * prepending, go on, since only saving the original + * file is better than saving nothing. */ + if (append == PREPEND) + goto cleanup_and_exit; + else + goto skip_backup; } }