nano

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

commit a322dab48296425d72b0b4554717c7751d32ce04
parent 0ed1695fd4bc03955438a4a165b73856b0e31fd6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 16 Jul 2020 15:01:04 +0200

tweaks: elide a function that is called just once

It also nicely groups the backup stuff together in a single function.

Diffstat:
Msrc/files.c | 26++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1523,21 +1523,6 @@ void init_backup_dir(void) free(backup_dir); backup_dir = charealloc(target, strlen(target) + 1); } - -/* Report the reason why the backup failed and ask what to do. Return TRUE - * when the user wants to save the file itself anyway. But refuse to go on - * if the backup failed due to a lack of space. */ -bool user_wants_to_proceed(void) -{ - warn_and_briefly_pause(strerror(errno)); - - if (errno == ENOSPC) { - currmenu = MMOST; - return FALSE; - } else - return (do_yesno_prompt(FALSE, _("Cannot make backup; " - "continue and save actual file? ")) == 1); -} #endif /* !NANO_TINY */ /* Read all data from inn, and write it to out. File inn must be open for @@ -1731,10 +1716,15 @@ bool make_backup_of(char *realname) goto retry_backup; } - /* If all attempts failed, ask the user what to do, because if something - * goes wrong during the save, the contents of the file might be lost. */ warn_and_briefly_pause(_("Cannot make backup")); - if (user_wants_to_proceed()) { + warn_and_briefly_pause(strerror(errno)); + currmenu = MMOST; + + /* If both attempts failed, and it isn't because of lack of disk space, + * ask the user what to do, because if something goes wrong during the + * save of the file itself, its contents may be lost. */ + if (errno != ENOSPC && do_yesno_prompt(FALSE, _("Cannot make backup; " + "continue and save actual file? ")) == 1) { free(backupname); return TRUE; }