tweaks: use five symbolic names, to make eight function calls clearer

This commit is contained in:
Benno Schulenberg 2021-09-29 15:18:17 +02:00
parent 6799bc69a6
commit 61b3aa6626
4 changed files with 15 additions and 8 deletions

View File

@ -115,6 +115,13 @@
#define REPLACING 1 #define REPLACING 1
#define INREGION 2 #define INREGION 2
#define NORMAL TRUE
#define SPECIAL FALSE
#define TEMPORARY FALSE
#define ANNOTATE TRUE
#define NONOTES FALSE
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
/* In UTF-8 a valid character is at most four bytes long. */ /* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4 #define MAXCHARLEN 4

View File

@ -2074,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool normal,
birthline = openfile->filetop; birthline = openfile->filetop;
openfile->filetop = topline; openfile->filetop = topline;
retval = write_file(name, stream, normal, method, FALSE); retval = write_file(name, stream, normal, method, NONOTES);
/* Restore the proper state of the buffer. */ /* Restore the proper state of the buffer. */
openfile->filetop = birthline; openfile->filetop = birthline;
@ -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, FALSE); NORMAL, OVERWRITE, NONOTES);
else if (choice == 0) else if (choice == 0)
return 2; return 2;
else else
@ -2324,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
* the marked region; otherwise, write out the whole buffer. */ * the marked region; otherwise, write out the whole buffer. */
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED)) if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
return write_marked_file(answer, NULL, TRUE, method); return write_marked_file(answer, NULL, NORMAL, method);
else else
#endif #endif
return write_file(answer, NULL, TRUE, method, TRUE); return write_file(answer, NULL, NORMAL, method, ANNOTATE);
} }
/* Write the current buffer to disk, or discard it. */ /* Write the current buffer to disk, or discard it. */

View File

@ -325,7 +325,7 @@ void emergency_save(const char *filename)
if (*targetname == '\0') if (*targetname == '\0')
fprintf(stderr, _("\nToo many .save files\n")); fprintf(stderr, _("\nToo many .save files\n"));
else if (write_file(targetname, NULL, FALSE, OVERWRITE, FALSE)) { else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
fprintf(stderr, _("\nBuffer written to %s\n"), targetname); fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
#ifndef NANO_TINY #ifndef NANO_TINY
/* Try to chmod/chown the saved file to the values of the original file, /* Try to chmod/chown the saved file to the values of the original file,

View File

@ -2499,10 +2499,10 @@ void do_spell(void)
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark) if (openfile->mark)
okay = write_marked_file(temp_name, stream, FALSE, OVERWRITE); okay = write_marked_file(temp_name, stream, TEMPORARY, OVERWRITE);
else else
#endif #endif
okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE); okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
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, FALSE); okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) { if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));