commit 61b3aa66269885c1000a1898f7ce5d231033f029
parent 6799bc69a6573567d068c66af75546ca4dc412c3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 29 Sep 2021 15:18:17 +0200
tweaks: use five symbolic names, to make eight function calls clearer
Diffstat:
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/definitions.h b/src/definitions.h
@@ -115,6 +115,13 @@
#define REPLACING 1
#define INREGION 2
+#define NORMAL TRUE
+#define SPECIAL FALSE
+#define TEMPORARY FALSE
+
+#define ANNOTATE TRUE
+#define NONOTES FALSE
+
#ifdef ENABLE_UTF8
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
diff --git a/src/files.c b/src/files.c
@@ -2074,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool normal,
birthline = openfile->filetop;
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. */
openfile->filetop = birthline;
@@ -2302,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
free(given);
if (choice == 1)
return write_file(openfile->filename, NULL,
- TRUE, OVERWRITE, FALSE);
+ NORMAL, OVERWRITE, NONOTES);
else if (choice == 0)
return 2;
else
@@ -2324,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
* the marked region; otherwise, write out the whole buffer. */
#ifndef NANO_TINY
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
- return write_marked_file(answer, NULL, TRUE, method);
+ return write_marked_file(answer, NULL, NORMAL, method);
else
#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. */
diff --git a/src/nano.c b/src/nano.c
@@ -325,7 +325,7 @@ void emergency_save(const char *filename)
if (*targetname == '\0')
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);
#ifndef NANO_TINY
/* Try to chmod/chown the saved file to the values of the original file,
diff --git a/src/text.c b/src/text.c
@@ -2499,10 +2499,10 @@ void do_spell(void)
#ifndef NANO_TINY
if (openfile->mark)
- okay = write_marked_file(temp_name, stream, FALSE, OVERWRITE);
+ okay = write_marked_file(temp_name, stream, TEMPORARY, OVERWRITE);
else
#endif
- okay = write_file(temp_name, stream, FALSE, OVERWRITE, FALSE);
+ okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
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, FALSE);
+ okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));