31 static void init(
struct buffer *buf)
38 static void add(
struct buffer *buf,
char c)
40 if (buf->len >= buf->alloc) {
42 buf->buf =
G_realloc(buf->buf, buf->alloc);
45 buf->buf[buf->len++] = c;
48 static void fini(
struct buffer *buf)
53 static const char *do_set(
struct buffer *buf,
const char *p)
67 for (; *p && *p !=
']'; p++)
78 static int wc2regex(
struct buffer *buf,
const char *pat)
87 for (p = pat; p && *p; p++) {
127 if (!(p = do_set(buf, p)))
148 static int re_filter(
const char *filename,
void *closure)
151 regex_t *regex = closure;
153 return filename[0] !=
'.' && regexec(regex, filename, 0,
NULL, 0) == 0;
156 const char *pcreErrorStr;
157 pcre_extra *pcreExtra;
159 pcre *pcre_regex = closure;
162 pcreExtra = pcre_study(pcre_regex, 0, &pcreErrorStr);
163 pcreExecRet = pcre_exec(pcre_regex, pcreExtra, filename,
169 return filename[0] !=
'.' && pcreExecRet == 0;
177 regex_t *regex =
G_malloc(
sizeof(regex_t));
179 if (regcomp(regex, pat,
180 REG_NOSUB | (extended ? REG_EXTENDED : 0) |
181 (ignorecase ? REG_ICASE : 0)) != 0) {
196 const char *pcreErrorStr;
200 pcre_regex = pcre_compile(pat, 0, &pcreErrorStr, &pcreErrorOffset,
NULL);
215 pcre_regex = pcre_compile(pat, 0, &pcreErrorStr, &pcreErrorOffset,
NULL);
246 if (!wc2regex(&buf, pat)) {
void G_free(void *)
Free allocated memory.
void G_set_ls_exclude_filter(int(*)(const char *, void *), void *)
void G_set_ls_filter(int(*)(const char *, void *), void *)
void * G_ls_glob_filter(const char *pat, int exclude, int ignorecase)
void * G_ls_regex_filter(const char *pat, int exclude, int extended, int ignorecase)
void G_free_ls_filter(void *regex)