# HG changeset patch # User Matti Hamalainen # Date 1400688602 -10800 # Node ID 1ffacd20b88b42054240183220c444533977a6b9 # Parent 399ce077b2a03801ec90a404f900ba7aa2ea3b40 Clean up the #ifdef mess around homedir handling a bit. diff -r 399ce077b2a0 -r 1ffacd20b88b main.c --- 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) {