summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJoão Antônio Cardoso <joao.maker@gmail.com>2020-04-15 15:39:50 -0300
committerFelipe Magno de Almeida <felipe@expertise.dev>2020-05-04 22:28:13 -0300
commit64964ed930ada3554fbf651940c09b3a77a8a6a2 (patch)
tree11f8ebf34a12c42c0d9842d84c6135e688043ba1 /src/lib
parentcb1b57ec6a51faf029b1441713e2b357585436f0 (diff)
windows: Add fnmatch win32 implementation
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_x/ecore_x_vsync.c4
-rw-r--r--src/lib/eet/eet_lib.c3
-rw-r--r--src/lib/efreet/efreet_mime.c6
-rw-r--r--src/lib/efreet/efreet_utils.c4
-rw-r--r--src/lib/eina/Eina.h1
-rw-r--r--src/lib/eina/eina_fnmatch.c249
-rw-r--r--src/lib/eina/eina_fnmatch.h37
-rw-r--r--src/lib/eina/eina_log.c6
-rw-r--r--src/lib/eina/eina_main.c1
-rw-r--r--src/lib/eina/meson.build6
-rw-r--r--src/lib/elementary/Efl_Ui.h2
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/elm_gengrid.c8
-rw-r--r--src/lib/elementary/elm_genlist.c10
-rw-r--r--src/lib/embryo/embryo_str.c4
-rw-r--r--src/lib/eo/eo_base_class.c3
-rw-r--r--src/lib/evas/canvas/evas_font_dir.c4
-rw-r--r--src/lib/evas/file/evas_path.c4
-rw-r--r--src/lib/evil/unposix/fnmatch.h23
-rw-r--r--src/lib/evil/unposix/meson.build5
20 files changed, 322 insertions, 59 deletions
diff --git a/src/lib/ecore_x/ecore_x_vsync.c b/src/lib/ecore_x/ecore_x_vsync.c
index e002e48302..79f5892007 100644
--- a/src/lib/ecore_x/ecore_x_vsync.c
+++ b/src/lib/ecore_x/ecore_x_vsync.c
@@ -15,7 +15,7 @@
15#include <sys/stat.h> 15#include <sys/stat.h>
16#include <sys/select.h> 16#include <sys/select.h>
17#include <fcntl.h> 17#include <fcntl.h>
18#include <fnmatch.h> 18#include <Eina.h>
19 19
20#ifdef HAVE_PRCTL 20#ifdef HAVE_PRCTL
21# include <sys/prctl.h> 21# include <sys/prctl.h>
@@ -457,7 +457,7 @@ glob_match(const char *glob, const char *str)
457{ 457{
458 if (!glob) return EINA_TRUE; 458 if (!glob) return EINA_TRUE;
459 if (!str) return EINA_FALSE; 459 if (!str) return EINA_FALSE;
460 if (!fnmatch(glob, str, 0)) return EINA_TRUE; 460 if (!eina_fnmatch(glob, str, 0)) return EINA_TRUE;
461 return EINA_FALSE; 461 return EINA_FALSE;
462} 462}
463 463
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 0e05b2acaf..957ad95035 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -9,7 +9,6 @@
9#include <time.h> 9#include <time.h>
10#include <string.h> 10#include <string.h>
11#include <unistd.h> 11#include <unistd.h>
12#include <fnmatch.h>
13#include <fcntl.h> 12#include <fcntl.h>
14 13
15#include <Eina.h> 14#include <Eina.h>
@@ -2607,7 +2606,7 @@ eet_list(Eet_File *ef,
2607 * check for * explicitly, because on some systems, * isn't well 2606 * check for * explicitly, because on some systems, * isn't well
2608 * supported 2607 * supported
2609 */ 2608 */
2610 if ((!glob) || !fnmatch(glob, efn->name, 0)) 2609 if ((!glob) || !eina_fnmatch(glob, efn->name, 0))
2611 { 2610 {
2612 /* add it to our list */ 2611 /* add it to our list */
2613 list_count++; 2612 list_count++;
diff --git a/src/lib/efreet/efreet_mime.c b/src/lib/efreet/efreet_mime.c
index 9eba8c8db9..b936439635 100644
--- a/src/lib/efreet/efreet_mime.c
+++ b/src/lib/efreet/efreet_mime.c
@@ -6,7 +6,7 @@
6#include <sys/stat.h> 6#include <sys/stat.h>
7#include <fcntl.h> 7#include <fcntl.h>
8#include <unistd.h> 8#include <unistd.h>
9#include <fnmatch.h> 9#include <Eina.h>
10 10
11#include <Ecore.h> 11#include <Ecore.h>
12#include <Ecore_File.h> 12#include <Ecore_File.h>
@@ -1243,7 +1243,7 @@ efreet_mime_glob_match(const char *str, const char *glob)
1243 if (str[0] == 0) return 1; 1243 if (str[0] == 0) return 1;
1244 return 0; 1244 return 0;
1245 } 1245 }
1246 if (!fnmatch(glob, str, 0)) return 1; 1246 if (!eina_fnmatch(glob, str, 0)) return 1;
1247 return 0; 1247 return 0;
1248} 1248}
1249 1249
@@ -1269,7 +1269,7 @@ efreet_mime_glob_case_match(char *str, const char *glob)
1269 tglob = alloca(strlen(glob) + 1); 1269 tglob = alloca(strlen(glob) + 1);
1270 for (tp = tglob, p = glob; *p; p++, tp++) *tp = tolower(*p); 1270 for (tp = tglob, p = glob; *p; p++, tp++) *tp = tolower(*p);
1271 *tp = 0; 1271 *tp = 0;
1272 if (!fnmatch(str, tglob, 0)) return 1; 1272 if (!eina_fnmatch(str, tglob, 0)) return 1;
1273 return 0; 1273 return 0;
1274} 1274}
1275 1275
diff --git a/src/lib/efreet/efreet_utils.c b/src/lib/efreet/efreet_utils.c
index e1cafaaf89..2e51d6dcff 100644
--- a/src/lib/efreet/efreet_utils.c
+++ b/src/lib/efreet/efreet_utils.c
@@ -4,7 +4,7 @@
4 4
5/* TODO: add no_display check, as we might want only displayable items */ 5/* TODO: add no_display check, as we might want only displayable items */
6 6
7#include <fnmatch.h> 7#include <Eina.h>
8#include <ctype.h> 8#include <ctype.h>
9 9
10#include <Ecore_File.h> 10#include <Ecore_File.h>
@@ -450,7 +450,7 @@ efreet_util_glob_match(const char *str, const char *glob)
450 return 0; 450 return 0;
451 } 451 }
452 if (!strcmp(glob, "*")) return 1; 452 if (!strcmp(glob, "*")) return 1;
453 if (!fnmatch(glob, str, 0)) return 1; 453 if (!eina_fnmatch(glob, str, 0)) return 1;
454 return 0; 454 return 0;
455} 455}
456 456
diff --git a/src/lib/eina/Eina.h b/src/lib/eina/Eina.h
index 383696d7d8..821c55f40d 100644
--- a/src/lib/eina/Eina.h
+++ b/src/lib/eina/Eina.h
@@ -277,6 +277,7 @@ extern "C" {
277#include <eina_promise.h> 277#include <eina_promise.h>
278#include <eina_vpath.h> 278#include <eina_vpath.h>
279#include <eina_abstract_content.h> 279#include <eina_abstract_content.h>
280#include <eina_fnmatch.h>
280 281
281 282
282#ifdef __cplusplus 283#ifdef __cplusplus
diff --git a/src/lib/eina/eina_fnmatch.c b/src/lib/eina/eina_fnmatch.c
new file mode 100644
index 0000000000..eae287fc22
--- /dev/null
+++ b/src/lib/eina/eina_fnmatch.c
@@ -0,0 +1,249 @@
1#include "eina_fnmatch.h"
2
3#include <stdlib.h>
4#include <errno.h>
5#include <string.h>
6#include <pcreposix.h>
7
8inline static int
9_is_escapable(char c)
10{
11 switch (c)
12 {
13 case '[': case '|': case '(': case ')': case '*': case '?':
14 case '!': case '^': case '$': case '.': case '+': case '\\':
15 return 1;
16 default:
17 return 0;
18 }
19}
20
21inline static char *
22_wildcards_to_regex(const char *pattern, int flags)
23{
24
25 // Counts how many additional chars needs to be allocated
26 int pattern_length = strlen(pattern);
27 int count = 2; // starts with '^' and ends with '$'
28 for (int j = 0; j < pattern_length; ++j)
29 {
30 if (pattern[j] == '\\')
31 {
32 if (flags & FNM_NOESCAPE) count++;
33 else count += 2;
34 }
35 else if ((pattern[j] == '*') || (pattern[j] == '?'))
36 {
37 if (flags & FNM_PATHNAME)
38 {
39 if (flags & FNM_PERIOD) // PATHNAME + PERIOD
40 {
41 if (pattern[j] == '*')
42 {
43 if (j == 0) count += 10;
44 else if (pattern[j - 1] == '/') count += 10;
45 else count += 5;
46 }
47 else if ((j == 0) || (pattern[j - 1] == '/')) count += 10;
48 else count += 4;
49 }
50 else if (pattern[j] == '*') count += 5; // PATHNAME
51 else count += 4;
52 }
53 else if (flags & FNM_PERIOD)
54 {
55 if (j == 0) // period at init
56 {
57 if (pattern[j] == '*') count += 5;
58 else count += 4;
59 }
60 // period at other places
61 else if (pattern[j] == '*') count += 2;
62 else count++;
63 }
64 else if (pattern[j] == '*') count += 2; // NORMAL
65 else count++;
66 }
67 else if (pattern[j] == '.') count += 4;
68 else count++; // OTHERS
69 }
70
71 int reg_length = pattern_length + count;
72
73 // Translates wildcards to regex
74 char *reg_pattern = (char *)malloc(reg_length * sizeof(char));
75 if (reg_pattern == NULL) exit(ENOMEM);
76 reg_pattern[0] = '^';
77 int i = 1;
78 for (int j = 0; j < pattern_length; ++j)
79 {
80 if (pattern[j] == '\\')
81 {
82 if (flags & FNM_NOESCAPE)
83 reg_pattern[i++] = '/';
84 else if (_is_escapable(pattern[j + 1]))
85 {
86 reg_pattern[i++] = '\\';
87 reg_pattern[i++] = pattern[++j];
88 }
89 else
90 {
91 reg_pattern[i++] = '\\';
92 reg_pattern[i++] = '/';
93 }
94 }
95 else if ((pattern[j] == '*') || (pattern[j] == '?'))
96 {
97 if (flags & FNM_PATHNAME)
98 {
99 if (flags & FNM_PERIOD) // PATHNAME + PERIOD
100 {
101 if (pattern[j] == '*')
102 {
103 if ( (j == 0) || (pattern[j - 1] == '/') )
104 {
105 strcpy_s(reg_pattern + i,
106 sizeof(reg_pattern + i),
107 "[^\\.][^/]*");
108 i += 10;
109 }
110 else
111 {
112 strcpy_s(reg_pattern + i,
113 sizeof(reg_pattern + i),
114 "[^/]*");
115 i += 5;
116 }
117 }
118 else if (j == 0)
119 {
120 strcpy_s(reg_pattern + i,
121 sizeof(reg_pattern + i),
122 "[^\\.][^/]?");
123 i += 10;
124 }
125 else if (pattern[j - 1] == '/')
126 {
127 strcpy_s(reg_pattern + i,
128 sizeof(reg_pattern + i),
129 "[^\\.][^/]?");
130 i += 10;
131 }
132 else
133 {
134 strcpy_s(reg_pattern + i,
135 sizeof(reg_pattern + i),
136 "[^/]");
137 i += 4;
138 }
139 }
140 else if (pattern[j] == '*') // PATHNAME
141 {
142 strcpy_s(reg_pattern + i,
143 sizeof(reg_pattern + i),
144 "[^/]*");
145 i += 5;
146 }
147 else
148 {
149 strcpy_s(reg_pattern + i,
150 sizeof(reg_pattern + i),
151 "[^/]");
152 i += 4;
153 }
154 }
155 else if (flags & FNM_PERIOD)
156 {
157 if (j == 0) // period at init
158 {
159 if (pattern[j] == '*')
160 {
161 strcpy_s(reg_pattern + i,
162 sizeof(reg_pattern + i),
163 "[\\.]*");
164 i += 5;
165 }
166 else
167 {
168 strcpy_s(reg_pattern + i,
169 sizeof(reg_pattern + i),
170 "[\\.]");
171 i += 4;
172 }
173 }
174 else if (pattern[j] == '*') // period at other places
175 {
176 strcpy_s(reg_pattern + i,
177 sizeof(reg_pattern + i),
178 ".*");
179 i += 2;
180 }
181 else
182 reg_pattern[i++] = '.';
183 }
184 else if (pattern[j] == '*') // NORMAL
185 {
186 strcpy_s(reg_pattern + i,
187 sizeof(reg_pattern + i),
188 ".*");
189 i += 2;
190 }
191 else
192 {
193 strcpy_s(reg_pattern + i,
194 sizeof(reg_pattern + i),
195 ".");
196 i++;
197 }
198 }
199 else if (pattern[j] == '.')
200 {
201 strcpy_s(reg_pattern + i,
202 sizeof(reg_pattern + i),
203 "[\\.]");
204 i += 4;
205 }
206 else reg_pattern[i++] = pattern[j]; // OTHERS
207 }
208 strcpy_s(reg_pattern + i,
209 sizeof(reg_pattern + i),
210 "$\0");
211
212 return reg_pattern;
213}
214
215int
216eina_fnmatch(const char *pattern, const char *string, int flags)
217{
218 // Converts wildcard pattern to regex pattern
219 char *reg_pattern = _wildcards_to_regex(pattern, flags);
220
221 // Configures regex
222 int regex_flags = (REG_NOSUB) // Report only success/fail in regexec()
223 || ((flags & FNM_CASEFOLD) ? REG_ICASE : 0);
224
225 // Compiles regex
226 regex_t regex;
227 if (regcomp(&regex, reg_pattern, regex_flags))
228 {
229 regfree(&regex);
230 return FNM_NOMATCH;
231 }
232
233 // Replaces '\\' with '/'
234 int string_length = strlen(string);
235 char *unix_path = (char *)malloc(string_length * sizeof(char));
236 if (unix_path == NULL) exit(ENOMEM);
237 unix_path[string_length] = '\0';
238 for (int i = 0; i < string_length; ++i)
239 unix_path[i] = (string[i] == '\\') ? '/' : string[i];
240
241 // Executes regex
242 int result = regexec(&regex, unix_path, 0, NULL, 0);
243
244 // Cleans-up and returns
245 free(unix_path);
246 free(reg_pattern);
247 regfree(&regex);
248 return result ? FNM_NOMATCH : 0;
249}
diff --git a/src/lib/eina/eina_fnmatch.h b/src/lib/eina/eina_fnmatch.h
new file mode 100644
index 0000000000..3450258ebb
--- /dev/null
+++ b/src/lib/eina/eina_fnmatch.h
@@ -0,0 +1,37 @@
1#ifndef EINA_FNMATCH_H
2#define EINA_FNMATCH_H
3
4#ifdef __cplusplus
5extern "C"
6{
7#endif
8
9#ifdef _WIN32
10
11/* Bits set in the FLAGS argument to `fnmatch'. */
12#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
13#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
14#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
15
16#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
17#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
18#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
19
20/* Value returned by `fnmatch' if STRING does not match PATTERN. */
21#define FNM_NOMATCH 1
22
23int eina_fnmatch(const char *pattern, const char *string, int flags);
24
25#else /* _WIN32 */
26
27//#define eina_fnmatch(a,b,c) fnmatch(a,b,c)
28#include <fnmatch.h>
29#define eina_fnmatch fnmatch
30
31#endif /* _WIN32 */
32
33#ifdef __cplusplus
34}
35#endif
36
37#endif /* EINA_FNMATCH_H */
diff --git a/src/lib/eina/eina_log.c b/src/lib/eina/eina_log.c
index 8cea3e9ebe..2768b16e24 100644
--- a/src/lib/eina/eina_log.c
+++ b/src/lib/eina/eina_log.c
@@ -25,7 +25,6 @@
25#include <string.h> 25#include <string.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <fnmatch.h>
29#include <assert.h> 28#include <assert.h>
30#include <errno.h> 29#include <errno.h>
31 30
@@ -51,6 +50,7 @@
51#include "eina_thread.h" 50#include "eina_thread.h"
52#include "eina_convert.h" 51#include "eina_convert.h"
53#include "eina_strbuf.h" 52#include "eina_strbuf.h"
53#include "eina_fnmatch.h"
54 54
55/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */ 55/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
56#include "eina_safety_checks.h" 56#include "eina_safety_checks.h"
@@ -1280,7 +1280,7 @@ finish_register:
1280 { 1280 {
1281 EINA_INLIST_FOREACH(_glob_list, pending) 1281 EINA_INLIST_FOREACH(_glob_list, pending)
1282 { 1282 {
1283 if (!fnmatch(pending->name, name, 0)) 1283 if (!eina_fnmatch(pending->name, name, 0))
1284 { 1284 {
1285 _log_domains[i].level = pending->level; 1285 _log_domains[i].level = pending->level;
1286 break; 1286 break;
@@ -1996,7 +1996,7 @@ eina_log_domain_level_get(const char *domain_name)
1996 1996
1997 EINA_INLIST_FOREACH(_glob_list, pending) 1997 EINA_INLIST_FOREACH(_glob_list, pending)
1998 { 1998 {
1999 if (!fnmatch(pending->name, domain_name, 0)) 1999 if (!eina_fnmatch(pending->name, domain_name, 0))
2000 return pending->level; 2000 return pending->level;
2001 } 2001 }
2002 2002
diff --git a/src/lib/eina/eina_main.c b/src/lib/eina/eina_main.c
index 252b7f6465..f8e2094058 100644
--- a/src/lib/eina/eina_main.c
+++ b/src/lib/eina/eina_main.c
@@ -67,6 +67,7 @@
67#include "eina_slstr.h" 67#include "eina_slstr.h"
68#include "eina_vpath.h" 68#include "eina_vpath.h"
69#include "eina_thread.h" 69#include "eina_thread.h"
70#include "eina_fnmatch.h"
70 71
71/*============================================================================* 72/*============================================================================*
72* Local * 73* Local *
diff --git a/src/lib/eina/meson.build b/src/lib/eina/meson.build
index 83c38bb51c..d20513e544 100644
--- a/src/lib/eina/meson.build
+++ b/src/lib/eina/meson.build
@@ -1,7 +1,7 @@
1if not sys_windows 1if not sys_windows
2 eina_deps = [dl] 2 eina_deps = [dl]
3else 3else
4 eina_deps = [] 4 eina_deps = [pcre_dep]
5endif 5endif
6eina_pub_deps = [thread_dep] 6eina_pub_deps = [thread_dep]
7 7
@@ -109,7 +109,8 @@ public_sub_headers = [
109'eina_freeq.h', 109'eina_freeq.h',
110'eina_slstr.h', 110'eina_slstr.h',
111'eina_vpath.h', 111'eina_vpath.h',
112'eina_abstract_content.h' 112'eina_abstract_content.h',
113'eina_fnmatch.h'
113] 114]
114 115
115public_headers = [ 116public_headers = [
@@ -199,6 +200,7 @@ if sys_windows == true
199 public_sub_headers += 'eina_inline_thread_win32.x' 200 public_sub_headers += 'eina_inline_thread_win32.x'
200 sources += 'eina_file_win32.c' 201 sources += 'eina_file_win32.c'
201 sources += 'eina_sched_win32.c' 202 sources += 'eina_sched_win32.c'
203 sources += 'eina_fnmatch.c'
202 public_sub_headers += 'eina_inline_lock_win32.x' 204 public_sub_headers += 'eina_inline_lock_win32.x'
203else 205else
204 public_sub_headers += 'eina_thread_posix.h' 206 public_sub_headers += 'eina_thread_posix.h'
diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h
index ffc5fd43c5..dbdbbfef15 100644
--- a/src/lib/elementary/Efl_Ui.h
+++ b/src/lib/elementary/Efl_Ui.h
@@ -14,7 +14,7 @@
14#include <sys/time.h> 14#include <sys/time.h>
15#include <sys/param.h> 15#include <sys/param.h>
16#include <math.h> 16#include <math.h>
17#include <fnmatch.h> 17#include <Eina.h>
18#include <limits.h> 18#include <limits.h>
19#include <ctype.h> 19#include <ctype.h>
20#include <time.h> 20#include <time.h>
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index c83481a9fd..7e02bcb40b 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -20,7 +20,6 @@
20#include <sys/time.h> 20#include <sys/time.h>
21#include <sys/param.h> 21#include <sys/param.h>
22#include <math.h> 22#include <math.h>
23#include <fnmatch.h>
24#include <limits.h> 23#include <limits.h>
25#include <ctype.h> 24#include <ctype.h>
26#include <time.h> 25#include <time.h>
diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c
index 8a5bccaa2f..3ed443a099 100644
--- a/src/lib/elementary/elm_gengrid.c
+++ b/src/lib/elementary/elm_gengrid.c
@@ -433,7 +433,7 @@ _elm_gengrid_search_by_text_item_get(Eo *obj EINA_UNUSED,
433 str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), 433 str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)),
434 WIDGET(it), part_name ? part_name : "elm.text"); 434 WIDGET(it), part_name ? part_name : "elm.text");
435 if (!str) continue; 435 if (!str) continue;
436 if (!fnmatch(pattern, str, fnflags)) 436 if (!eina_fnmatch(pattern, str, fnflags))
437 { 437 {
438 free(str); 438 free(str);
439 return EO_OBJ(it); 439 return EO_OBJ(it);
@@ -1019,7 +1019,7 @@ _item_text_realize(Elm_Gen_Item *it,
1019 (edje_object_data_get(target, "texts")); 1019 (edje_object_data_get(target, "texts"));
1020 EINA_LIST_FOREACH(*source, l, key) 1020 EINA_LIST_FOREACH(*source, l, key)
1021 { 1021 {
1022 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue; 1022 if (parts && eina_fnmatch(parts, key, FNM_PERIOD)) continue;
1023 1023
1024 s = it->itc->func.text_get 1024 s = it->itc->func.text_get
1025 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key); 1025 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@@ -1068,7 +1068,7 @@ _item_content_realize(Elm_Gen_Item *it,
1068 1068
1069 EINA_LIST_FREE(source, key) 1069 EINA_LIST_FREE(source, key)
1070 { 1070 {
1071 if (parts && fnmatch(parts, key, FNM_PERIOD)) 1071 if (parts && eina_fnmatch(parts, key, FNM_PERIOD))
1072 continue; 1072 continue;
1073 1073
1074 Evas_Object *old = edje_object_part_swallow_get(target, key); 1074 Evas_Object *old = edje_object_part_swallow_get(target, key);
@@ -1135,7 +1135,7 @@ _item_state_realize(Elm_Gen_Item *it, Evas_Object *target, const char *parts)
1135 src = elm_widget_stringlist_get(edje_object_data_get(target, "states")); 1135 src = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1136 EINA_LIST_FREE(src, key) 1136 EINA_LIST_FREE(src, key)
1137 { 1137 {
1138 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue; 1138 if (parts && eina_fnmatch(parts, key, FNM_PERIOD)) continue;
1139 1139
1140 Eina_Bool on = it->itc->func.state_get 1140 Eina_Bool on = it->itc->func.state_get
1141 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key); 1141 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index 5da1517fc8..5841f28253 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -2,7 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#include <fnmatch.h> 5#include <Eina.h>
6 6
7#define EFL_ACCESS_OBJECT_PROTECTED 7#define EFL_ACCESS_OBJECT_PROTECTED
8#define EFL_ACCESS_SELECTION_PROTECTED 8#define EFL_ACCESS_SELECTION_PROTECTED
@@ -347,7 +347,7 @@ _item_text_realize(Elm_Gen_Item *it,
347 (edje_object_data_get(target, "texts")); 347 (edje_object_data_get(target, "texts"));
348 EINA_LIST_FOREACH(*source, l, key) 348 EINA_LIST_FOREACH(*source, l, key)
349 { 349 {
350 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue; 350 if (parts && eina_fnmatch(parts, key, FNM_PERIOD)) continue;
351 351
352 s = it->itc->func.text_get 352 s = it->itc->func.text_get
353 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key); 353 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@@ -423,7 +423,7 @@ _item_content_realize(Elm_Gen_Item *it,
423 423
424 EINA_LIST_FREE(source, key) 424 EINA_LIST_FREE(source, key)
425 { 425 {
426 if (parts && fnmatch(parts, key, FNM_PERIOD)) 426 if (parts && eina_fnmatch(parts, key, FNM_PERIOD))
427 continue; 427 continue;
428 428
429 Evas_Object *old = NULL; 429 Evas_Object *old = NULL;
@@ -505,7 +505,7 @@ _item_state_realize(Elm_Gen_Item *it, Evas_Object *target, const char *parts)
505 src = elm_widget_stringlist_get(edje_object_data_get(target, "states")); 505 src = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
506 EINA_LIST_FREE(src, key) 506 EINA_LIST_FREE(src, key)
507 { 507 {
508 if (parts && fnmatch(parts, key, FNM_PERIOD)) continue; 508 if (parts && eina_fnmatch(parts, key, FNM_PERIOD)) continue;
509 509
510 Eina_Bool on = it->itc->func.state_get 510 Eina_Bool on = it->itc->func.state_get
511 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key); 511 ((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), key);
@@ -8746,7 +8746,7 @@ _elm_genlist_search_by_text_item_get(Eo *obj EINA_UNUSED,
8746 if (!it->itc->func.text_get) continue; 8746 if (!it->itc->func.text_get) continue;
8747 str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), part_name); 8747 str = it->itc->func.text_get((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), part_name);
8748 if (!str) continue; 8748 if (!str) continue;
8749 if (!fnmatch(pattern, str, fnflags)) 8749 if (!eina_fnmatch(pattern, str, fnflags))
8750 { 8750 {
8751 free(str); 8751 free(str);
8752 return EO_OBJ(it); 8752 return EO_OBJ(it);
diff --git a/src/lib/embryo/embryo_str.c b/src/lib/embryo/embryo_str.c
index d7da4e0dd3..dc1940414b 100644
--- a/src/lib/embryo/embryo_str.c
+++ b/src/lib/embryo/embryo_str.c
@@ -14,7 +14,7 @@
14#include <stdlib.h> 14#include <stdlib.h>
15#include <stdio.h> 15#include <stdio.h>
16#include <string.h> 16#include <string.h>
17#include <fnmatch.h> 17#include <Eina.h>
18 18
19#include "Embryo.h" 19#include "Embryo.h"
20#include "embryo_private.h" 20#include "embryo_private.h"
@@ -59,7 +59,7 @@ _embryo_str_fnmatch(Embryo_Program *ep, Embryo_Cell *params)
59 STRGET(ep, s1, params[1]); 59 STRGET(ep, s1, params[1]);
60 STRGET(ep, s2, params[2]); 60 STRGET(ep, s2, params[2]);
61 if ((!s1) || (!s2)) return -1; 61 if ((!s1) || (!s2)) return -1;
62 return (Embryo_Cell)fnmatch(s1, s2, 0); 62 return (Embryo_Cell)eina_fnmatch(s1, s2, 0);
63} 63}
64 64
65static Embryo_Cell 65static Embryo_Cell
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 44fe92cf4a..cf21aedc4e 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -3,7 +3,6 @@
3#endif 3#endif
4 4
5#include <Eina.h> 5#include <Eina.h>
6#include <fnmatch.h>
7 6
8#include <Eo.h> 7#include <Eo.h>
9 8
@@ -544,7 +543,7 @@ _name_match(const char *match, Eina_Bool is_glob, const char *str)
544 // if match string is "*" special case it and match 543 // if match string is "*" special case it and match
545 if ((match[0] == '*') && (match[1] == 0)) return EINA_TRUE; 544 if ((match[0] == '*') && (match[1] == 0)) return EINA_TRUE;
546 // actual compare 545 // actual compare
547 if (!fnmatch(match, str, 0)) return EINA_TRUE; 546 if (!eina_fnmatch(match, str, 0)) return EINA_TRUE;
548 } 547 }
549 else 548 else
550 { 549 {
diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c
index 5b945dcb27..83a9bdcb67 100644
--- a/src/lib/evas/canvas/evas_font_dir.c
+++ b/src/lib/evas/canvas/evas_font_dir.c
@@ -65,7 +65,7 @@ static FcConfig *fc_config = NULL;
65 65
66/* FIXME move these helper function to eina_file or eina_path */ 66/* FIXME move these helper function to eina_file or eina_path */
67/* get the casefold feature! */ 67/* get the casefold feature! */
68#include <fnmatch.h> 68#include <Eina.h>
69#include <unistd.h> 69#include <unistd.h>
70#include <sys/param.h> 70#include <sys/param.h>
71int 71int
@@ -115,7 +115,7 @@ _file_path_list(char *path, const char *match, int match_case)
115 { 115 {
116 if (match) 116 if (match)
117 { 117 {
118 if (fnmatch(match, info->path + info->name_start, flags) == 0) 118 if (eina_fnmatch(match, info->path + info->name_start, flags) == 0)
119 files = eina_list_append(files, strdup(info->path + info->name_start)); 119 files = eina_list_append(files, strdup(info->path + info->name_start));
120 } 120 }
121 else 121 else
diff --git a/src/lib/evas/file/evas_path.c b/src/lib/evas/file/evas_path.c
index ef3d439018..d064b04401 100644
--- a/src/lib/evas/file/evas_path.c
+++ b/src/lib/evas/file/evas_path.c
@@ -12,7 +12,7 @@
12#include <sys/types.h> 12#include <sys/types.h>
13#include <sys/stat.h> 13#include <sys/stat.h>
14/* get the casefold feature! */ 14/* get the casefold feature! */
15#include <fnmatch.h> 15#include <Eina.h>
16#include <unistd.h> 16#include <unistd.h>
17#include <sys/param.h> 17#include <sys/param.h>
18 18
@@ -114,7 +114,7 @@ evas_file_path_list(char *path, const char *match, int match_case)
114 { 114 {
115 if (match) 115 if (match)
116 { 116 {
117 if (fnmatch(match, info->path + info->name_start, flags) == 0) 117 if (eina_fnmatch(match, info->path + info->name_start, flags) == 0)
118 files = eina_list_append(files, strdup(info->path + info->name_start)); 118 files = eina_list_append(files, strdup(info->path + info->name_start));
119 } 119 }
120 else 120 else
diff --git a/src/lib/evil/unposix/fnmatch.h b/src/lib/evil/unposix/fnmatch.h
deleted file mode 100644
index a1442121ff..0000000000
--- a/src/lib/evil/unposix/fnmatch.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef UNPOSIX_FNMATCH_H
2#define UNPOSIX_FNMATCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8// The string does not match the specified pattern.
9#define FNM_NOMATCH 1
10// <slash> in string only matches <slash> in pattern.
11#define FNM_PATHNAME (1 << 0)
12// Disable backslash escaping.
13#define FNM_NOESCAPE (1 << 1)
14// Leading <period> in string must be exactly matched by <period> in pattern.
15#define FNM_PERIOD (1 << 2)
16
17int fnmatch(const char *, const char *, int);
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
diff --git a/src/lib/evil/unposix/meson.build b/src/lib/evil/unposix/meson.build
index 53d82022fa..62b4bb6beb 100644
--- a/src/lib/evil/unposix/meson.build
+++ b/src/lib/evil/unposix/meson.build
@@ -4,7 +4,6 @@ if sys_windows
4 evil_unposix_src = [] 4 evil_unposix_src = []
5 5
6 evil_unposix_header_src = [ 6 evil_unposix_header_src = [
7 'fnmatch.h',
8 'libgen.h', 7 'libgen.h',
9 'limits.h', 8 'limits.h',
10 'locale.h', 9 'locale.h',
@@ -22,14 +21,14 @@ if sys_windows
22 evil_unposix_lib = static_library('evil_unposix', 21 evil_unposix_lib = static_library('evil_unposix',
23 evil_unposix_src, 22 evil_unposix_src,
24 include_directories: [include_directories('.'), config_dir], 23 include_directories: [include_directories('.'), config_dir],
25 dependencies : [pcre_dep, getopt_dep], 24 dependencies : [getopt_dep],
26 install: true, 25 install: true,
27 version: meson.project_version(), 26 version: meson.project_version(),
28 ) 27 )
29 28
30 evil_unposix = declare_dependency( 29 evil_unposix = declare_dependency(
31 include_directories: [include_directories('.')], 30 include_directories: [include_directories('.')],
32 dependencies: [pcre_dep, getopt_dep], 31 dependencies: [getopt_dep],
33 link_with: evil_unposix_lib, 32 link_with: evil_unposix_lib,
34 ) 33 )
35 34