From e06472a249fdb99182f80270edb1dae33121c355 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 20 Jun 2015 08:21:35 +0000 Subject: [PATCH] Keeping homedir NULL when no home directory could be determined, so that nano will show a message about it. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5259 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/utils.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index abcecb0f..819f73eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * src/search.c (do_research): If nothing was searched for yet during this run of nano, take the most recent item from the search history. This makes M-W work also right after startup, like in vim/less. + * src/utils.c (get_homedir): Keep homedir NULL when no home directory + could be determined, so that nano will show a message about it. 2015-06-18 Benno Schulenberg * src/rcfile.c: Allow a tiny nano's ~/.nanorc to enable search and diff --git a/src/utils.c b/src/utils.c index 9c936a5f..36cd140e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -43,7 +43,11 @@ void get_homedir(void) if (userage != NULL) homenv = userage->pw_dir; } - homedir = mallocstrcpy(NULL, homenv); + + /* Only set homedir if some home directory could be determined, + * otherwise keep homedir NULL. */ + if (homenv != NULL && strcmp(homenv, "") != 0) + homedir = mallocstrcpy(NULL, homenv); } } -- 2.39.5