Mercurial > hg > nnchat
changeset 616:1ffacd20b88b
Clean up the #ifdef mess around homedir handling a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 May 2014 19:10:02 +0300 |
parents | 399ce077b2a0 |
children | ada20f599490 |
files | main.c |
diffstat | 1 files changed, 5 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Tue May 20 07:15:48 2014 +0300 +++ b/main.c Wed May 21 19:10:02 2014 +0300 @@ -2003,31 +2003,26 @@ th_cfg_add_section(&cfg, "logging", tmpcfg); // Get home directory path -#ifdef __WIN32 { +#if defined(__WIN32) char tmpPath[MAX_PATH]; if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) setHomeDir = th_strdup(tmpPath); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); - } -#else - { - char *xdgConfigDir = getenv("XDG_CONFIG_HOME"), - *userHomeDir = getenv("HOME"); +#elif defined(USE_XDG) + char *xdgConfigDir = getenv("XDG_CONFIG_HOME"); -#ifdef USE_XDG // If XDG is enabled, try the environment variable first if (xdgConfigDir != NULL) setHomeDir = th_strdup(xdgConfigDir); else // Nope, try the obvious alternative - setHomeDir = th_strdup_printf("%s/.config", userHomeDir); + setHomeDir = th_strdup_printf("%s/.config", getenv("HOME")); #else - setHomeDir = th_strdup(userHomeDir); + setHomeDir = th_strdup(getenv("HOME")); #endif } -#endif if (setHomeDir != NULL) {