From 43edba2b8d25dd8e2290e1e4534b05387b0f60f9 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sun, 24 Mar 2024 00:15:35 +0100 Subject: Use dGethomedir() to get the home directory Other platforms don't use $HOME. Reported-by: dogma --- dpi/file.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'dpi/file.c') 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; -- cgit v1.2.3