schema parsers CHANGE unify name collisions error messages
Also move the error into a common category despite it is YANG or YIN.
diff --git a/src/common.h b/src/common.h
index 19ece23..958a753 100644
--- a/src/common.h
+++ b/src/common.h
@@ -159,6 +159,8 @@
#define LY_VCODE_INVAL_MINMAX LYVE_SEMANTICS, "Invalid combination of min-elements and max-elements: min value %u is bigger than the max value %u."
#define LY_VCODE_CIRC_WHEN LYVE_SEMANTICS, "When condition of \"%s\" includes a self-reference (referenced by when of \"%s\")."
#define LY_VCODE_DUMMY_WHEN LYVE_SEMANTICS, "When condition of \"%s\" is accessing its own conditional node."
+#define LY_VCODE_NAME_COL LYVE_SEMANTICS, "Name collision between %s of name \"%s\"."
+#define LY_VCODE_NAME2_COL LYVE_SEMANTICS, "Name collision between %s and %s of name \"%s\"."
#define LY_VCODE_INSTMT LYVE_SYNTAX_YANG, "Invalid keyword \"%s\"."
#define LY_VCODE_INCHILDSTMT LYVE_SYNTAX_YANG, "Invalid keyword \"%s\" as a child of \"%s\"."
@@ -185,7 +187,6 @@
#define LY_VCODE_UNEXP_ATTR LYVE_SYNTAX_YIN, "Unexpected attribute \"%.*s\" of \"%s\" element."
#define LY_VCODE_MAND_SUBELEM LYVE_SYNTAX_YIN, "Missing mandatory sub-element \"%s\" of \"%s\" element."
#define LY_VCODE_FIRT_SUBELEM LYVE_SYNTAX_YIN, "Sub-element \"%s\" of \"%s\" element must be defined as it's first sub-element."
-#define LY_VCODE_NAME_COL LYVE_SYNTAX_YIN, "Name collision between module and submodule of name \"%s\"."
#define LY_VCODE_SUBELEM_REDEF LYVE_SYNTAX_YIN, "Redefinition of \"%s\" sub-element in \"%s\" element."
#define LY_VCODE_XP_EOE LYVE_XPATH, "Unterminated string delimited with %c (%.15s)."
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 0019403..71dd843 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -1076,7 +1076,7 @@
/* submodules share the namespace with the module names, so there must not be
* a module of the same name in the context, no need for revision matching */
if (!strcmp(module_name, inc->name) || ly_ctx_get_module_latest(PARSER_CTX(ctx), inc->name)) {
- LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Name collision between module and submodule of name \"%s\".", inc->name);
+ LOGVAL_PARSER(ctx, LY_VCODE_NAME2_COL, "module", "submodule", inc->name);
return LY_EVALID;
}
@@ -4219,7 +4219,7 @@
* a submodule of the same name in the context, no need for revision matching */
dup = ly_ctx_get_submodule(PARSER_CTX(ctx), NULL, mod->mod->name, NULL);
if (dup) {
- LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Name collision between module and submodule of name \"%s\".", mod->mod->name);
+ LOGVAL_PARSER(ctx, LY_VCODE_NAME2_COL, "module", "submodule", mod->mod->name);
return LY_EVALID;
}
@@ -4424,7 +4424,7 @@
dup = ly_ctx_get_submodule(PARSER_CTX(ctx), NULL, submod->name, NULL);
/* main modules may have different revisions */
if (dup && strcmp(dup->mod->name, submod->mod->name)) {
- LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Name collision between submodules of name \"%s\".", dup->name);
+ LOGVAL_PARSER(ctx, LY_VCODE_NAME_COL, "submodules", dup->name);
return LY_EVALID;
}
diff --git a/src/parser_yin.c b/src/parser_yin.c
index f117f43..c13ce60 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -1747,7 +1747,7 @@
/* submodules share the namespace with the module names, so there must not be
* a module of the same name in the context, no need for revision matching */
if (!strcmp(inc_meta->name, inc->name) || ly_ctx_get_module_latest(ctx->xmlctx->ctx, inc->name)) {
- LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_NAME_COL, inc->name);
+ LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_NAME2_COL, "module", "submodule", inc->name);
return LY_EVALID;
}
@@ -3700,7 +3700,7 @@
* a submodule of the same name in the context, no need for revision matching */
dup = ly_ctx_get_submodule(ctx->xmlctx->ctx, NULL, mod->mod->name, NULL);
if (dup) {
- LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LYVE_SYNTAX_YANG, "Name collision between module and submodule of name \"%s\".", mod->mod->name);
+ LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_NAME2_COL, "module", "submodule", mod->mod->name);
return LY_EVALID;
}
@@ -3768,7 +3768,7 @@
* a submodule of the same name in the context, no need for revision matching */
dup = ly_ctx_get_submodule(ctx->xmlctx->ctx, NULL, submod->name, NULL);
if (dup && strcmp(dup->mod->name, submod->mod->name)) {
- LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LYVE_SYNTAX_YANG, "Name collision between submodules of name \"%s\".", dup->name);
+ LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_NAME_COL, "submodules", dup->name);
return LY_EVALID;
}