From 8ed478ce46e82465302159400f64e7a100e3cd3f Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Mon, 5 Feb 2024 14:40:25 +0100 Subject: [PATCH] libutil: enable record output without separator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The separator line emitted by util_rec functions may not be suitable for all users. Fix this by making the hdr_sep parameter optional. Reviewed-by: Jan Höppner Signed-off-by: Peter Oberparleiter Signed-off-by: Steffen Eiden --- libutil/util_rec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libutil/util_rec.c b/libutil/util_rec.c index d9fd8ff7..0aec095e 100644 --- a/libutil/util_rec.c +++ b/libutil/util_rec.c @@ -111,7 +111,7 @@ const char *util_rec_fld_get_key(struct util_rec_fld *fld) /** * Create a new record with "wide" output format * - * @param[in] hdr_sep Header separator + * @param[in] hdr_sep Header separator or %NULL for no separator * * @returns Pointer to the created record */ @@ -121,7 +121,7 @@ struct util_rec *util_rec_new_wide(const char *hdr_sep) rec->list = util_list_new(struct util_rec_fld, node); rec->fmt.type = REC_FMT_WIDE; - rec->fmt.d.wide_p.hdr_sep = util_strdup(hdr_sep); + rec->fmt.d.wide_p.hdr_sep = hdr_sep ? util_strdup(hdr_sep) : NULL; rec->fmt.d.wide_p.argz_sep = ','; rec->fmt.indent = 0; return rec; @@ -249,7 +249,7 @@ static void rec_free_wide(struct util_rec *rec) /** * Create a new record with "long" output format * - * @param[in] hdr_sep Header separator + * @param[in] hdr_sep Header separator or %NULL for no separator * @param[in] col_sep Column separator * @param[in] key Primary key of record * @param[in] key_size Width of left column i.e. keys @@ -264,7 +264,7 @@ struct util_rec *util_rec_new_long(const char *hdr_sep, const char *col_sep, rec->list = util_list_new(struct util_rec_fld, node); rec->fmt.type = REC_FMT_LONG; - rec->fmt.d.long_p.hdr_sep = util_strdup(hdr_sep); + rec->fmt.d.long_p.hdr_sep = hdr_sep ? util_strdup(hdr_sep) : NULL; rec->fmt.d.long_p.col_sep = util_strdup(col_sep); rec->fmt.d.long_p.key = util_strdup(key); rec->fmt.d.long_p.key_size = key_size;