From 2e39c1c2835d32e73bcf42a4280745c55a842e30 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Thu, 13 Feb 2003 03:36:15 +0000 Subject: [PATCH] - rcfile.c:do_rcfile() - Revert (somewhat) previous behavior of looking at /home/chrisa, and only run getpw* if it is NULL. Most *nix programs seem to only care about /home/chrisa, and at the user-level getpw* may not be reliable (and its slower) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ rcfile.c | 29 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5bcc07a..c70403d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -62,6 +62,11 @@ CVS code (David Benbennick). colortoint, parse_colors() - Don't add strings with invalid fg colors at all. + do_rcfile() + - Revert (somewhat) previous behavior of looking at + $HOME, and only run getpw* if it is NULL. Most *nix programs + seem to only care about $HOME, and at the user-level + getpw* may not be reliable (and its slower). - search.c: do_gotoline() - Only goto_abort() if we *didnt* abort the command, making diff --git a/rcfile.c b/rcfile.c index 03f5dfee..829a1efb 100644 --- a/rcfile.c +++ b/rcfile.c @@ -635,20 +635,27 @@ void do_rcfile(void) } #endif - /* Determine home directory using getpwent(), don't rely on $HOME */ - do { - userage = getpwent(); - } while (userage != NULL && userage->pw_uid != euid); - endpwent(); - lineno = 0; - if (userage == NULL) { - rcfile_error(_("I can't find my home directory! Wah!")); - SET(NO_RCFILE); + /* Rely on $HOME, fall back on getpwuid() */ + if (getenv("HOME") != NULL) { + nanorc = nrealloc(nanorc, strlen(getenv("HOME")) + 10); + sprintf(nanorc, "%s/.nanorc", getenv("HOME")); } else { - nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9); - sprintf(nanorc, "%s/.nanorc", userage->pw_dir); + userage = getpwuid(euid); + endpwent(); + + if (userage == NULL) { + rcfile_error(_("I can't find my home directory! Wah!")); + SET(NO_RCFILE); + } else { + nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9); + sprintf(nanorc, "%s/.nanorc", userage->pw_dir); + + } + } + + if (!ISSET(NO_RCFILE)) { #if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING) /* If we've already read $SYSCONFDIR/nanorc (if it's there), we're -- 2.39.5