mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05: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:
parent
c1e1f01d49
commit
fe4cdce6e6
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user