context FEATURE public API for parsing schemas
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 8c907e5..805ef4f 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -2242,9 +2242,10 @@
buf = malloc(word_len + 2);
}
LY_CHECK_ERR_RET(!buf, LOGMEM(ctx->ctx), LY_EMEM);
- memmove(buf + 1, word, word_len + 1);
- word[0] = 0x06;
- restr->arg = lydict_insert_zc(ctx->ctx, word);
+ memmove(buf + 1, word, word_len);
+ buf[0] = 0x06; /* pattern's default regular-match flag */
+ buf[word_len + 1] = '\0'; /* terminating NULL byte */
+ restr->arg = lydict_insert_zc(ctx->ctx, buf);
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret) {
LY_CHECK_RET(ret);
@@ -4628,7 +4629,7 @@
size_t word_len;
enum yang_keyword kw;
struct lysp_module *mod = NULL;
- struct ly_parser_ctx context;
+ struct ly_parser_ctx context = {0};
context.ctx = ctx;
context.line = 1;
@@ -4666,6 +4667,9 @@
}
assert(!buf);
+ /* make sure that the newest revision is at position 0 */
+ lysp_sort_revisions(mod->revs);
+
*mod_p = mod;
return ret;