[augeas-devel] [PATCH 4 of 6] Be more consistent in how NULL labels are printed
David Lutterkort
dlutter at redhat.com
Tue May 6 01:12:23 UTC 2008
# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1210036202 25200
# Node ID e68744ad2a0b41dce0abbaa4185932d7f75922a1
# Parent 3a8d71e509488b78bc30ae943bd14044c1805b50
Be more consistent in how NULL labels are printed
diff -r 3a8d71e50948 -r e68744ad2a0b src/augeas.c
--- a/src/augeas.c Mon May 05 18:09:49 2008 -0700
+++ b/src/augeas.c Mon May 05 18:10:02 2008 -0700
@@ -313,12 +313,19 @@ static int path_find_one(struct path *pa
return 1;
}
+static const char *pretty_label(const struct tree *tree) {
+ if (tree == NULL)
+ return "(no_tree)";
+ else if (tree->label == NULL)
+ return "(none)";
+ else
+ return tree->label;
+}
+
static const char *seg_label(struct segment *seg) {
if (seg->label != NULL)
return seg->label;
- if (seg->tree != NULL && seg->tree->label != NULL)
- return seg->tree->label;
- return "(none)";
+ return pretty_label(seg->tree);
}
static int seg_needs_qual(struct path *path, struct segment *seg) {
@@ -382,7 +389,7 @@ static char *path_expand(struct tree *tr
if (cnt == 1)
ind = 0;
- label = (tree->label == NULL) ? "()" : tree->label;
+ label = pretty_label(tree);
if (ind > 0) {
r = asprintf(&path, "%s/%s[%d]", ppath, label, ind);
} else {
More information about the augeas-devel
mailing list