summaryrefslogtreecommitdiff
path: root/spectro/xdg_bds.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-02 19:24:58 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-02 19:24:58 +0200
commit3db384424bd7398ffbb7a355cab8f15f3add009f (patch)
tree4536961c62454aca3ac87ee88229e4d20c0d44fa /spectro/xdg_bds.c
parentd479dd1aab1c1cb907932c6595b0ef33523fc797 (diff)
New upstream version 1.9.1+repackupstream/1.9.1+repack
Diffstat (limited to 'spectro/xdg_bds.c')
-rw-r--r--spectro/xdg_bds.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/spectro/xdg_bds.c b/spectro/xdg_bds.c
index c1805ed..e24e4ab 100644
--- a/spectro/xdg_bds.c
+++ b/spectro/xdg_bds.c
@@ -169,20 +169,22 @@ static char *append(char *in, char *app) {
return rv;
}
-/* Append a ':' or ';' then a string. Free in. Return NULL on error. */
+/* Append a ':' or ';' then a string. Free in. */
+/* Return NULL on error. */
static char *cappend(char *in, char *app) {
- int inlen;
+ int inlen, aplen;
char *rv;
inlen = strlen(in);
+ aplen = strlen(app);
- if ((rv = malloc(inlen + 1 + strlen(app) + 1)) == NULL) {
+ if ((rv = malloc(inlen + 1 + aplen + 1)) == NULL) {
a1loge(g_log, 1, "xdg_bds: cappend malloc failed\n");
free(in);
return NULL;
}
strcpy(rv, in);
- if (inlen > 1)
+ if (inlen > 0 && in[inlen-1] != SSEP && aplen > 0)
strcat(rv, SSEPS);
strcat(rv, app);
free(in);
@@ -190,20 +192,22 @@ static char *cappend(char *in, char *app) {
return rv;
}
-/* Append a '/' then a string. Free in. Return NULL on error. */
+/* Append a '/' then a string. Free in. */
+/* Return NULL on error. */
static char *dappend(char *in, char *app) {
- int inlen;
+ int inlen, aplen;
char *rv;
inlen = strlen(in);
+ aplen = strlen(app);
- if ((rv = malloc(inlen + 1 + strlen(app) + 1)) == NULL) {
+ if ((rv = malloc(inlen + 1 + aplen + 1)) == NULL) {
a1loge(g_log, 1, "xdg_bds: dappend malloc failed\n");
free(in);
return NULL;
}
strcpy(rv, in);
- if (inlen > 1 && in[inlen-1] != '/')
+ if (inlen > 0 && in[inlen-1] != '/')
strcat(rv, "/");
strcat(rv, app);
free(in);
@@ -332,7 +336,7 @@ int xdg_bds(
if (getenv("HOME") != NULL)
path = dappend(path, ".local/share");
#else
-#ifdef __APPLE__
+#ifdef UNIX_APPLE
path = dappend(path, "Library/Application Support");
#else /* Unix, Default */
path = dappend(path, ".local/share");
@@ -380,7 +384,7 @@ int xdg_bds(
if (getenv("HOME") != NULL)
path = dappend(path, ".config");
#else
-#ifdef __APPLE__
+#ifdef UNIX_APPLE
path = dappend(path, "Library/Preferences");
#else /* Unix, Default */
path = dappend(path, ".config");
@@ -435,7 +439,7 @@ int xdg_bds(
else
path = dappend(path, "Cache");
#else
-#ifdef __APPLE__
+#ifdef UNIX_APPLE
path = dappend(path, "Library/Caches");
#else /* Unix, Default */
path = dappend(path, ".cache");
@@ -477,7 +481,7 @@ int xdg_bds(
}
path = cappend(path, home);
#else
-#ifdef __APPLE__
+#ifdef UNIX_APPLE
path = cappend(path, "/Library");
#else
path = cappend(path, "/usr/local/share:/usr/share");
@@ -508,7 +512,7 @@ int xdg_bds(
}
path = cappend(path, home);
#else
-#ifdef __APPLE__
+#ifdef UNIX_APPLE
path = cappend(path, "/Library/Preferences");
#else
path = cappend(path, "/etc/xdg");