summaryrefslogtreecommitdiff
path: root/lib/exclude.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-02-15 19:21:04 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-02-21 17:35:26 +0200
commit24b8e0622053e4772eddba3bfba48c2928321cec (patch)
tree2864de77e5bc1b357a1d1c4244035197342275a2 /lib/exclude.h
parent3f51bf41c8be8b310f57caff371377414701d5cc (diff)
downloadgnulib-24b8e0622053e4772eddba3bfba48c2928321cec.tar.gz
exclude: add support for posix regexps
This commit adds support for POSIX extended regular expressions and fixes a long-standing memory leak (pattern buffer was never freed). It also implements a new interface function to read exclude patterns from a FILE, which passes an additional parameter to its callback function, thereby allowing to preserve its state between invocations. * lib/exclude.c (struct patopts): Pack regex and pattern into union. (pattern_buffer): New struct. (exclude): New member patbuf. (exclude_add_pattern_buffer): New function. (free_exclude_segment): Free regexps. (free_exclude): Free allocated pattern buffers. (exclude_patopts): New function. (file_pattern_matches): Use exclude_patopts. (add_exclude): support regexps. (add_exclude_fp): New function. (add_exclude_file): Rewrite using add_exclude_fp. (fnmatch_pattern_has_wildcards): Support posix extended regexps. * lib/exclude.h (EXCLUDE_REGEX, EXCLUDE_ALLOC): New flags. (add_exclude_fp) (exclude_add_pattern_buffer): New prototypes. * modules/exclude: Depends on regex and filename.
Diffstat (limited to 'lib/exclude.h')
-rw-r--r--lib/exclude.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/exclude.h b/lib/exclude.h
index 45dbe69ca6..955521861c 100644
--- a/lib/exclude.h
+++ b/lib/exclude.h
@@ -20,6 +20,7 @@
#define _GL_EXCLUDE_H 1
#include <stdbool.h>
+#include <stdio.h>
/* Written by Paul Eggert <eggert@twinsun.com>
and Sergey Poznyakoff <gray@gnu.org> */
@@ -37,6 +38,12 @@
option, these characters are ordinary and fnmatch is not used. */
#define EXCLUDE_WILDCARDS (1 << 28)
+/* Patterns are POSIX extended regular expressions */
+#define EXCLUDE_REGEX (1 << 27)
+
+/* Allocate storage for the pattern */
+#define EXCLUDE_ALLOC (1 << 26)
+
struct exclude;
bool fnmatch_pattern_has_wildcards (const char *, int) _GL_ATTRIBUTE_PURE;
@@ -46,7 +53,10 @@ void free_exclude (struct exclude *);
void add_exclude (struct exclude *, char const *, int);
int add_exclude_file (void (*) (struct exclude *, char const *, int),
struct exclude *, char const *, int, char);
+int add_exclude_fp (void (*) (struct exclude *, char const *, int, void *),
+ struct exclude *, FILE *, int, char, void *);
bool excluded_file_name (struct exclude const *, char const *);
-bool exclude_fnmatch (char const *pattern, char const *f, int options);
+void exclude_add_pattern_buffer (struct exclude *ex, char *buf);
+bool exclude_fnmatch (char const *, char const *, int);
#endif /* _GL_EXCLUDE_H */