tweaks: adjust three parameters -- two were mistaken, one superfluous

The calls of write_file() in do_spell() and do_formatter() write out
a temporary file -- such a file does not have an 'openfile' record,
so setting 'annotate' to TRUE was pointless.  Using the correct value
for this parameter allows dropping two conditions in write_file().

And when 'exiting' is TRUE and --save-on-exit is in effect, it is
slightly wasteful to stat() the written file and store the info in
its 'openfile' record as the buffer will be closed directly after.

So, now the only place where 'annotate' is TRUE is when writing out
the full buffer to a normally named file.
master
Benno Schulenberg 2021-09-29 14:51:22 +02:00
parent 0c01227d86
commit 6799bc69a6
2 changed files with 5 additions and 5 deletions

View File

@ -1983,7 +1983,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
}
/* When having written an entire buffer, update some administrivia. */
if (annotate && method == OVERWRITE && normal) {
if (annotate && method == OVERWRITE) {
/* If the filename was changed, write a new lockfile when needed,
* and check whether it means a different syntax gets used. */
if (strcmp(openfile->filename, realname) != 0) {
@ -2030,7 +2030,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && annotate && normal)
if (ISSET(MINIBAR) && LINES > 1 && annotate)
report_size = TRUE;
else
#endif
@ -2302,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
free(given);
if (choice == 1)
return write_file(openfile->filename, NULL,
TRUE, OVERWRITE, TRUE);
TRUE, OVERWRITE, FALSE);
else if (choice == 0)
return 2;
else

View File

@ -2502,7 +2502,7 @@ void do_spell(void)
okay = write_marked_file(temp_name, stream, FALSE, OVERWRITE);
else
#endif
okay = write_file(temp_name, stream, FALSE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
@ -2903,7 +2903,7 @@ void do_formatter(void)
temp_name = safe_tempfile(&stream);
if (temp_name != NULL)
okay = write_file(temp_name, stream, FALSE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));