Eina: use eina_fnmatch() instead of fnmatch()

Reviewers: raster

Reviewed By: raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12262
This commit is contained in:
Vincent Torri 2021-05-03 18:48:24 +01:00 committed by Carsten Haitzler (Rasterman)
parent 84e907ef7d
commit de296b13c8
15 changed files with 37 additions and 57 deletions

View File

@ -3,7 +3,6 @@
#endif
#include <locale.h>
#include <fnmatch.h>
#include <Ecore.h>
#include <Ecore_Getopt.h>
@ -56,7 +55,7 @@ module_matches(const char *name)
if (!module_patterns) return EINA_TRUE;
for (itr = module_patterns; *itr != NULL; itr++)
if (fnmatch(*itr, name, 0) == 0) return EINA_TRUE;
if (eina_fnmatch(*itr, name, 0)) return EINA_TRUE;
return EINA_FALSE;
}
@ -65,7 +64,7 @@ static inline Eina_Bool
type_matches(const char *name)
{
if (!type_glob) return EINA_TRUE;
return fnmatch(type_glob, name, 0) == 0;
return eina_fnmatch(type_glob, name, 0);
}
static int

View File

@ -3,7 +3,6 @@
#endif
#include <locale.h>
#include <fnmatch.h>
#include <unistd.h>
#include <errno.h>
@ -101,7 +100,7 @@ static inline Eina_Bool
matches(const char *name, const char *pattern)
{
if (!pattern) return EINA_TRUE;
return fnmatch(pattern, name, 0) == 0;
return eina_fnmatch(pattern, name, 0);
}
static void

View File

@ -15,7 +15,6 @@
#include <sys/stat.h>
#include <sys/select.h>
#include <fcntl.h>
#include <fnmatch.h>
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
@ -648,7 +647,7 @@ glob_match(const char *glob, const char *str)
{
if (!glob) return EINA_TRUE;
if (!str) return EINA_FALSE;
if (!fnmatch(glob, str, 0)) return EINA_TRUE;
if (eina_fnmatch(glob, str, 0)) return EINA_TRUE;
return EINA_FALSE;
}

View File

@ -9,7 +9,6 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <fnmatch.h>
#include <fcntl.h>
#include <Eina.h>
@ -2607,7 +2606,7 @@ eet_list(Eet_File *ef,
* check for * explicitly, because on some systems, * isn't well
* supported
*/
if ((!glob) || !fnmatch(glob, efn->name, 0))
if ((!glob) || eina_fnmatch(glob, efn->name, 0))
{
/* add it to our list */
list_count++;

View File

@ -6,7 +6,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <fnmatch.h>
#include <Ecore.h>
#include <Ecore_File.h>
@ -1237,7 +1236,7 @@ efreet_mime_glob_match(const char *str, const char *glob)
if (str[0] == 0) return 1;
return 0;
}
if (!fnmatch(glob, str, 0)) return 1;
if (eina_fnmatch(glob, str, 0)) return 1;
return 0;
}
@ -1263,7 +1262,7 @@ efreet_mime_glob_case_match(char *str, const char *glob)
tglob = alloca(strlen(glob) + 1);
for (tp = tglob, p = glob; *p; p++, tp++) *tp = tolower(*p);
*tp = 0;
if (!fnmatch(str, tglob, 0)) return 1;
if (eina_fnmatch(str, tglob, 0)) return 1;
return 0;
}

View File

@ -4,7 +4,6 @@
/* TODO: add no_display check, as we might want only displayable items */
#include <fnmatch.h>
#include <ctype.h>
#include <Ecore_File.h>
@ -450,7 +449,7 @@ efreet_util_glob_match(const char *str, const char *glob)
return 0;
}
if (!strcmp(glob, "*")) return 1;
if (!fnmatch(glob, str, 0)) return 1;
if (eina_fnmatch(glob, str, 0)) return 1;
return 0;
}

View File

@ -25,7 +25,6 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fnmatch.h>
#include <assert.h>
#include <errno.h>
@ -45,6 +44,7 @@
#include "eina_config.h"
#include "eina_private.h"
#include "eina_fnmatch.h"
#include "eina_inlist.h"
#include "eina_lock.h"
#include "eina_thread.h"
@ -1280,7 +1280,7 @@ finish_register:
{
EINA_INLIST_FOREACH(_glob_list, pending)
{
if (!fnmatch(pending->name, name, 0))
if (eina_fnmatch(pending->name, name, 0))
{
_log_domains[i].level = pending->level;
break;
@ -1996,7 +1996,7 @@ eina_log_domain_level_get(const char *domain_name)
EINA_INLIST_FOREACH(_glob_list, pending)
{
if (!fnmatch(pending->name, domain_name, 0))
if (eina_fnmatch(pending->name, domain_name, 0))
return pending->level;
}

View File

@ -14,7 +14,6 @@
#include <sys/time.h>
#include <sys/param.h>
#include <math.h>
#include <fnmatch.h>
#include <limits.h>
#include <ctype.h>
#include <time.h>

View File

@ -20,7 +20,6 @@
#include <sys/time.h>
#include <sys/param.h>
#include <math.h>
#include <fnmatch.h>
#include <limits.h>
#include <ctype.h>
#include <time.h>

View File

@ -418,12 +418,10 @@ _elm_gengrid_search_by_text_item_get(Eo *obj EINA_UNUSED,
if (!pattern) return NULL;
if (!sd->items) return NULL;
if (flags & ELM_GLOB_MATCH_NO_ESCAPE) fnflags |= FNM_NOESCAPE;
if (flags & ELM_GLOB_MATCH_PATH) fnflags |= FNM_PATHNAME;
if (flags & ELM_GLOB_MATCH_PERIOD) fnflags |= FNM_PERIOD;
#ifdef FNM_CASEFOLD
if (flags & ELM_GLOB_MATCH_NOCASE) fnflags |= FNM_CASEFOLD;
#endif
if (flags & ELM_GLOB_MATCH_NO_ESCAPE) fnflags |= EINA_FNMATCH_NOESCAPE;
if (flags & ELM_GLOB_MATCH_PATH) fnflags |= EINA_FNMATCH_PATHNAME;
if (flags & ELM_GLOB_MATCH_PERIOD) fnflags |= EINA_FNMATCH_PERIOD;
if (flags & ELM_GLOB_MATCH_NOCASE) fnflags |= EINA_FNMATCH_CASEFOLD;
ELM_GENGRID_ITEM_DATA_GET(eo_item_to_search_from, item_to_search_from);
start = (item_to_search_from) ?
@ -435,7 +433,7 @@ _elm_gengrid_search_by_text_item_get(Eo *obj EINA_UNUSED,
str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)),
WIDGET(it), part_name ? part_name : "elm.text");
if (!str) continue;
if (!fnmatch(pattern, str, fnflags))
if (eina_fnmatch(pattern, str, fnflags))
{
free(str);
return EO_OBJ(it);
@ -1021,7 +1019,7 @@ _item_text_realize(Elm_Gen_Item *it,
(edje_object_data_get(target, "texts"));
EINA_LIST_FOREACH(*source, l, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD)) continue;
s = it->itc->func.text_get
((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@ -1070,7 +1068,7 @@ _item_content_realize(Elm_Gen_Item *it,
EINA_LIST_FREE(source, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD))
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD))
continue;
Evas_Object *old = edje_object_part_swallow_get(target, key);
@ -1137,7 +1135,7 @@ _item_state_realize(Elm_Gen_Item *it, Evas_Object *target, const char *parts)
src = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
EINA_LIST_FREE(src, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD)) continue;
Eina_Bool on = it->itc->func.state_get
((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);

View File

@ -2,8 +2,6 @@
# include "elementary_config.h"
#endif
#include <fnmatch.h>
#define EFL_ACCESS_OBJECT_PROTECTED
#define EFL_ACCESS_SELECTION_PROTECTED
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
@ -347,7 +345,7 @@ _item_text_realize(Elm_Gen_Item *it,
(edje_object_data_get(target, "texts"));
EINA_LIST_FOREACH(*source, l, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD)) continue;
s = it->itc->func.text_get
((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@ -423,7 +421,7 @@ _item_content_realize(Elm_Gen_Item *it,
EINA_LIST_FREE(source, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD))
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD))
continue;
Evas_Object *old = NULL;
@ -505,7 +503,7 @@ _item_state_realize(Elm_Gen_Item *it, Evas_Object *target, const char *parts)
src = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
EINA_LIST_FREE(src, key)
{
if (parts && fnmatch(parts, key, FNM_PERIOD)) continue;
if (parts && !eina_fnmatch(parts, key, EINA_FNMATCH_PERIOD)) continue;
Eina_Bool on = it->itc->func.state_get
((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@ -8746,12 +8744,10 @@ _elm_genlist_search_by_text_item_get(Eo *obj EINA_UNUSED,
if (!pattern) return NULL;
if (!sd->items) return NULL;
if (flags & ELM_GLOB_MATCH_NO_ESCAPE) fnflags |= FNM_NOESCAPE;
if (flags & ELM_GLOB_MATCH_PATH) fnflags |= FNM_PATHNAME;
if (flags & ELM_GLOB_MATCH_PERIOD) fnflags |= FNM_PERIOD;
#ifdef FNM_CASEFOLD
if (flags & ELM_GLOB_MATCH_NOCASE) fnflags |= FNM_CASEFOLD;
#endif
if (flags & ELM_GLOB_MATCH_NO_ESCAPE) fnflags |= EINA_FNMATCH_NOESCAPE;
if (flags & ELM_GLOB_MATCH_PATH) fnflags |= EINA_FNMATCH_PATHNAME;
if (flags & ELM_GLOB_MATCH_PERIOD) fnflags |= EINA_FNMATCH_PERIOD;
if (flags & ELM_GLOB_MATCH_NOCASE) fnflags |= EINA_FNMATCH_CASEFOLD;
start = (item_to_search_from) ?
EINA_INLIST_GET((Elm_Gen_Item *)efl_data_scope_get(item_to_search_from, ELM_GENLIST_ITEM_CLASS)) :
@ -8761,7 +8757,7 @@ _elm_genlist_search_by_text_item_get(Eo *obj EINA_UNUSED,
if (!it->itc->func.text_get) continue;
str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), part_name);
if (!str) continue;
if (!fnmatch(pattern, str, fnflags))
if (eina_fnmatch(pattern, str, fnflags))
{
free(str);
return EO_OBJ(it);

View File

@ -14,7 +14,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fnmatch.h>
#include <Eina.h>
@ -61,7 +60,7 @@ _embryo_str_fnmatch(Embryo_Program *ep, Embryo_Cell *params)
STRGET(ep, s1, params[1]);
STRGET(ep, s2, params[2]);
if ((!s1) || (!s2)) return -1;
return (Embryo_Cell)fnmatch(s1, s2, 0);
return (Embryo_Cell)!eina_fnmatch(s1, s2, 0);
}
static Embryo_Cell

View File

@ -3,7 +3,6 @@
#endif
#include <Eina.h>
#include <fnmatch.h>
#include <Eo.h>
@ -545,7 +544,7 @@ _name_match(const char *match, Eina_Bool is_glob, const char *str)
// if match string is "*" special case it and match
if ((match[0] == '*') && (match[1] == 0)) return EINA_TRUE;
// actual compare
if (!fnmatch(match, str, 0)) return EINA_TRUE;
if (eina_fnmatch(match, str, 0)) return EINA_TRUE;
}
else
{

View File

@ -65,7 +65,6 @@ static FcConfig *fc_config = NULL;
/* FIXME move these helper function to eina_file or eina_path */
/* get the casefold feature! */
#include <fnmatch.h>
#include <unistd.h>
#include <sys/param.h>
int
@ -99,11 +98,10 @@ _file_path_list(char *path, const char *match, int match_case)
Eina_List *files = NULL;
int flags;
flags = FNM_PATHNAME;
#ifdef FNM_CASEFOLD
flags = EINA_FNMATCH_PATHNAME;
if (!match_case)
flags |= FNM_CASEFOLD;
#elif defined FNM_IGNORECASE
flags |= EINA_FNMATCH_CASEFOLD;
#if defined FNM_IGNORECASE
if (!match_case)
flags |= FNM_IGNORECASE;
#else
@ -115,7 +113,7 @@ _file_path_list(char *path, const char *match, int match_case)
{
if (match)
{
if (fnmatch(match, info->path + info->name_start, flags) == 0)
if (eina_fnmatch(match, info->path + info->name_start, flags))
files = eina_list_append(files, strdup(info->path + info->name_start));
}
else

View File

@ -12,7 +12,6 @@
#include <sys/types.h>
#include <sys/stat.h>
/* get the casefold feature! */
#include <fnmatch.h>
#include <unistd.h>
#include <sys/param.h>
@ -98,11 +97,10 @@ evas_file_path_list(char *path, const char *match, int match_case)
Eina_List *files = NULL;
int flags;
flags = FNM_PATHNAME;
#ifdef FNM_CASEFOLD
flags = EINA_FNMATCH_PATHNAME;
if (!match_case)
flags |= FNM_CASEFOLD;
#elif defined FNM_IGNORECASE
flags |= EINA_FNMATCH_CASEFOLD;
#if defined FNM_IGNORECASE
if (!match_case)
flags |= FNM_IGNORECASE;
#else
@ -114,7 +112,7 @@ evas_file_path_list(char *path, const char *match, int match_case)
{
if (match)
{
if (fnmatch(match, info->path + info->name_start, flags) == 0)
if (eina_fnmatch(match, info->path + info->name_start, flags))
files = eina_list_append(files, strdup(info->path + info->name_start));
}
else