commit c2a0c78d9b11d8a28e867f435b9406a8a1ab5d84
parent 97f4fe26f01ed5ede6fdd40791e492a22b8475ef
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 15 Jul 2016 12:59:59 +0200
tweaks: rename a variable and a type, to be less confusing
Diffstat:
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1695,15 +1695,15 @@ int copy_file(FILE *inn, FILE *out)
*
* tmp means we are writing a temporary file in a secure fashion. We
* use it when spell checking or dumping the file on an error. If
- * append is APPEND, it means we are appending instead of overwriting.
- * If append is PREPEND, it means we are prepending instead of
+ * method is APPEND, it means we are appending instead of overwriting.
+ * If method is PREPEND, it means we are prepending instead of
* overwriting. If nonamechange is TRUE, we don't change the current
* filename. nonamechange is ignored if tmp is FALSE, we're appending,
* or we're prepending.
*
* Return TRUE on success or FALSE on error. */
-bool write_file(const char *name, FILE *f_open, bool tmp, append_type
- append, bool nonamechange)
+bool write_file(const char *name, FILE *f_open, bool tmp,
+ kind_of_writing_type method, bool nonamechange)
{
bool retval = FALSE;
/* Instead of returning in this function, you should always
@@ -1769,7 +1769,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
* only if the file has not been modified by someone else since nano
* opened it. */
if (ISSET(BACKUP_FILE) && !tmp && realexists && openfile->current_stat &&
- (append != OVERWRITE || openfile->mark_set ||
+ (method != OVERWRITE || openfile->mark_set ||
openfile->current_stat->st_mtime == st.st_mtime)) {
int backup_fd;
FILE *backup_file;
@@ -1948,7 +1948,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
/* If we're prepending, copy the file to a temp file. */
- if (append == PREPEND) {
+ if (method == PREPEND) {
int fd_source;
FILE *f_source = NULL;
@@ -1997,7 +1997,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
if (f_open == NULL) {
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
* is copied from joe, because wiggy says so *shrug*. */
- fd = open(realname, O_WRONLY | O_CREAT | ((append == APPEND) ?
+ fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), S_IRUSR |
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
@@ -2013,7 +2013,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto cleanup_and_exit;
}
- f = fdopen(fd, (append == APPEND) ? "ab" : "wb");
+ f = fdopen(fd, (method == APPEND) ? "ab" : "wb");
if (f == NULL) {
statusline(ALERT, _("Error writing %s: %s"), realname,
@@ -2079,7 +2079,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
/* If we're prepending, open the temp file, and append it to f. */
- if (append == PREPEND) {
+ if (method == PREPEND) {
int fd_source;
FILE *f_source = NULL;
@@ -2111,7 +2111,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto cleanup_and_exit;
}
- if (!tmp && append == OVERWRITE) {
+ if (!tmp && method == OVERWRITE) {
/* If we must set the filename, and it changed, adjust things. */
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
#ifndef DISABLE_COLOR
@@ -2164,7 +2164,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* Write a marked selection from a file out to disk. Return TRUE on
* success or FALSE on error. */
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
- append_type append)
+ kind_of_writing_type method)
{
bool retval;
bool old_modified = openfile->modified;
@@ -2188,7 +2188,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
added_magicline = TRUE;
}
- retval = write_file(name, f_open, tmp, append, TRUE);
+ retval = write_file(name, f_open, tmp, method, TRUE);
/* If we added a magicline, remove it now. */
if (added_magicline)
@@ -2214,7 +2214,7 @@ int do_writeout(bool exiting)
{
int i;
bool result = FALSE;
- append_type append = OVERWRITE;
+ kind_of_writing_type method = OVERWRITE;
char *given;
/* The filename we offer, or what the user typed so far. */
bool maychange = (openfile->filename[0] == '\0');
@@ -2250,13 +2250,13 @@ int do_writeout(bool exiting)
* it allows reading from or writing to files not specified on
* the command line. */
if (openfile->mark_set && !exiting && !ISSET(RESTRICTED))
- msg = (append == PREPEND) ? _("Prepend Selection to File") :
- (append == APPEND) ? _("Append Selection to File") :
+ msg = (method == PREPEND) ? _("Prepend Selection to File") :
+ (method == APPEND) ? _("Append Selection to File") :
_("Write Selection to File");
else
#endif /* !NANO_TINY */
- msg = (append == PREPEND) ? _("File Name to Prepend to") :
- (append == APPEND) ? _("File Name to Append to") :
+ msg = (method == PREPEND) ? _("File Name to Prepend to") :
+ (method == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
present_path = mallocstrcpy(present_path, "./");
@@ -2332,10 +2332,10 @@ int do_writeout(bool exiting)
} else
#endif /* !NANO_TINY */
if (func == prepend_void) {
- append = (append == PREPEND) ? OVERWRITE : PREPEND;
+ method = (method == PREPEND) ? OVERWRITE : PREPEND;
continue;
} else if (func == append_void) {
- append = (append == APPEND) ? OVERWRITE : APPEND;
+ method = (method == APPEND) ? OVERWRITE : APPEND;
continue;
} else if (func == do_help_void) {
continue;
@@ -2360,7 +2360,7 @@ int do_writeout(bool exiting)
}
#endif
- if (append == OVERWRITE) {
+ if (method == OVERWRITE) {
size_t answer_len = strlen(answer);
bool name_exists, do_warning;
char *full_answer, *full_filename;
@@ -2449,10 +2449,10 @@ int do_writeout(bool exiting)
* writing to files not specified on the command line. */
#ifndef NANO_TINY
if (openfile->mark_set && !exiting && !ISSET(RESTRICTED))
- result = write_marked_file(answer, NULL, FALSE, append);
+ result = write_marked_file(answer, NULL, FALSE, method);
else
#endif
- result = write_file(answer, NULL, FALSE, append, FALSE);
+ result = write_file(answer, NULL, FALSE, method, FALSE);
break;
}
diff --git a/src/nano.h b/src/nano.h
@@ -173,7 +173,7 @@ typedef enum {
typedef enum {
OVERWRITE, APPEND, PREPEND
-} append_type;
+} kind_of_writing_type;
typedef enum {
UPWARD, DOWNWARD
diff --git a/src/proto.h b/src/proto.h
@@ -317,11 +317,11 @@ int delete_lockfile(const char *lockfilename);
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
#endif
int copy_file(FILE *inn, FILE *out);
-bool write_file(const char *name, FILE *f_open, bool tmp, append_type
- append, bool nonamechange);
+bool write_file(const char *name, FILE *f_open, bool tmp,
+ kind_of_writing_type method, bool nonamechange);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
- append_type append);
+ kind_of_writing_type method);
#endif
int do_writeout(bool exiting);
void do_writeout_void(void);