From 50543300d9ff2db79fea4d4f220daf2f64aec696 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 14 Jul 2021 10:36:15 +0200 Subject: [PATCH] tweaks: reshuffle some code to elide a variable, and improve a comment --- src/nano.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/nano.c b/src/nano.c index 61bf1a70..501d4f87 100644 --- a/src/nano.c +++ b/src/nano.c @@ -309,12 +309,11 @@ void do_exit(void) statusbar(_("Cancelled")); } -/* Save the current buffer under the given name (or under "nano." - * for a nameless buffer). If needed, the name is modified to be unique. */ +/* Save the current buffer under the given name (or "nano." when nameless) + * with suffix ".save". If needed, the name is further suffixed to be unique. */ void emergency_save(const char *filename) { char *plainname, *targetname; - bool saved = FALSE; if (*filename == '\0') { plainname = nmalloc(28); @@ -324,13 +323,11 @@ void emergency_save(const char *filename) targetname = get_next_filename(plainname, ".save"); - if (*targetname != '\0') - saved = write_file(targetname, NULL, TRUE, OVERWRITE, FALSE); - - if (saved) + if (*targetname == '\0') + fprintf(stderr, _("\nToo many .save files\n")); + else if (write_file(targetname, NULL, TRUE, OVERWRITE, FALSE)) { fprintf(stderr, _("\nBuffer written to %s\n"), targetname); - else if (*targetname == '\0') - fprintf(stderr, _("\nToo many .save files")); + } #ifndef NANO_TINY /* Try to chmod/chown the saved file to the values of the original file,