/* Path manipulation routines for GDB and gdbserver.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
#ifndef __APPLE__
const char *xdg_cache_home = getenv ("XDG_CACHE_HOME");
- if (xdg_cache_home != NULL)
+ if (xdg_cache_home != NULL && xdg_cache_home[0] != '\0')
{
/* Make sure the path is absolute and tilde-expanded. */
gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home));
#endif
const char *home = getenv ("HOME");
- if (home != NULL)
+ if (home != NULL && home[0] != '\0')
{
/* Make sure the path is absolute and tilde-expanded. */
gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
}
+#ifdef WIN32
+ const char *win_home = getenv ("LOCALAPPDATA");
+ if (win_home != NULL && win_home[0] != '\0')
+ {
+ /* Make sure the path is absolute and tilde-expanded. */
+ gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (win_home));
+ return string_printf ("%s/gdb", abs.get ());
+ }
+#endif
+
return {};
}
#ifndef __APPLE__
const char *xdg_config_home = getenv ("XDG_CONFIG_HOME");
- if (xdg_config_home != NULL)
+ if (xdg_config_home != NULL && xdg_config_home[0] != '\0')
{
/* Make sure the path is absolute and tilde-expanded. */
gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_config_home));
#endif
const char *home = getenv ("HOME");
- if (home != NULL)
+ if (home != NULL && home[0] != '\0')
{
/* Make sure the path is absolute and tilde-expanded. */
gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
}
const char *homedir = getenv ("HOME");
- if (homedir != nullptr)
+ if (homedir != nullptr && homedir[0] != '\0')
{
/* Make sure the path is absolute and tilde-expanded. */
gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (homedir));