Use homenv variable instead of getenv(HOME) 3 times in do_rcfile
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1466 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
1debce2865
commit
d3c8f09d17
7
rcfile.c
7
rcfile.c
|
@ -622,6 +622,7 @@ void do_rcfile(void)
|
||||||
FILE *rcstream;
|
FILE *rcstream;
|
||||||
const struct passwd *userage;
|
const struct passwd *userage;
|
||||||
uid_t euid = geteuid();
|
uid_t euid = geteuid();
|
||||||
|
char *homenv = getenv("HOME");
|
||||||
|
|
||||||
#ifdef SYSCONFDIR
|
#ifdef SYSCONFDIR
|
||||||
assert(sizeof(SYSCONFDIR) == strlen(SYSCONFDIR) + 1);
|
assert(sizeof(SYSCONFDIR) == strlen(SYSCONFDIR) + 1);
|
||||||
|
@ -638,9 +639,9 @@ void do_rcfile(void)
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
|
|
||||||
/* Rely on $HOME, fall back on getpwuid() */
|
/* Rely on $HOME, fall back on getpwuid() */
|
||||||
if (getenv("HOME") != NULL) {
|
if (homenv != NULL) {
|
||||||
nanorc = nrealloc(nanorc, strlen(getenv("HOME")) + 10);
|
nanorc = nrealloc(nanorc, strlen(homenv) + 10);
|
||||||
sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
|
sprintf(nanorc, "%s/.nanorc", homenv);
|
||||||
} else {
|
} else {
|
||||||
userage = getpwuid(euid);
|
userage = getpwuid(euid);
|
||||||
endpwent();
|
endpwent();
|
||||||
|
|
Loading…
Reference in New Issue