nano

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

commit f081fa3047114f06656ec595e76063e704a4acea
parent 4383b01b9b8ee1b0990cc5f36b86fd070db4bad3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 17 Sep 2019 14:18:03 +0200

tweaks: rename two variables, to better describe what they contain

The 'tilded' variable is used for two purposes: a user's home directory,
and an intermediate user name.

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

diff --git a/src/files.c b/src/files.c @@ -2305,44 +2305,44 @@ void do_savefile(void) /* Convert the tilde notation when the given path begins with ~/ or ~user/. * Return an allocated string containing the expanded path. */ -char *real_dir_from_tilde(const char *buf) +char *real_dir_from_tilde(const char *path) { - char *tilde_dir, *retval; + char *tilded, *retval; size_t i = 1; - if (*buf != '~') - return mallocstrcpy(NULL, buf); + if (*path != '~') + return mallocstrcpy(NULL, path); /* Figure out how much of the string we need to compare. */ - while (buf[i] != '/' && buf[i] != '\0') + while (path[i] != '/' && path[i] != '\0') i++; if (i == 1) { get_homedir(); - tilde_dir = mallocstrcpy(NULL, homedir); + tilded = mallocstrcpy(NULL, homedir); } else { #ifdef HAVE_PWD_H const struct passwd *userdata; - tilde_dir = mallocstrncpy(NULL, buf, i + 1); - tilde_dir[i] = '\0'; + tilded = mallocstrncpy(NULL, path, i + 1); + tilded[i] = '\0'; do { userdata = getpwent(); - } while (userdata != NULL && - strcmp(userdata->pw_name, tilde_dir + 1) != 0); + } while (userdata && strcmp(userdata->pw_name, tilded + 1) != 0); endpwent(); + if (userdata != NULL) - tilde_dir = mallocstrcpy(tilde_dir, userdata->pw_dir); + tilded = mallocstrcpy(tilded, userdata->pw_dir); #else - tilde_dir = strdup(""); + tilded = strdup(""); #endif } - retval = charalloc(strlen(tilde_dir) + strlen(buf + i) + 1); - sprintf(retval, "%s%s", tilde_dir, buf + i); + retval = charalloc(strlen(tilded) + strlen(path + i) + 1); + sprintf(retval, "%s%s", tilded, path + i); - free(tilde_dir); + free(tilded); return retval; }