diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-10-02 19:25:17 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-10-02 19:25:17 +0200 |
commit | c2ca7be5a751879159f3cb591a64bb9568b79762 (patch) | |
tree | 04e38d4f4a2aad4d789bda0a65b7abb80a3439a2 /spectro/xdg_bds.c | |
parent | 45c152c326d87478fbf41714b4b8e2f7b57a282b (diff) | |
parent | 3db384424bd7398ffbb7a355cab8f15f3add009f (diff) |
Updated version 1.9.1+repack from 'upstream/1.9.1+repack'
with Debian dir 98a996367aa69ae41accf9c6d369f600bc94de80
Diffstat (limited to 'spectro/xdg_bds.c')
-rw-r--r-- | spectro/xdg_bds.c | 30 |
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"); |