[augeas-devel] [PATCH 4/8] regexp: add convenience function make_regexp_dup
lutter at redhat.com
lutter at redhat.com
Sat May 7 01:12:52 UTC 2011
From: David Lutterkort <lutter at redhat.com>
---
src/regexp.c | 9 +++++++++
src/regexp.h | 5 +++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/regexp.c b/src/regexp.c
index 14020af..b5978d2 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -113,6 +113,15 @@ void print_regexp(FILE *out, struct regexp *r) {
fputc('i', out);
}
+struct regexp *
+make_regexp_dup(struct info *info, const char *pat, int nocase) {
+ char *p = strdup(pat);
+
+ if (p == NULL)
+ return NULL;
+ return make_regexp(info, p, nocase);
+}
+
struct regexp *make_regexp(struct info *info, char *pat, int nocase) {
struct regexp *regexp;
diff --git a/src/regexp.h b/src/regexp.h
index 221252c..e770735 100644
--- a/src/regexp.h
+++ b/src/regexp.h
@@ -41,6 +41,11 @@ void print_regexp(FILE *out, struct regexp *regexp);
*/
struct regexp *make_regexp(struct info *info, char *pat, int nocase);
+/* Make a regexp with pattern PAT, which is copied. Ownership of INFO is
+ * taken.
+ */
+struct regexp *make_regexp_dup(struct info *info, const char *pat, int nocase);
+
/* Return 1 if R is an empty pattern, i.e. one consisting of nothing but
'(' and ')' characters, 0 otherwise */
int regexp_is_empty_pattern(struct regexp *r);
--
1.7.4.4
More information about the augeas-devel
mailing list