forked from enlightenment/efl
parent
434759396a
commit
3db40c0d97
|
@ -29,7 +29,7 @@ static Eina_Hash *paths = NULL;
|
|||
static int
|
||||
strcmplen(const void *data1, const void *data2)
|
||||
{
|
||||
return strncmp(data1, data2, strlen(data2));
|
||||
return strncmp(data1, data2, eina_stringshare_strlen(data2));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -187,6 +187,7 @@ main()
|
|||
int priority = 0;
|
||||
char *dir = NULL;
|
||||
char *map = MAP_FAILED;
|
||||
char *path;
|
||||
int fd = -1, tmpfd, dirsfd = -1;
|
||||
struct stat st;
|
||||
int changed = 0;
|
||||
|
@ -258,7 +259,7 @@ main()
|
|||
{
|
||||
unsigned int size = *(unsigned int *)p;
|
||||
p += sizeof(unsigned int);
|
||||
user_dirs = eina_list_append(user_dirs, strdup(p));
|
||||
user_dirs = eina_list_append(user_dirs, eina_stringshare_add(p));
|
||||
p += size;
|
||||
}
|
||||
munmap(map, st.st_size);
|
||||
|
@ -266,25 +267,19 @@ main()
|
|||
if (ftruncate(dirsfd, 0) < 0) goto error;
|
||||
}
|
||||
|
||||
while (dirs)
|
||||
EINA_LIST_FREE(dirs, path)
|
||||
{
|
||||
char file_id[PATH_MAX] = { '\0' };
|
||||
char *path;
|
||||
Eina_List *l;
|
||||
|
||||
path = eina_list_data_get(dirs);
|
||||
if (path)
|
||||
if (!cache_scan(path, file_id, priority++, 1, &changed)) goto error;
|
||||
l = eina_list_search_unsorted_list(user_dirs, strcmplen, path);
|
||||
if (l)
|
||||
{
|
||||
if (!cache_scan(path, file_id, priority++, 1, &changed)) goto error;
|
||||
l = eina_list_search_unsorted_list(user_dirs, strcmplen, path);
|
||||
if (l)
|
||||
{
|
||||
free(eina_list_data_get(l));
|
||||
user_dirs = eina_list_remove_list(user_dirs, l);
|
||||
}
|
||||
free(path);
|
||||
eina_stringshare_del(eina_list_data_get(l));
|
||||
user_dirs = eina_list_remove_list(user_dirs, l);
|
||||
}
|
||||
dirs = eina_list_remove_list(dirs, dirs);
|
||||
eina_stringshare_del(path);
|
||||
}
|
||||
EINA_LIST_FREE(user_dirs, dir)
|
||||
{
|
||||
|
@ -295,7 +290,7 @@ main()
|
|||
write(dirsfd, dir, size);
|
||||
}
|
||||
if (!cache_scan(dir, NULL, priority, 0, &changed)) goto error;
|
||||
free(dir);
|
||||
eina_stringshare_del(dir);
|
||||
}
|
||||
eina_hash_free(file_ids);
|
||||
eina_hash_free(paths);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "Efreet.h"
|
||||
#include "efreet_private.h"
|
||||
|
@ -196,12 +197,13 @@ static int
|
|||
efreet_parse_locale_setting(const char *env)
|
||||
{
|
||||
int found = 0;
|
||||
char *setting;
|
||||
char setting[PATH_MAX];
|
||||
char *p;
|
||||
|
||||
setting = getenv(env);
|
||||
if (!setting) return 0;
|
||||
setting = strdup(setting);
|
||||
p = getenv(env);
|
||||
if (!p) return 0;
|
||||
strncpy(setting, p, sizeof(setting));
|
||||
setting[PATH_MAX - 1] = '\0';
|
||||
|
||||
/* pull the modifier off the end */
|
||||
p = strrchr(setting, '@');
|
||||
|
@ -225,14 +227,12 @@ efreet_parse_locale_setting(const char *env)
|
|||
found = 1;
|
||||
}
|
||||
|
||||
if (setting && (*setting != '\0'))
|
||||
if (*setting != '\0')
|
||||
{
|
||||
efreet_lang = eina_stringshare_add(setting);
|
||||
found = 1;
|
||||
}
|
||||
|
||||
FREE(setting);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "Efreet.h"
|
||||
#include "efreet_private.h"
|
||||
|
@ -225,14 +226,15 @@ efreet_dirs_get(const char *key, const char *fallback)
|
|||
{
|
||||
Eina_List *dirs = NULL;
|
||||
const char *path;
|
||||
char *tmp, *s, *p;
|
||||
char tmp[PATH_MAX], *s, *p;
|
||||
|
||||
path = getenv(key);
|
||||
if (!path || (path[0] == '\0')) path = fallback;
|
||||
|
||||
if (!path) return dirs;
|
||||
|
||||
tmp = strdup(path);
|
||||
strncpy(tmp, path, sizeof(tmp));
|
||||
tmp[PATH_MAX - 1] = '\0';
|
||||
s = tmp;
|
||||
p = strchr(s, EFREET_PATH_SEP);
|
||||
while (p)
|
||||
|
@ -246,7 +248,6 @@ efreet_dirs_get(const char *key, const char *fallback)
|
|||
}
|
||||
if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s))
|
||||
dirs = eina_list_append(dirs, (void *)eina_stringshare_add(s));
|
||||
FREE(tmp);
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ struct Efreet_Menu_Desktop
|
|||
static const char *efreet_menu_prefix = NULL; /**< The $XDG_MENU_PREFIX env var */
|
||||
Eina_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for KDELegacy entries */
|
||||
static const char *efreet_tag_menu = NULL;
|
||||
static char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */
|
||||
static const char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */
|
||||
|
||||
static Eina_Hash *efreet_merged_menus = NULL;
|
||||
static Eina_Hash *efreet_merged_dirs = NULL;
|
||||
|
@ -580,7 +580,7 @@ efreet_menu_kde_legacy_init(void)
|
|||
void
|
||||
efreet_menu_shutdown(void)
|
||||
{
|
||||
IF_FREE(efreet_menu_file);
|
||||
IF_RELEASE(efreet_menu_file);
|
||||
|
||||
IF_FREE_HASH(efreet_menu_handle_cbs);
|
||||
IF_FREE_HASH(efreet_menu_filter_cbs);
|
||||
|
@ -623,9 +623,9 @@ efreet_menu_new(const char *name)
|
|||
EAPI void
|
||||
efreet_menu_file_set(const char *file)
|
||||
{
|
||||
IF_FREE(efreet_menu_file);
|
||||
IF_RELEASE(efreet_menu_file);
|
||||
efreet_menu_file = NULL;
|
||||
if (file) efreet_menu_file = strdup(file);
|
||||
if (file) efreet_menu_file = eina_stringshare_add(file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -990,12 +990,12 @@ efreet_default_dirs_get(const char *user_dir, Eina_List *system_dirs,
|
|||
Eina_List *l;
|
||||
|
||||
snprintf(dir, sizeof(dir), "%s/%s", user_dir, suffix);
|
||||
list = eina_list_append(list, strdup(dir));
|
||||
list = eina_list_append(list, eina_stringshare_add(dir));
|
||||
|
||||
EINA_LIST_FOREACH(system_dirs, l, xdg_dir)
|
||||
{
|
||||
snprintf(dir, sizeof(dir), "%s/%s", xdg_dir, suffix);
|
||||
list = eina_list_append(list, strdup(dir));
|
||||
list = eina_list_append(list, eina_stringshare_add(dir));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -1203,19 +1203,19 @@ efreet_menu_handle_default_app_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xm
|
|||
"applications");
|
||||
EINA_LIST_FREE(dirs, dir)
|
||||
{
|
||||
Efreet_Menu_App_Dir *app_dir;
|
||||
if (!eina_list_search_unsorted(parent->app_dirs,
|
||||
EINA_COMPARE_CB(efreet_menu_cb_app_dirs_compare),
|
||||
dir))
|
||||
{
|
||||
Efreet_Menu_App_Dir *app_dir;
|
||||
|
||||
if (eina_list_search_unsorted(parent->app_dirs,
|
||||
EINA_COMPARE_CB(efreet_menu_cb_app_dirs_compare),
|
||||
dir))
|
||||
continue;
|
||||
app_dir = efreet_menu_app_dir_new();
|
||||
app_dir->path = strdup(dir);
|
||||
|
||||
app_dir = efreet_menu_app_dir_new();
|
||||
app_dir->path = strdup(dir);
|
||||
prepend = eina_list_append(prepend, app_dir);
|
||||
}
|
||||
|
||||
prepend = eina_list_append(prepend, app_dir);
|
||||
|
||||
free(dir);
|
||||
eina_stringshare_del(dir);
|
||||
}
|
||||
parent->app_dirs = eina_list_merge(prepend, parent->app_dirs);
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ efreet_menu_handle_directory_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
|
|||
static int
|
||||
efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__)
|
||||
{
|
||||
Eina_List *dirs, *l;
|
||||
Eina_List *dirs;
|
||||
char *dir;
|
||||
|
||||
if (!parent) return 0;
|
||||
|
@ -1270,18 +1270,11 @@ efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_X
|
|||
efreet_menu_create_directory_dirs_list(parent);
|
||||
dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
|
||||
"desktop-directories");
|
||||
EINA_LIST_FOREACH(dirs, l, dir)
|
||||
EINA_LIST_FREE(dirs, dir)
|
||||
{
|
||||
if (eina_list_search_unsorted(parent->directory_dirs, EINA_COMPARE_CB(strcmp), dir))
|
||||
continue;
|
||||
|
||||
parent->directory_dirs = eina_list_prepend(parent->directory_dirs, strdup(dir));
|
||||
}
|
||||
|
||||
while (dirs)
|
||||
{
|
||||
free(eina_list_data_get(dirs));
|
||||
dirs = eina_list_remove_list(dirs, dirs);
|
||||
if (!eina_list_search_unsorted(parent->directory_dirs, EINA_COMPARE_CB(strcmp), dir))
|
||||
parent->directory_dirs = eina_list_prepend(parent->directory_dirs, strdup(dir));
|
||||
eina_stringshare_del(dir);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1817,11 +1810,10 @@ efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *
|
|||
dirs = efreet_default_dirs_get(efreet_config_home_get(),
|
||||
efreet_config_dirs_get(), path);
|
||||
|
||||
while ((p = eina_list_data_get(dirs)))
|
||||
EINA_LIST_FREE(dirs, p)
|
||||
{
|
||||
dirs = eina_list_remove_list(dirs, dirs);
|
||||
efreet_menu_merge_dir(parent, xml, p);
|
||||
FREE(p);
|
||||
eina_stringshare_del(p);
|
||||
}
|
||||
#ifndef STRICT_SPEC
|
||||
/* Also check the path of the parent file */
|
||||
|
|
|
@ -114,7 +114,7 @@ efreet_util_path_in_default(const char *section, const char *path)
|
|||
if (!strncmp(path, dir, strlen(dir)))
|
||||
ret = dir;
|
||||
else
|
||||
free(dir);
|
||||
eina_stringshare_del(dir);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -124,7 +124,7 @@ EAPI const char *
|
|||
efreet_util_path_to_file_id(const char *path)
|
||||
{
|
||||
size_t len;
|
||||
char *tmp, *p;
|
||||
char tmp[PATH_MAX], *p;
|
||||
char *base;
|
||||
const char *file_id;
|
||||
|
||||
|
@ -139,25 +139,25 @@ efreet_util_path_to_file_id(const char *path)
|
|||
len = strlen(base);
|
||||
if (strlen(path) <= len)
|
||||
{
|
||||
free(base);
|
||||
eina_stringshare_del(base);
|
||||
return NULL;
|
||||
}
|
||||
if (strncmp(path, base, len))
|
||||
{
|
||||
free(base);
|
||||
eina_stringshare_del(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmp = strdup(path + len + 1);
|
||||
strncpy(tmp, path + len + 1, sizeof(tmp));
|
||||
tmp[PATH_MAX - 1] = '\0';
|
||||
p = tmp;
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '/') *p = '-';
|
||||
p++;
|
||||
}
|
||||
free(base);
|
||||
eina_stringshare_del(base);
|
||||
file_id = eina_stringshare_add(tmp);
|
||||
free(tmp);
|
||||
eina_hash_del(file_id_by_desktop_path, path, NULL);
|
||||
eina_hash_add(file_id_by_desktop_path, path, (void *)file_id);
|
||||
return file_id;
|
||||
|
|
Loading…
Reference in New Issue