[augeas-devel] [PATCH 2/4] Always do REGS_REALLOCATE for regexp match registers

David Lutterkort lutter at redhat.com
Tue Feb 17 18:54:06 UTC 2009


---
 src/get.c    |    3 +--
 src/put.c    |    3 +--
 src/regexp.c |    1 +
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/get.c b/src/get.c
index e54bf38..90d1da8 100644
--- a/src/get.c
+++ b/src/get.c
@@ -251,8 +251,7 @@ static struct split *split_concat(struct state *state, struct lens *lens) {
     struct split *split = NULL;
     struct regexp *ctype = lens->ctype;
 
-    if (ctype->re != NULL)
-        ctype->re->regs_allocated = REGS_UNALLOCATED;
+    MEMZERO(&regs, 1);
     count = regexp_match(ctype, outer->start, outer->size, 0, &regs);
     if (count < 0) {
         regexp_match_error(state, lens, count, outer, ctype);
diff --git a/src/put.c b/src/put.c
index 26352a5..e85ae96 100644
--- a/src/put.c
+++ b/src/put.c
@@ -189,8 +189,7 @@ static struct split *split_concat(struct state *state, struct lens *lens) {
         return split;
     }
 
-    if (atype->re != NULL)
-        atype->re->regs_allocated = REGS_UNALLOCATED;
+    MEMZERO(&regs, 1);
     count = regexp_match(atype, outer->labels, outer->end,
                          outer->start, &regs);
     if (count >= 0 && count != outer->end - outer->start)
diff --git a/src/regexp.c b/src/regexp.c
index 3d1890a..f96cb86 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -295,6 +295,7 @@ int regexp_compile(struct regexp *r) {
     c = re_compile_pattern(r->pattern->str, strlen(r->pattern->str), r->re);
     re_syntax_options = old_syntax;
 
+    r->re->regs_allocated = REGS_REALLOCATE;
     if (c != NULL) {
         char *p = escape(r->pattern->str, -1);
         syntax_error(r->info, "invalid regexp /%s/: %s", p, c);
-- 
1.6.0.6




More information about the augeas-devel mailing list