aboutsummaryrefslogtreecommitdiff
path: root/dpi
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-03-24 00:15:35 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-03-24 00:15:35 +0100
commit43edba2b8d25dd8e2290e1e4534b05387b0f60f9 (patch)
tree59ef45c822057a58e21f34a0a927bc58a16bf981 /dpi
parent9013cbdefbc942de7b3959bb553517bd112dc947 (diff)
Use dGethomedir() to get the home directory
Other platforms don't use $HOME. Reported-by: dogma
Diffstat (limited to 'dpi')
-rw-r--r--dpi/file.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/dpi/file.c b/dpi/file.c
index 0e3390b5..796f7d6e 100644
--- a/dpi/file.c
+++ b/dpi/file.c
@@ -791,7 +791,7 @@ static int File_parse_hex_octet(const char *s)
/*
* Make a file URL into a human (and machine) readable path.
- * The home tile '~' character is expanded from the value of $HOME.
+ * The tilde '~' character is expanded to the value of the user home.
* The idea is to always have a path that starts with only one slash.
* Embedded slashes are ignored.
*/
@@ -812,11 +812,7 @@ static char *File_normalize_path(const char *orig)
if (str[0] == '~' && (str[1] == '/' || str[1] == '\0')) {
/* Expand home tilde "~" into "/home/userxyz" */
- const char *home = getenv("HOME");
- if (home == NULL || home[0] == '\0') {
- _MSG("cannot get home path from the environment variable HOME\n");
- return NULL;
- }
+ const char *home = dGethomedir();
/* Add separator if needed */
char *sep = home[strlen(home) - 1] == '/' ? "" : "/";
char *next = str + 1;