diff options
author | TingPing <tingping@tingping.se> | 2014-11-29 08:24:31 -0500 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-11-29 08:31:35 -0500 |
commit | f03023297b7efc5e93ba258b5940b76967bbfc20 (patch) | |
tree | 2edea4e66982f499e841a48da61310ca2d43e1e6 /src | |
parent | c92b24787813e6f88beeb7bf3b5f5bf4f7502541 (diff) |
Fix handling --cfgdir
Fixes #1225
Diffstat (limited to 'src')
-rw-r--r-- | src/common/hexchat.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c index fde6d108..5bb76f72 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -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 * know the language which is set in the config. The code below is copy-pasted from fe_args() * 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) - { - g_free (xdir); - } - xdir = strdup (argv[i + 1]); + } + else if (strncmp (argv[i], "--cfgdir=", 9) == 0) + { + xdir = strdup (argv[i] + 9); + } + if (xdir != NULL) + { if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR) { xdir[strlen (xdir) - 1] = 0; } + break; } } } |