libyang FEATURE sorting of data nodes
1. Plugin type 'lyds_tree' is integrated. Used in metadata and it is
internal, which is distinguished by the unset print callback.
Internal metadata must not be printed.
2. Leaf-list and list data instances are now automatically sorted.
3. Both the explicit and implicit YANG statement 'ordered-by system'
will cause the nodes to be ordered.
4. The first instance of the list or leaf-list of node contain
new metadata named 'lyds_tree'.
5. Data nodes are sorted only if their data types have
callback 'sort' set.
6. Sorting can be turned off so far only by adding the 'ordered-by user'
statement to the YANG model.
7. If the sort fails for some reason, the node is still inserted
as the last instance. A warning message informs about this situation.
8. The time required for sorting should be relatively small thanks to
the Red-black tree implementation.
9. Memory requirements will now increase by 40 bytes per list/leaf-list
data node, plus metadata structure overhead.
10. New internal lyds_tree plugin type.
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 73802f1..9dd95a8 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -288,10 +288,27 @@
LY_ARRAY_COUNT_TYPE u;
LY_ARRAY_FOR(exts, u) {
+ if (exts[u].flags & LYS_INTERNAL) {
+ continue;
+ }
yprp_extension_instance(pctx, substmt, substmt_index, &exts[u], flag);
}
}
+static ly_bool
+yprp_extension_has_printable_instances(struct lysp_ext_instance *exts)
+{
+ LY_ARRAY_COUNT_TYPE u;
+
+ LY_ARRAY_FOR(exts, u) {
+ if (!(exts[u].flags & LYS_INTERNAL)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static void
yprc_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index,
struct lysc_ext_instance *exts, ly_bool *flag)
@@ -2148,7 +2165,7 @@
YPR_EXTRA_LINE(modp->extensions, pctx);
- if (modp->exts) {
+ if (yprp_extension_has_printable_instances(modp->exts)) {
YPR_EXTRA_LINE_PRINT(pctx);
yprp_extension_instances(pctx, LY_STMT_MODULE, 0, modp->exts, NULL);
}