diff options
author | Clément Gallet <clement.gallet@ens-lyon.org> | 2019-02-09 00:31:18 +0100 |
---|---|---|
committer | Clément Gallet <clement.gallet@ens-lyon.org> | 2019-02-09 00:31:18 +0100 |
commit | 5ca20a59239bc1852df5d410ca043ca6a5ea8283 (patch) | |
tree | 669a7bc6223eecfdd60a8d5ee1b7c36a08ebc0c8 | |
parent | d7618ebf37d36e17ba0d8573dd1fbd0138f684e0 (diff) |
Fix getenv returning NULLv1.3.3
-rw-r--r-- | src/program/main.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/program/main.cpp b/src/program/main.cpp index c3f04f1a..f62121a5 100644 --- a/src/program/main.cpp +++ b/src/program/main.cpp @@ -191,8 +191,11 @@ int main(int argc, char **argv) context.libtaspath += "/libtas.so"; /* Create the working directories */ - context.config.configdir = getenv("XDG_CONFIG_HOME"); - if (context.config.configdir.empty()) { + char *path = getenv("XDG_CONFIG_HOME"); + if (path) { + context.config.configdir = path; + } + else { context.config.configdir = getenv("HOME"); context.config.configdir += "/.config"; } @@ -213,8 +216,12 @@ int main(int argc, char **argv) /* If the config file set custom directories for the remaining working dir, * we create these directories (if not already created). * Otherwise, we set and create the default ones. */ - std::string data_dir = getenv("XDG_DATA_HOME"); - if (data_dir.empty()) { + std::string data_dir; + path = getenv("XDG_DATA_HOME"); + if (path) { + data_dir = path; + } + else { data_dir = getenv("HOME"); data_dir += "/.local/share"; } |