nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit e4c3ffcd382095bb19eec3d6fd261399a3737e95
parent 5e7a3c2e7e118c7f12d5dfda9f9140f638976aa2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 28 Apr 2024 11:15:54 +0200

tweaks: rename a variable, away from an abbreviation

Diffstat:
Msrc/files.c | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1763,8 +1763,8 @@ bool write_file(const char *name, FILE *thefile, bool normal, #endif char *realname = real_dir_from_tilde(name); /* The filename after tilde expansion. */ - int fd = 0; - /* The descriptor that is assigned when opening the file. */ + int descriptor = 0; + /* The descriptor that gets assigned when opening the file. */ char *tempname = NULL; /* The name of the temporary file we use when prepending. */ linestruct *line = openfile->filetop; @@ -1856,7 +1856,7 @@ bool write_file(const char *name, FILE *thefile, bool normal, #endif /* Now open the file. Use O_EXCL for an emergency file. */ - fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ? + descriptor = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ? O_APPEND : (normal ? O_TRUNC : O_EXCL)), permissions); #ifndef NANO_TINY @@ -1866,7 +1866,7 @@ bool write_file(const char *name, FILE *thefile, bool normal, #endif /* If we couldn't open the file, give up. */ - if (fd == -1) { + if (descriptor < 0) { if (errno == EINTR || errno == 0) statusline(ALERT, _("Interrupted")); else @@ -1878,11 +1878,11 @@ bool write_file(const char *name, FILE *thefile, bool normal, goto cleanup_and_exit; } - thefile = fdopen(fd, (method == APPEND) ? "ab" : "wb"); + thefile = fdopen(descriptor, (method == APPEND) ? "ab" : "wb"); if (thefile == NULL) { statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno)); - close(fd); + close(descriptor); goto cleanup_and_exit; } } @@ -1976,9 +1976,9 @@ bool write_file(const char *name, FILE *thefile, bool normal, #if !defined(NANO_TINY) && defined(HAVE_CHMOD) && defined(HAVE_CHOWN) /* Change permissions and owner of an emergency save file to the values * of the original file, but ignore any failure as we are in a hurry. */ - if (method == EMERGENCY && fd && openfile->statinfo) { - IGNORE_CALL_RESULT(fchmod(fd, openfile->statinfo->st_mode)); - IGNORE_CALL_RESULT(fchown(fd, openfile->statinfo->st_uid, + if (method == EMERGENCY && descriptor && openfile->statinfo) { + IGNORE_CALL_RESULT(fchmod(descriptor, openfile->statinfo->st_mode)); + IGNORE_CALL_RESULT(fchown(descriptor, openfile->statinfo->st_uid, openfile->statinfo->st_gid)); } #endif