1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Handle correctly g_get_home_dir() returning NULL, assume it's the current

directory then.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2968 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-10-19 17:48:10 +00:00 committed by cras
parent c1e1f01d49
commit fe4cdce6e6
2 changed files with 19 additions and 5 deletions

View File

@ -159,6 +159,7 @@ void core_init_paths(int argc, char *argv[])
{ "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.irssi)", "PATH" },
{ NULL, '\0', 0, NULL }
};
const char *home;
char *str;
int n, len;
@ -191,8 +192,13 @@ void core_init_paths(int argc, char *argv[])
args_register(options);
if (irssi_dir == NULL)
irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, g_get_home_dir());
if (irssi_dir == NULL) {
home = g_get_home_dir();
if (home == NULL)
home = ".";
irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, home);
}
if (irssi_config_file == NULL)
irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, irssi_dir);

View File

@ -451,9 +451,17 @@ int mkpath(const char *path, int mode)
/* convert ~/ to $HOME */
char *convert_home(const char *path)
{
return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ?
g_strconcat(g_get_home_dir(), path+1, NULL) :
g_strdup(path);
const char *home;
if (*path == '~' && (*(path+1) == '/' || *(path+1) == '\0')) {
home = g_get_home_dir();
if (home == NULL)
home = ".";
return g_strconcat(home, path+1, NULL);
} else {
return g_strdup(path);
}
}
int g_istr_equal(gconstpointer v, gconstpointer v2)