summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-01-25 12:44:09 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-01-25 12:44:09 +0100
commit762d4fb551529421df2c2b37efdc7d462f3359b6 (patch)
tree2d51207f459b35773696ad030ffcd7927e1628b3 /src/lib/efreet
parent546d87c8b5de547a6ecbe579a08910981deac8a0 (diff)
Efreet: do not get confused by path ending with / in XDG_* vars
This @fix the parsing of dirs from the xdg env vars. Now always remove the leading / char from the paths. This was causing lots of trouble on my system, where XDG_DATA_DIRS is: /usr/local/share/enlightenment:/usr/local/share:/usr/local/share/:/usr/share/ At first /usr/local/share was added 2 times in the list, one with the / and one witout, causing a double lookup for each file. Secondly the icon cache was totally unusable as the cached paths ended up as: /usr/share//icons/Mint-X/places/32/folder.svg. The double / in there was making the cache lookup to fail and anways return the biggest icon available. Causing a big system slowdown whe searching for icons. As a bonus the function now use eina_str_split instead of the custom splitting code that require a bad special handling for the last item.
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_base.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c
index 3e681874c7..ba7a7e8225 100644
--- a/src/lib/efreet/efreet_base.c
+++ b/src/lib/efreet/efreet_base.c
@@ -379,8 +379,9 @@ efreet_dirs_get(const char *key, const char *fallback)
379{ 379{
380 Eina_List *dirs = NULL; 380 Eina_List *dirs = NULL;
381 const char *path = NULL; 381 const char *path = NULL;
382 char *s, *p; 382 char *s, **split;
383 size_t len; 383 char sep[2] = {EFREET_PATH_SEP, '\0'};
384 size_t len, i;
384 385
385#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 386#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
386 if (getuid() == geteuid()) 387 if (getuid() == geteuid())
@@ -390,13 +391,17 @@ efreet_dirs_get(const char *key, const char *fallback)
390 391
391 if (!path) return dirs; 392 if (!path) return dirs;
392 393
393 len = strlen(path) + 1; 394 split = eina_str_split(path, sep, 0);
394 s = alloca(len); 395 for (i = 0; split[i]; i++)
395 memcpy(s, path, len);
396 p = strchr(s, EFREET_PATH_SEP);
397 while (p)
398 { 396 {
399 *p = '\0'; 397 s = split[i];
398
399 // ensure the dir not end with '/'
400 len = strlen(s);
401 if ((len > 2) && (s[len-1] == '/'))
402 s[len-1] = '\0';
403
404 // add the dir to the list, if not yet there
400 if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s)) 405 if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s))
401 { 406 {
402 char *tmp = eina_file_path_sanitize(s); 407 char *tmp = eina_file_path_sanitize(s);
@@ -406,20 +411,10 @@ efreet_dirs_get(const char *key, const char *fallback)
406 free(tmp); 411 free(tmp);
407 } 412 }
408 } 413 }
409
410 s = ++p;
411 p = strchr(s, EFREET_PATH_SEP);
412 }
413 if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s))
414 {
415 char *tmp = eina_file_path_sanitize(s);
416 if (tmp)
417 {
418 dirs = eina_list_append(dirs, eina_stringshare_add(tmp));
419 free(tmp);
420 }
421 } 414 }
422 415
416 free(split[0]);
417 free(split);
423 return dirs; 418 return dirs;
424} 419}
425 420