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
parent
0c01227d86
commit
6799bc69a6
|
@ -1983,7 +1983,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When having written an entire buffer, update some administrivia. */
|
/* 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,
|
/* If the filename was changed, write a new lockfile when needed,
|
||||||
* and check whether it means a different syntax gets used. */
|
* and check whether it means a different syntax gets used. */
|
||||||
if (strcmp(openfile->filename, realname) != 0) {
|
if (strcmp(openfile->filename, realname) != 0) {
|
||||||
|
@ -2030,7 +2030,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(MINIBAR) && LINES > 1 && annotate && normal)
|
if (ISSET(MINIBAR) && LINES > 1 && annotate)
|
||||||
report_size = TRUE;
|
report_size = TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -2302,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
free(given);
|
free(given);
|
||||||
if (choice == 1)
|
if (choice == 1)
|
||||||
return write_file(openfile->filename, NULL,
|
return write_file(openfile->filename, NULL,
|
||||||
TRUE, OVERWRITE, TRUE);
|
TRUE, OVERWRITE, FALSE);
|
||||||
else if (choice == 0)
|
else if (choice == 0)
|
||||||
return 2;
|
return 2;
|
||||||
else
|
else
|
||||||
|
|
|
@ -2502,7 +2502,7 @@ void do_spell(void)
|
||||||
okay = write_marked_file(temp_name, stream, FALSE, OVERWRITE);
|
okay = write_marked_file(temp_name, stream, FALSE, OVERWRITE);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
okay = write_file(temp_name, stream, FALSE, OVERWRITE, TRUE);
|
okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE);
|
||||||
|
|
||||||
if (!okay) {
|
if (!okay) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
|
@ -2903,7 +2903,7 @@ void do_formatter(void)
|
||||||
temp_name = safe_tempfile(&stream);
|
temp_name = safe_tempfile(&stream);
|
||||||
|
|
||||||
if (temp_name != NULL)
|
if (temp_name != NULL)
|
||||||
okay = write_file(temp_name, stream, FALSE, OVERWRITE, TRUE);
|
okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE);
|
||||||
|
|
||||||
if (!okay) {
|
if (!okay) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
|
|
Loading…
Reference in New Issue