[augeas-devel] [PATCH 6 of 6] Enclose the regexp for a key in (..) before adding a /
David Lutterkort
dlutter at redhat.com
Tue May 6 01:12:25 UTC 2008
# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1210036263 25200
# Node ID 3aac4ca5d0afee4fef06bf5c771359043ca01ce9
# Parent 050726209f9d5eeff658a2e64f40eb64aa955e11
Enclose the regexp for a key in (..) before adding a /
diff -r 050726209f9d -r 3aac4ca5d0af src/lens.c
--- a/src/lens.c Mon May 05 18:10:45 2008 -0700
+++ b/src/lens.c Mon May 05 18:11:03 2008 -0700
@@ -45,7 +45,8 @@ static fa_t regexp_to_fa(struct regexp *
int error = fa_compile(regexp->pattern->str, &fa);
if (error != REG_NOERROR) {
syntax_error(regexp->info,
- "unexpected error from fa_compile %d", error);
+ "unexpected error from fa_compile %d compiling %s",
+ error, regexp->pattern->str);
return NULL;
}
return fa;
@@ -445,13 +446,13 @@ static struct value *typecheck_maybe(str
static struct regexp *make_key_regexp(struct info *info, const char *pat) {
struct regexp *regexp;
- size_t len = strlen(pat) + 2;
+ size_t len = strlen(pat) + 4;
make_ref(regexp);
make_ref(regexp->pattern);
regexp->info = ref(info);
CALLOC(regexp->pattern->str, len);
- snprintf((char *) regexp->pattern->str, len, "%s/", pat);
+ snprintf((char *) regexp->pattern->str, len, "(%s)/", pat);
return regexp;
}
diff -r 050726209f9d -r 3aac4ca5d0af tests/modules/pass_iter_key_union.aug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/modules/pass_iter_key_union.aug Mon May 05 18:11:03 2008 -0700
@@ -0,0 +1,13 @@
+module Pass_iter_key_union =
+
+ (* We used to typecheck the atype of this as (a|b/)* *)
+ (* which is wrong and leads to spurious ambiguous iteration errors *)
+ (* The right atype is ((a|b)/)* *)
+ let l1 = [ key /a|b/ . store /x/ ]
+ let l2 = [ key /ab/ . store /y/ ]
+
+ let lns = (l1 | l2)*
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
More information about the augeas-devel
mailing list