diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 733219d98..375238ffb 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -116,6 +116,20 @@ EAPI Eina_Bool e_nopause = EINA_FALSE; EINTERN const char *e_first_frame = NULL; EINTERN double e_first_frame_start_time = -1; +static Eina_Bool +_xdg_check_str(const char *env, const char *str) +{ + const char *p; + size_t len; + + len = strlen(str); + for (p = strstr(env, str); p; p++, p = strstr(p, str)) + { + if ((!p[len]) || (p[len] == ':')) return EINA_TRUE; + } + return EINA_FALSE; +} + static void _xdg_data_dirs_augment(void) { @@ -126,18 +140,27 @@ _xdg_data_dirs_augment(void) if (!p) return; s = getenv("XDG_DATA_DIRS"); - snprintf(newpath, sizeof(newpath), "%s:%s/share", e_prefix_data_get(), p); if (s) { - if (strncmp(s, newpath, strlen(newpath))) + Eina_Bool pfxdata, pfx; + + pfxdata = !_xdg_check_str(s, e_prefix_data_get()); + snprintf(newpath, sizeof(newpath), "%s/share", p); + pfx = !_xdg_check_str(s, newpath); + if (pfxdata || pfx) { - snprintf(buf, sizeof(buf), "%s:%s", newpath, s); + snprintf(buf, sizeof(buf), "%s%s%s%s%s", + pfxdata ? e_prefix_data_get() : "", + pfxdata ? ":" : "", + pfx ? newpath : "", + pfx ? ":" : "", + s); e_util_env_set("XDG_DATA_DIRS", buf); } } else { - snprintf(buf, sizeof(buf), "%s:/usr/local/share:/usr/share", newpath); + snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p); e_util_env_set("XDG_DATA_DIRS", buf); } @@ -145,7 +168,7 @@ _xdg_data_dirs_augment(void) snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p); if (s) { - if (strncmp(s, newpath, strlen(newpath))) + if (!_xdg_check_str(s, newpath)) { snprintf(buf, sizeof(buf), "%s:%s", newpath, s); e_util_env_set("XDG_CONFIG_DIRS", buf);