From: David Lutterkort <[email protected]>
---
src/builtin.c | 2 +-
src/get.c | 8 +++++---
src/info.h | 1 -
src/lens.h | 2 +-
src/transform.c | 6 +++---
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/builtin.c b/src/builtin.c
index 1b339e3..53624aa 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -179,7 +179,7 @@ static struct value *lens_get(struct info *info, struct
value *l,
struct value *v;
const char *text = str->string->str;
- struct tree *tree = lns_get(info, l->lens, text, &err);
+ struct tree *tree = lns_get(info, l->lens, text, 0, &err);
if (err == NULL && ! HAS_ERR(info)) {
v = make_value(V_TREE, ref(info));
v->origin = make_tree_origin(tree);
diff --git a/src/get.c b/src/get.c
index 18947ef..6e02bed 100644
--- a/src/get.c
+++ b/src/get.c
@@ -67,6 +67,7 @@ struct state {
*/
struct re_registers *regs;
uint nreg;
+ uint store_spans; /* corresponds to AUG_ENABLE_SPAN flag */
};
/* Used by recursive lenses to stack intermediate results */
@@ -683,7 +684,7 @@ static struct tree *get_subtree(struct lens *lens, struct
state *state) {
state->key = NULL;
state->value = NULL;
- if (state->info->flags & AUG_ENABLE_SPAN) {
+ if (state->store_spans) {
state->span = make_span(state->info);
ERR_NOMEM(state->span == NULL, state->info);
}
@@ -892,7 +893,7 @@ static void visit_enter(struct lens *lens,
state->value = NULL;
} else if (lens->tag == L_MAYBE) {
push_frame(rec_state, lens);
- if (state->info->flags & AUG_ENABLE_SPAN) {
+ if (state->store_spans) {
state->span = make_span(state->info);
ERR_NOMEM(state->span == NULL, state->info);
}
@@ -1275,7 +1276,7 @@ static int init_regs(struct state *state, struct lens
*lens, uint size) {
}
struct tree *lns_get(struct info *info, struct lens *lens, const char *text,
- struct lns_error **err) {
+ unsigned int store_spans, struct lns_error **err) {
struct state state;
struct tree *tree = NULL;
uint size = strlen(text);
@@ -1287,6 +1288,7 @@ struct tree *lns_get(struct info *info, struct lens
*lens, const char *text,
*state.info = *info;
state.info->ref = UINT_MAX;
+ state.store_spans = store_spans;
state.text = text;
diff --git a/src/info.h b/src/info.h
index 2e3aa0f..1a7c2b1 100644
--- a/src/info.h
+++ b/src/info.h
@@ -52,7 +52,6 @@ struct info {
uint16_t last_line;
uint16_t last_column;
ref_t ref;
- int flags;
};
struct span {
diff --git a/src/lens.h b/src/lens.h
index 420b26f..4a032d1 100644
--- a/src/lens.h
+++ b/src/lens.h
@@ -195,7 +195,7 @@ void free_lns_error(struct lns_error *err);
* parse_flags
*/
struct tree *lns_get(struct info *info, struct lens *lens, const char *text,
- struct lns_error **err);
+ unsigned int store_spans, struct lns_error **err);
struct skel *lns_parse(struct lens *lens, const char *text,
struct dict **dict, struct lns_error **err);
void lns_put(FILE *out, struct lens *lens, struct tree *tree,
diff --git a/src/transform.c b/src/transform.c
index d5629b2..9ae3f9e 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -507,15 +507,15 @@ static int load_file(struct augeas *aug, struct lens
*lens,
make_ref(info->filename);
info->filename->str = strdup(filename);
info->error = aug->error;
- info->flags = aug->flags;
info->first_line = 1;
- if (aug->flags & AUG_ENABLE_SPAN) {
+ unsigned int store_spans = aug->flags & AUG_ENABLE_SPAN;
+ if (store_spans) {
span = make_span(info);
ERR_NOMEM(span == NULL, info);
}
- tree = lns_get(info, lens, text, &err);
+ tree = lns_get(info, lens, text, store_spans, &err);
unref(info, info);
--
1.7.4
_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel