[augeas-devel] augeas: master - * src/get.c: never try to process a string that doesn't match
David Lutterkort
lutter at fedoraproject.org
Fri Nov 13 19:26:48 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=c059a71193bcebcb7a5468b68f88e00a1704b4ca
Commit: c059a71193bcebcb7a5468b68f88e00a1704b4ca
Parent: d53671ceef962c3351fcf01bf50658acb58ea72c
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Tue Nov 10 17:49:19 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Nov 13 10:43:56 2009 -0800
* src/get.c: never try to process a string that doesn't match
When a string during init_regs doesn't match at all, there's nothing useful
we can do. Immediately return an error from lns_get.
---
src/get.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/get.c b/src/get.c
index 322233f..9927df1 100644
--- a/src/get.c
+++ b/src/get.c
@@ -683,7 +683,9 @@ static int init_regs(struct state *state, struct lens *lens, uint size) {
if (lens->tag != L_STAR) {
r = match(state, lens, lens->ctype, size, 0);
- if (r < -1)
+ if (r == -1)
+ get_error(state, lens, "Input string does not match at all");
+ if (r <= -1)
return -1;
return r != size;
}
@@ -721,8 +723,8 @@ struct tree *lns_get(struct info *info, struct lens *lens, const char *text,
* fails, we throw our arms in the air and say 'something went wrong'
*/
partial = init_regs(&state, lens, size);
-
- tree = get_lens(lens, &state);
+ if (partial >= 0)
+ tree = get_lens(lens, &state);
free_seqs(state.seqs);
if (state.key != NULL) {
More information about the augeas-devel
mailing list