mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
common: use fnmatch() for pattern matching
Drop-in POSIX-compliant function that has a nice glob(7) manual page for reference.
This commit is contained in:
parent
e864419194
commit
3e5b988d38
2 changed files with 6 additions and 11 deletions
|
|
@ -1,15 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include "common/match.h"
|
||||
|
||||
bool
|
||||
match_glob(const gchar *pattern, const gchar *string)
|
||||
match_glob(const char *pattern, const char *string)
|
||||
{
|
||||
gchar *p = g_utf8_casefold(pattern, -1);
|
||||
gchar *s = g_utf8_casefold(string, -1);
|
||||
bool ret = g_pattern_match_simple(p, s);
|
||||
g_free(p);
|
||||
g_free(s);
|
||||
return ret;
|
||||
return fnmatch(pattern, string, FNM_CASEFOLD) == 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue