# HG changeset patch # User John W. Eaton # Date 1427995170 14400 # Node ID 4b7b7ac7af2c0372acf6f89b3b0d4239174ee8ca # Parent 47d420d769ba819f2ea0a63eb6860390b1988d77 use get_home_directory instead of getenv ("HOME") (bug #44694) * files-dock-widget.cc (files_dock_widget::popdownmenu_home): Use get_home_directory instead of getenv ("HOME") for the benefit of Windows systems which may not have HOME set in the environment. * kpse.cc (kpse_tilde_expand): Likewise. * prefdir.m: Likewise. * system.tst: Likewise. * edit.m: Use get_home_directory instead of default_home. (default_home): Delete subfunction. diff -r 47d420d769ba -r 4b7b7ac7af2c libgui/src/files-dock-widget.cc --- a/libgui/src/files-dock-widget.cc Thu Apr 02 13:08:34 2015 -0400 +++ b/libgui/src/files-dock-widget.cc Thu Apr 02 13:19:30 2015 -0400 @@ -46,6 +46,7 @@ #include #include "load-save.h" +#include "oct-env.h" class FileTreeViewer : public QTreeView { @@ -822,7 +823,8 @@ void files_dock_widget::popdownmenu_home (bool) { - QString dir = qgetenv ("HOME"); + QString dir = QString::fromStdString (octave_env::get_home_directory ()); + if (dir.isEmpty ()) dir = QDir::homePath (); diff -r 47d420d769ba -r 4b7b7ac7af2c liboctave/util/kpse.cc --- a/liboctave/util/kpse.cc Thu Apr 02 13:08:34 2015 -0400 +++ b/liboctave/util/kpse.cc Thu Apr 02 13:19:30 2015 -0400 @@ -1201,7 +1201,7 @@ } else if (name.length () == 1) { - expansion = octave_env::getenv ("HOME"); + expansion = octave_env::get_home_directory (); if (expansion.empty ()) expansion = "."; @@ -1212,7 +1212,7 @@ else if (IS_DIR_SEP (name[1])) { unsigned c = 1; - std::string home = octave_env::getenv ("HOME"); + std::string home = octave_env::get_home_directory (); if (home.empty ()) home = "."; diff -r 47d420d769ba -r 4b7b7ac7af2c scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m Thu Apr 02 13:08:34 2015 -0400 +++ b/scripts/miscellaneous/edit.m Thu Apr 02 13:19:30 2015 -0400 @@ -125,7 +125,8 @@ ## Pick up globals or default them. - persistent FUNCTION = struct ("HOME", fullfile (default_home, "octave"), + persistent FUNCTION = struct ("HOME", + fullfile (get_home_directory (), "octave"), "AUTHOR", default_user(1), "EMAIL", [], "LICENSE", "GPL", @@ -164,7 +165,7 @@ return; case "HOME" if (! isempty (stateval) && stateval(1) == "~") - stateval = [ default_home, stateval(2:end) ]; + stateval = [ get_home_directory, stateval(2:end) ]; endif FUNCTION.HOME = stateval; return; @@ -517,20 +518,6 @@ endfunction -function retval = default_home () - - retval = getenv ("HOME"); - if (isempty (retval)) - retval = glob ("~"); - if (! isempty (retval)) - retval = retval{1}; - else - retval = ""; - endif - endif - -endfunction - ## Return the name associated with the current user ID. ## ## If LONG_FORM is 1, return the full name. This will be the diff -r 47d420d769ba -r 4b7b7ac7af2c scripts/prefs/prefdir.m --- a/scripts/prefs/prefdir.m Thu Apr 02 13:08:34 2015 -0400 +++ b/scripts/prefs/prefdir.m Thu Apr 02 13:19:30 2015 -0400 @@ -42,7 +42,7 @@ function folder = prefdir () - folder = getenv ("HOME"); + folder = get_home_directory (); endfunction diff -r 47d420d769ba -r 4b7b7ac7af2c test/system.tst --- a/test/system.tst Thu Apr 02 13:08:34 2015 -0400 +++ b/test/system.tst Thu Apr 02 13:19:30 2015 -0400 @@ -268,7 +268,7 @@ %!error <... getgid> getgid (1) -%!assert (getenv ("HOME"), tilde_expand ("~")) +%!assert (get_home_directory (), tilde_expand ("~")) %!error getenv () %!error getenv ("foo", 1)