Skip to content

Commit

Permalink
tree printer CHANGE for augment nodes print their module name as prefix
Browse files Browse the repository at this point in the history
prefix of the module is not unique, so in the tree output, use module
names instead the module prefix.

Relates to #24
  • Loading branch information
rkrejci authored and PavolVican committed Feb 21, 2016
1 parent ba913c1 commit 6b7d2e1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/printer_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ get_max_name_len(const struct lys_module *module, const struct lys_node *node)
(LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST
| LYS_ANYXML | LYS_CASE)) {
mod = lys_mainmodule(sub);
name_len = strlen(sub->name) + (module == mod ? 0 : strlen(mod->prefix)+1);
name_len = strlen(sub->name) + (module == mod ? 0 : strlen(mod->name)+1);
if (name_len > max_name_len) {
max_name_len = name_len;
}
Expand Down Expand Up @@ -212,7 +212,7 @@ tree_print_container(struct lyout *out, const struct lys_module *module, int lev

nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
ly_print(out, "%s:", nodemod->name);
}

ly_print(out, "%s%s", cont->name, (cont->presence ? "!" : ""));
Expand Down Expand Up @@ -262,7 +262,7 @@ tree_print_choice(struct lyout *out, const struct lys_module *module, int level,

nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
ly_print(out, "%s:", nodemod->name);
}

ly_print(out, "%s)%s", choice->name, (choice->flags & LYS_MAND_TRUE ? "" : "?"));
Expand Down Expand Up @@ -303,7 +303,7 @@ tree_print_case(struct lyout *out, const struct lys_module *module, int level, c

nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
ly_print(out, "%s:", nodemod->name);
}

ly_print(out, "%s)", cas->name);
Expand Down Expand Up @@ -354,8 +354,8 @@ tree_print_anyxml(struct lyout *out, const struct lys_module *module, char *inde
prefix_len = 0;
nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
prefix_len = strlen(nodemod->prefix)+1;
ly_print(out, "%s:", nodemod->name);
prefix_len = strlen(nodemod->name)+1;
}

ly_print(out, "%s%s%*sanyxml", anyxml->name, (anyxml->flags & LYS_MAND_TRUE ? " " : "?"),
Expand Down Expand Up @@ -406,8 +406,8 @@ tree_print_leaf(struct lyout *out, const struct lys_module *module, char *indent
prefix_len = 0;
nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
prefix_len = strlen(nodemod->prefix)+1;
ly_print(out, "%s:", nodemod->name);
prefix_len = strlen(nodemod->name)+1;
}

ly_print(out, "%s%s%*s", leaf->name, ((leaf->flags & LYS_MAND_TRUE) || is_key ? " " : "?"),
Expand Down Expand Up @@ -446,7 +446,7 @@ tree_print_leaflist(struct lyout *out, const struct lys_module *module, char *in

nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
ly_print(out, "%s:", nodemod->name);
}

ly_print(out, "%s*%*s", leaflist->name, 3 + (int)(max_name_len - strlen(leaflist->name)), " ");
Expand Down Expand Up @@ -482,7 +482,7 @@ tree_print_list(struct lyout *out, const struct lys_module *module, int level, c

nodemod = lys_mainmodule(node);
if (module != nodemod) {
ly_print(out, "%s:", nodemod->prefix);
ly_print(out, "%s:", nodemod->name);
}

ly_print(out, "%s*", list->name);
Expand Down

0 comments on commit 6b7d2e1

Please sign in to comment.