summaryrefslogtreecommitdiff
path: root/src/core/wee-dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/wee-dir.c')
-rw-r--r--src/core/wee-dir.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/wee-dir.c b/src/core/wee-dir.c
index d05280861..969749b0e 100644
--- a/src/core/wee-dir.c
+++ b/src/core/wee-dir.c
@@ -442,6 +442,9 @@ dir_find_xdg_dirs (char **config_dir, char **data_dir, char **cache_dir,
*runtime_dir = NULL;
ptr_home = getenv ("HOME");
+ if (!ptr_home)
+ goto error_home;
+
xdg_config_home = getenv ("XDG_CONFIG_HOME");
xdg_data_home = getenv ("XDG_DATA_HOME");
xdg_cache_home = getenv ("XDG_CACHE_HOME");
@@ -462,7 +465,7 @@ dir_find_xdg_dirs (char **config_dir, char **data_dir, char **cache_dir,
}
*config_dir = strdup (path);
if (!*config_dir)
- goto error;
+ goto error_memory;
/* set data dir: $XDG_DATA_HOME/weechat or $HOME/.local/share/weechat */
if (xdg_data_home && xdg_data_home[0])
@@ -480,7 +483,7 @@ dir_find_xdg_dirs (char **config_dir, char **data_dir, char **cache_dir,
}
*data_dir = strdup (path);
if (!*data_dir)
- goto error;
+ goto error_memory;
/* set cache dir: $XDG_CACHE_HOME/weechat or $HOME/.cache/weechat */
if (xdg_cache_home && xdg_cache_home[0])
@@ -497,7 +500,7 @@ dir_find_xdg_dirs (char **config_dir, char **data_dir, char **cache_dir,
}
*cache_dir = strdup (path);
if (!*cache_dir)
- goto error;
+ goto error_memory;
/* set runtime dir: $XDG_RUNTIME_DIR/weechat or same as cache dir */
if (xdg_runtime_dir && xdg_runtime_dir[0])
@@ -512,10 +515,19 @@ dir_find_xdg_dirs (char **config_dir, char **data_dir, char **cache_dir,
*runtime_dir = strdup (*cache_dir);
}
if (!*runtime_dir)
- goto error;
+ goto error_memory;
return 1;
+error_home:
+ string_fprintf (stderr,
+ _("Error: environment variable \"HOME\" is not defined\n"));
+ goto error;
+
+error_memory:
+ string_fprintf (stderr, _("Error: not enough memory\n"));
+ goto error;
+
error:
if (*config_dir)
{
@@ -537,7 +549,6 @@ error:
free (*runtime_dir);
*runtime_dir = NULL;
}
- string_fprintf (stderr, _("Error: not enough memory\n"));
return 0;
}