mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 00:52:30 +02: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
2 changed files with 19 additions and 5 deletions
|
|
@ -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" },
|
{ "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.irssi)", "PATH" },
|
||||||
{ NULL, '\0', 0, NULL }
|
{ NULL, '\0', 0, NULL }
|
||||||
};
|
};
|
||||||
|
const char *home;
|
||||||
char *str;
|
char *str;
|
||||||
int n, len;
|
int n, len;
|
||||||
|
|
||||||
|
|
@ -191,8 +192,13 @@ void core_init_paths(int argc, char *argv[])
|
||||||
|
|
||||||
args_register(options);
|
args_register(options);
|
||||||
|
|
||||||
if (irssi_dir == NULL)
|
if (irssi_dir == NULL) {
|
||||||
irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, g_get_home_dir());
|
home = g_get_home_dir();
|
||||||
|
if (home == NULL)
|
||||||
|
home = ".";
|
||||||
|
|
||||||
|
irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, home);
|
||||||
|
}
|
||||||
if (irssi_config_file == NULL)
|
if (irssi_config_file == NULL)
|
||||||
irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, irssi_dir);
|
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 */
|
/* convert ~/ to $HOME */
|
||||||
char *convert_home(const char *path)
|
char *convert_home(const char *path)
|
||||||
{
|
{
|
||||||
return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ?
|
const char *home;
|
||||||
g_strconcat(g_get_home_dir(), path+1, NULL) :
|
|
||||||
g_strdup(path);
|
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)
|
int g_istr_equal(gconstpointer v, gconstpointer v2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue