aboutsummaryrefslogtreecommitdiff
path: root/lib/config_global.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-03-24 14:51:59 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-03-25 17:16:05 -0400
commit838c8723e314782c255011536126b95e9d6a97f9 (patch)
treeaaef6390df688a75bd6af1f3b6b1d33c07ab9e30 /lib/config_global.c
parentae3eb38592cb40011fd026d3c7c64ebc022bedca (diff)
downloadspmc-838c8723e314782c255011536126b95e9d6a97f9.tar.gz
Add .circleci/config.yml
Diffstat (limited to 'lib/config_global.c')
-rw-r--r--lib/config_global.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/config_global.c b/lib/config_global.c
index 16d97cf..f63566b 100644
--- a/lib/config_global.c
+++ b/lib/config_global.c
@@ -10,20 +10,16 @@
*/
char *get_user_conf_dir(void) {
char *result = NULL;
- wordexp_t wexp;
- wordexp("~/.spm", &wexp, 0);
- if (wexp.we_wordc != 0) {
- result = (char *)calloc(strlen(wexp.we_wordv[0]) + 1, sizeof(char));
- if (!result) {
- wordfree(&wexp);
- return NULL;
- }
- strncpy(result, wexp.we_wordv[0], strlen(wexp.we_wordv[0]));
- if (access(result, F_OK) != 0) {
- mkdirs(result, 0755);
- }
+
+ result = expandpath("~/.spm");
+ if (result == NULL) {
+ perror("get_user_conf_dir");
+ return NULL;
+ }
+
+ if (access(result, F_OK) != 0) {
+ mkdirs(result, 0755);
}
- wordfree(&wexp);
return result;
}
@@ -44,6 +40,7 @@ char *get_user_config_file(void) {
sprintf(template, "%s%c%s", ucd, DIRSEP, filename);
if (access(template, F_OK) != 0) {
// No configuration exists, so fail
+ free(ucd);
return NULL;
}
free(ucd);
@@ -109,6 +106,7 @@ char *get_package_manifest(void) {
if (manifest == NULL) {
perror("manifest generator");
fprintf(SYSERROR);
+ free(ucd);
return NULL;
}
manifest_write(manifest, PKG_DIR);