diff options
Diffstat (limited to '')
-rw-r--r-- | src/printer_tree.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/src/printer_tree.c b/src/printer_tree.c index 6a7e7ce..6aa2814 100644 --- a/src/printer_tree.c +++ b/src/printer_tree.c @@ -1873,7 +1873,7 @@ trp_ext_is_present(ly_bool lysc_tree, const void *node) } else { pn = (const struct lysp_node *)node; LY_ARRAY_FOR(pn->exts, i) { - if (!(pn->exts && pn->exts->record->plugin.printer_ptree)) { + if (!(pn->exts && pn->exts->record && pn->exts->record->plugin.printer_ptree)) { continue; } if (!trp_ext_parent_is_valid(0, &pn->exts[i])) { @@ -3426,7 +3426,7 @@ troc_modi_first_sibling(struct trt_parent_cache ca, struct trt_tree_ctx *tc) /* current node is top-node */ switch (tc->section) { case TRD_SECT_MODULE: - tc->cn = tc->cmod->data; + tc->cn = tc->cn->module->compiled->data; break; case TRD_SECT_RPCS: tc->cn = (const struct lysc_node *)tc->cmod->rpcs; @@ -3486,7 +3486,8 @@ trb_gap_to_opts(const struct trt_node *node) } if (node->name.module_prefix) { - len += strlen(node->name.module_prefix); + /* prefix_name and ':' */ + len += strlen(node->name.module_prefix) + 1; } if (node->name.str) { len += strlen(node->name.str); @@ -3753,7 +3754,10 @@ trb_print_parents(const struct lysc_node *node, struct trt_wrapper *wr_in, struc /* print node */ ly_print_(pc->out, "\n"); print_node = pc->fp.read.node(TRP_EMPTY_PARENT_CACHE, tc); + /* siblings do not print, so the node is always considered the last */ + print_node.last_one = 1; max_gap_before_type = trb_max_gap_to_type(TRP_EMPTY_PARENT_CACHE, pc, tc); + tc->cn = node; trb_print_entire_node(&print_node, max_gap_before_type, wr, pc, tc); } @@ -3856,22 +3860,36 @@ trb_ext_iter(const struct trt_tree_ctx *tc, uint64_t *i) * @param[in] compiled if @p ext is lysc structure. * @param[in] ext current processed extension. * @param[out] plug_ctx is plugin context which will be initialized. + * @param[out] ignore plugin callback is NULL. * @return LY_ERR value. */ static LY_ERR -tro_ext_printer_tree(ly_bool compiled, void *ext, const struct lyspr_tree_ctx *plug_ctx) +tro_ext_printer_tree(ly_bool compiled, void *ext, const struct lyspr_tree_ctx *plug_ctx, ly_bool *ignore) { struct lysc_ext_instance *ext_comp; struct lysp_ext_instance *ext_pars; + const struct lyplg_ext *plugin; const char *flags = NULL, *add_opts = NULL; if (compiled) { ext_comp = ext; - return ext_comp->def->plugin->printer_ctree(ext, plug_ctx, &flags, &add_opts); + plugin = ext_comp->def->plugin; + if (!plugin->printer_ctree) { + *ignore = 1; + return LY_SUCCESS; + } + return plugin->printer_ctree(ext, plug_ctx, &flags, &add_opts); } else { ext_pars = ext; - return ext_pars->record->plugin.printer_ptree(ext, plug_ctx, &flags, &add_opts); + plugin = &ext_pars->record->plugin; + if (!plugin->printer_ptree) { + *ignore = 1; + return LY_SUCCESS; + } + return plugin->printer_ptree(ext, plug_ctx, &flags, &add_opts); } + + return LY_SUCCESS; } /** @@ -3986,7 +4004,7 @@ trb_ext_print_instances(struct trt_wrapper wr, struct trt_parent_cache ca, struc LY_ARRAY_COUNT_TYPE i; uint64_t last_instance = UINT64_MAX; void *ext; - ly_bool child_exists; + ly_bool child_exists, ignore = 0; uint32_t max, max_gap_before_type = 0; ca = tro_parent_cache_for_child(ca, tc); @@ -4004,8 +4022,12 @@ trb_ext_print_instances(struct trt_wrapper wr, struct trt_parent_cache ca, struc while ((ext = trb_ext_iter(tc, &i))) { struct lyspr_tree_ctx plug_ctx = {0}; - rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx); + rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx, &ignore); LY_CHECK_ERR_GOTO(rc, tc->last_error = rc, end); + if (ignore) { + ignore = 0; + continue; + } trb_ext_try_unified_indent(&plug_ctx, ca, &max_gap_before_type, pc, tc); if (plug_ctx.schemas) { last_instance = i; @@ -4024,8 +4046,12 @@ trb_ext_print_instances(struct trt_wrapper wr, struct trt_parent_cache ca, struc while ((ext = trb_ext_iter(tc, &i))) { struct lyspr_tree_ctx plug_ctx = {0}; - rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx); + rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx, &ignore); LY_CHECK_ERR_GOTO(rc, tc->last_error = rc, end); + if (ignore) { + ignore = 0; + continue; + } if (!child_exists && (last_instance == i)) { trb_ext_print_schemas(&plug_ctx, 1, max_gap_before_type, wr, ca, pc, tc); } else { @@ -4491,6 +4517,7 @@ trm_print_plugin_ext(struct trt_printer_ctx *pc, struct trt_tree_ctx *tc) struct trt_printer_ctx pc_dupl; struct trt_tree_ctx tc_dupl; struct trt_node node; + ly_bool ignore = 0; uint32_t max_gap_before_type; void *ext; @@ -4504,9 +4531,10 @@ trm_print_plugin_ext(struct trt_printer_ctx *pc, struct trt_tree_ctx *tc) while ((ext = trb_mod_ext_iter(tc, &i))) { struct lyspr_tree_ctx plug_ctx = {0}; - rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx); + rc = tro_ext_printer_tree(tc->lysc_tree, ext, &plug_ctx, &ignore); LY_CHECK_ERR_GOTO(rc, tc->last_error = rc, end); - if (!plug_ctx.schemas) { + if (!plug_ctx.schemas || ignore) { + ignore = 0; continue; } |