schema parsers BUGFIX handling includes in submodules
The result of parsing includes in submodule was incorrectly checked.
Instead of parsing submodule all the times, check the submodule presence
in main module and re-use it.
In YANG 1.0, main module is not required to include all the submodules.
Some of the submodules can be included via another submodule. In such a
case, the include record is now injected also into the main module to be
simply available and to unify it with YANG 1.1. Such a record is marked
as injected and it is not printed.
On the other hand, YANG 1.1 requires all the submodules to be present in
main module. So the situation described above raises error.
Fixes #1353
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 2935a67..324f3f2 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -751,7 +751,6 @@
lys_resolve_import_include(struct lys_parser_ctx *pctx, struct lysp_module *pmod)
{
struct lysp_import *imp;
- struct lysp_include *inc;
LY_ARRAY_COUNT_TYPE u, v;
pmod->parsing = 1;
@@ -768,12 +767,8 @@
}
}
}
- LY_ARRAY_FOR(pmod->includes, u) {
- inc = &pmod->includes[u];
- if (!inc->submodule) {
- LY_CHECK_RET(lysp_load_submodule(pctx, inc));
- }
- }
+ LY_CHECK_RET(lysp_load_submodules(pctx, pmod));
+
pmod->parsing = 0;
return LY_SUCCESS;