yanglint FEATURE use strict data parsing option by default
diff --git a/tools/lint/cmd_data.c b/tools/lint/cmd_data.c
index a78f06b..16c20c1 100644
--- a/tools/lint/cmd_data.c
+++ b/tools/lint/cmd_data.c
@@ -103,22 +103,22 @@
char **argv = NULL;
int opt, opt_index;
struct option options[] = {
- {"defaults", required_argument, NULL, 'd'},
- {"present", no_argument, NULL, 'e'},
- {"format", required_argument, NULL, 'f'},
- {"help", no_argument, NULL, 'h'},
- {"merge", no_argument, NULL, 'm'},
- {"output", required_argument, NULL, 'o'},
+ {"defaults", required_argument, NULL, 'd'},
+ {"present", no_argument, NULL, 'e'},
+ {"format", required_argument, NULL, 'f'},
+ {"help", no_argument, NULL, 'h'},
+ {"merge", no_argument, NULL, 'm'},
+ {"output", required_argument, NULL, 'o'},
{"operational", required_argument, NULL, 'O'},
- {"strict", no_argument, NULL, 's'},
- {"type", required_argument, NULL, 't'},
- {"xpath", required_argument, NULL, 'x'},
+ {"not-strict", no_argument, NULL, 'n'},
+ {"type", required_argument, NULL, 't'},
+ {"xpath", required_argument, NULL, 'x'},
{NULL, 0, NULL, 0}
};
uint8_t data_merge = 0;
uint32_t options_print = 0;
- uint32_t options_parse = 0;
+ uint32_t options_parse = YL_DEFAULT_DATA_PARSE_OPTIONS;
uint32_t options_validate = 0;
uint8_t data_type = 0;
uint8_t data_type_set = 0;
@@ -132,7 +132,7 @@
goto cleanup;
}
- while ((opt = getopt_long(argc, argv, "d:ef:hmo:O:r:st:x:", options, &opt_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "d:ef:hmo:O:r:nt:x:", options, &opt_index)) != -1) {
switch (opt) {
case 'd': /* --default */
if (!strcasecmp(optarg, "all")) {
@@ -194,8 +194,8 @@
case 'm': /* --merge */
data_merge = 1;
break;
- case 's': /* --strict */
- options_parse |= LYD_PARSE_STRICT;
+ case 'n': /* --not-strict */
+ options_parse &= ~LYD_PARSE_STRICT;
break;
case 't': /* --type */
if (data_type_set) {
diff --git a/tools/lint/common.h b/tools/lint/common.h
index ce4793d..85f7997 100644
--- a/tools/lint/common.h
+++ b/tools/lint/common.h
@@ -28,6 +28,11 @@
#define YL_DEFAULT_CTX_OPTIONS LY_CTX_NO_YANGLIBRARY
/**
+ * @brief Default data parsing flags.
+ */
+#define YL_DEFAULT_DATA_PARSE_OPTIONS LYD_PARSE_STRICT
+
+/**
* @brief log error message
*/
#define YLMSG_E(MSG, ...) \
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index aa22c27..08a008a 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -188,8 +188,9 @@
" Supplement to the --schema-node option to print information\n"
" only about a single node specified as PATH argument.\n\n"
- " -s, --strict Strict data parsing (do not skip unknown data), has no effect\n"
- " for schemas.\n\n"
+ " -n, --not-strict\n"
+ " Do not require strict data parsing (silently skip unknown data),\n"
+ " has no effect for schemas.\n\n"
" -e, --present Validate only with the schema modules whose data actually\n"
" exist in the provided input data files. Takes effect only\n"
@@ -382,7 +383,7 @@
{"path", required_argument, NULL, 'p'},
{"schema-node", required_argument, NULL, 'P'},
{"single-node", no_argument, NULL, 'q'},
- {"strict", no_argument, NULL, 's'},
+ {"not-strict", no_argument, NULL, 'n'},
{"type", required_argument, NULL, 't'},
{"version", no_argument, NULL, 'v'},
{"verbose", no_argument, NULL, 'V'},
@@ -392,10 +393,12 @@
uint16_t options_ctx = YL_DEFAULT_CTX_OPTIONS;
uint8_t data_type_set = 0;
+ c->data_parse_options = YL_DEFAULT_DATA_PARSE_OPTIONS;
+
#ifndef NDEBUG
- while ((opt = getopt_long(argc, argv, "d:Def:F:hilmyo:p:P:qst:vV", options, &opt_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "d:Def:F:hilmyo:p:P:qnt:vV", options, &opt_index)) != -1) {
#else
- while ((opt = getopt_long(argc, argv, "d:Def:F:G:hilmyo:p:P:qst:vV", options, &opt_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "d:Def:F:G:hilmyo:p:P:qnt:vV", options, &opt_index)) != -1) {
#endif
switch (opt) {
case 'd': /* --default */
@@ -511,8 +514,8 @@
c->schema_print_options |= LYS_PRINT_NO_SUBSTMT;
break;
- case 's': /* --strict */
- c->data_parse_options |= LYD_PARSE_STRICT;
+ case 'n': /* --not-strict */
+ c->data_parse_options &= ~LYD_PARSE_STRICT;
break;
case 'e': /* --present */
@@ -670,7 +673,7 @@
if (c->data_print_options && !c->data_out_format) {
YLMSG_W("data printer options specified, but the data output format is missing.\n");
}
- if ((c->data_parse_options || c->data_type) && !c->data_inputs.count) {
+ if (((c->data_parse_options != YL_DEFAULT_DATA_PARSE_OPTIONS) || c->data_type) && !c->data_inputs.count) {
YLMSG_W("Data parser options specified, but no data input file provided.\n");
}