From bd90afc43b0cf343eaad75930f3dab8db3eea6bb Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 4 Oct 2021 22:17:53 +0200 Subject: [PATCH] line: add new option "comment_prefix" --- lib/formats/line.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/formats/line.cpp b/lib/formats/line.cpp index 0829878ae..1437b54dd 100644 --- a/lib/formats/line.cpp +++ b/lib/formats/line.cpp @@ -141,13 +141,15 @@ void LineFormat::parse(json_t *json) int ret; json_error_t err; const char *delim = nullptr; + const char *com = nullptr; int header = -1; int skip = -1; - ret = json_unpack_ex(json, &err, 0, "{ s?: s, s?: b, s?: b }", + ret = json_unpack_ex(json, &err, 0, "{ s?: s, s?: b, s?: b, s?: s }", "delimiter", &delim, "header", &header, - "skip_first_line", &skip + "skip_first_line", &skip, + "comment_prefix", &com ); if (ret) throw ConfigError(json, err, "node-config-format-line", "Failed to parse format configuration"); @@ -159,6 +161,13 @@ void LineFormat::parse(json_t *json) delimiter = delim[0]; } + if (com) { + if (strlen(com) != 1) + throw ConfigError(json, "node-config-format-line-comment_prefix", "Comment prefix must be a single character!"); + + comment = com[0]; + } + if (header >= 0) print_header = header;