Skip to content

Commit 322c9d1

Browse files
committed
plugins ext UPDATE store quotes of ext inst argument
1 parent 8a43b23 commit 322c9d1

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/parser_yang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ parse_ext(struct lysp_yang_ctx *ctx, const char *ext_name, size_t ext_name_len,
991991
LY_CHECK_RET(lysdict_insert(PARSER_CTX(ctx), ext_name, ext_name_len, &e->name));
992992

993993
/* get optional argument */
994-
LY_CHECK_RET(get_argument(ctx, Y_MAYBE_STR_ARG, NULL, &word, &buf, &word_len));
994+
LY_CHECK_RET(get_argument(ctx, Y_MAYBE_STR_ARG, &e->flags, &word, &buf, &word_len));
995995
if (word) {
996996
INSERT_WORD_GOTO(ctx, buf, e->argument, word, word_len, ret, cleanup);
997997
}

src/plugins_exts.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ struct lysp_ext_instance {
412412
enum ly_stmt parent_stmt; /**< type of the parent statement */
413413
LY_ARRAY_COUNT_TYPE parent_stmt_index; /**< index of the stamenet in case the parent does not point to the parent
414414
statement directly and it is an array */
415-
uint16_t flags; /**< ::LYS_INTERNAL value (@ref snodeflags) */
415+
uint16_t flags; /**< ::LYS_INTERNAL value and ::LYS_SINGLEQUOTED or ::LYS_DOUBLEQUOTED
416+
describing the argument (@ref snodeflags) */
416417

417418
struct lysp_ext_substmt *substmts; /**< list of supported known YANG statements with the pointer to their
418419
parsed data ([sized array](@ref sizedarrays)) */

src/printer_yang.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Michal Vasko <mvasko@cesnet.cz>
55
* @brief YANG printer
66
*
7-
* Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
7+
* Copyright (c) 2015 - 2026 CESNET, z.s.p.o.
88
*
99
* This source code is licensed under BSD 3-Clause License (the "License").
1010
* You may not use this file except in compliance with the License.
@@ -288,6 +288,7 @@ yprp_extension_instance(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t
288288
{
289289
struct lysp_stmt *stmt;
290290
ly_bool child_presence;
291+
uint16_t flags = 0;
291292

292293
if ((ext->flags & LYS_INTERNAL) || (ext->parent_stmt != substmt) || (ext->parent_stmt_index != substmt_index)) {
293294
return;
@@ -296,9 +297,13 @@ yprp_extension_instance(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t
296297
ypr_open(pctx->out, flag);
297298

298299
if (ext->argument) {
299-
ly_print_(pctx->out, "%*s%s \"", INDENT, ext->name);
300-
ypr_encode(pctx->out, ext->argument, -1);
301-
ly_print_(pctx->out, "\"");
300+
if (!strchr(ext->argument, '\n')) {
301+
flags |= LYS_YPR_TEXT_SINGLELINE;
302+
}
303+
if (ext->flags & LYS_SINGLEQUOTED) {
304+
flags |= LYS_YPR_TEXT_SINGLEQUOTED;
305+
}
306+
ypr_text(pctx, ext->name, ext->argument, flags);
302307
} else {
303308
ly_print_(pctx->out, "%*s%s", INDENT, ext->name);
304309
}

0 commit comments

Comments
 (0)