1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-22 09:12:22 -05:00

Fix handling --cfgdir

Fixes #1225
This commit is contained in:
TingPing 2014-11-29 08:24:31 -05:00
parent c92b247878
commit f03023297b

View File

@ -1018,23 +1018,27 @@ main (int argc, char *argv[])
* load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to * load_config() must come before fe_args() because fe_args() calls gtk_init() which needs to
* know the language which is set in the config. The code below is copy-pasted from fe_args() * know the language which is set in the config. The code below is copy-pasted from fe_args()
* for the most part. */ * for the most part. */
if (argc >= 3) if (argc >= 2)
{ {
for (i = 1; i < argc - 1; i++) for (i = 1; i < argc; i++)
{ {
if (strcmp (argv[i], "-d") == 0) if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
&& i + 1 < argc)
{ {
if (xdir) xdir = strdup (argv[i + 1]);
}
else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
{ {
g_free (xdir); xdir = strdup (argv[i] + 9);
} }
xdir = strdup (argv[i + 1]); if (xdir != NULL)
{
if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR) if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
{ {
xdir[strlen (xdir) - 1] = 0; xdir[strlen (xdir) - 1] = 0;
} }
break;
} }
} }
} }