[augeas-devel] augeas: master - * src/lens.c (format_lens): minimalistic pretty-printing of a lens
David Lutterkort
lutter at fedoraproject.org
Wed Dec 23 20:29:02 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=badc0429e02cbb406ff44f6322e3db813ccf2e5f
Commit: badc0429e02cbb406ff44f6322e3db813ccf2e5f
Parent: 672d154eb7d7d3ed59b02df95aa71973dbb87b75
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Fri Nov 20 10:47:23 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Dec 23 12:18:25 2009 -0800
* src/lens.c (format_lens): minimalistic pretty-printing of a lens
---
src/lens.c | 9 +++++++++
src/lens.h | 3 +++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/lens.c b/src/lens.c
index 723d8f1..e837214 100644
--- a/src/lens.c
+++ b/src/lens.c
@@ -54,6 +54,15 @@ static const struct string digits_string = {
};
static const struct string *const digits_pat = &digits_string;
+char *format_lens(struct lens *l) {
+ char *inf = format_info(l->info);
+ char *result;
+
+ xasprintf(&result, "%s[%s]", tags[l->tag - L_DEL], inf);
+ free(inf);
+ return result;
+}
+
/* Construct a finite automaton from REGEXP and return it in *FA.
*
* Return NULL if REGEXP is valid, if the regexp REGEXP has syntax errors,
diff --git a/src/lens.h b/src/lens.h
index 7f9e30d..d378e02 100644
--- a/src/lens.h
+++ b/src/lens.h
@@ -96,6 +96,9 @@ struct value *lns_make_plus(struct info *, struct lens *,
struct value *lns_make_maybe(struct info *, struct lens *,
int check);
+/* Pretty-print a lens */
+char *format_lens(struct lens *l);
+
/* Pretty-print the atype of a lens. Allocates BUF, which must be freed by
* the caller */
int lns_format_atype(struct lens *, char **buf);
More information about the augeas-devel
mailing list