From 530e4d9b7896e5abee079687ea19ed63f8d5c73b Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Thu, 6 Jun 2024 18:43:54 +0200 Subject: [PATCH] csvparser/filterx: change parse_csv() "delimiters" arg to singular To match format_csv() Signed-off-by: Balazs Scheidler --- modules/csvparser/filterx-func-parse-csv.c | 6 +++--- modules/csvparser/filterx-func-parse-csv.h | 4 ++-- modules/csvparser/tests/test_filterx_func_parse_csv.c | 6 +++--- tests/light/functional_tests/filterx/test_filterx.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/csvparser/filterx-func-parse-csv.c b/modules/csvparser/filterx-func-parse-csv.c index d1593026f7..f2e0df95af 100644 --- a/modules/csvparser/filterx-func-parse-csv.c +++ b/modules/csvparser/filterx-func-parse-csv.c @@ -209,17 +209,17 @@ _extract_opts(FilterXFunctionParseCSV *self, FilterXFunctionArgs *args, GError * gboolean flag_err = FALSE; gboolean flag_val = FALSE; - value = filterx_function_args_get_named_literal_string(args, FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS, &len, &exists); + value = filterx_function_args_get_named_literal_string(args, FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER, &len, &exists); if (exists) { if (len < 1) { - error_str = FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS " can not be empty"; + error_str = FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER " can not be empty"; goto error; } if (!value) { - error_str = FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS " must be a string literal"; + error_str = FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER " must be a string literal"; goto error; } csv_scanner_options_set_delimiters(&self->options, value); diff --git a/modules/csvparser/filterx-func-parse-csv.h b/modules/csvparser/filterx-func-parse-csv.h index c21f93656d..7909d59bdc 100644 --- a/modules/csvparser/filterx-func-parse-csv.h +++ b/modules/csvparser/filterx-func-parse-csv.h @@ -27,13 +27,13 @@ #include "filterx/expr-function.h" #define FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS "columns" -#define FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS "delimiters" +#define FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER "delimiter" #define FILTERX_FUNC_PARSE_CSV_ARG_NAME_DIALECT "dialect" #define FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRIP_WHITESPACES "strip_whitespaces" #define FILTERX_FUNC_PARSE_CSV_ARG_NAME_GREEDY "greedy" #define FILTERX_FUNC_PARSE_CSV_USAGE "Usage: parse_csv(msg_str [" \ FILTERX_FUNC_PARSE_CSV_ARG_NAME_COLUMNS"=json_array, " \ - FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS"=string, " \ + FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER"=string, " \ FILTERX_FUNC_PARSE_CSV_ARG_NAME_DIALECT"=string, " \ FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRIP_WHITESPACES"=boolean, " \ FILTERX_FUNC_PARSE_CSV_ARG_NAME_GREEDY"=boolean])" diff --git a/modules/csvparser/tests/test_filterx_func_parse_csv.c b/modules/csvparser/tests/test_filterx_func_parse_csv.c index a54e9d46c9..86562e0a04 100644 --- a/modules/csvparser/tests/test_filterx_func_parse_csv.c +++ b/modules/csvparser/tests/test_filterx_func_parse_csv.c @@ -203,7 +203,7 @@ Test(filterx_func_parse_csv, test_optional_argument_delimiters) GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, filterx_literal_new(filterx_string_new("foo bar+baz;tik|tak:toe", -1)))); - args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS, + args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER, filterx_literal_new(filterx_string_new(" +;", -1)))); GError *err = NULL; @@ -329,7 +329,7 @@ Test(filterx_func_parse_csv, test_optional_argument_flag_strip_whitespace) GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, filterx_literal_new(filterx_string_new(" foo , bar , baz , tik tak toe", -1)))); - args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS, + args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER, filterx_literal_new(filterx_string_new(",", -1)))); // delimiter args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRIP_WHITESPACES, @@ -362,7 +362,7 @@ Test(filterx_func_parse_csv, test_optional_argument_flag_not_to_strip_whitespace GList *args = NULL; args = g_list_append(args, filterx_function_arg_new(NULL, filterx_literal_new(filterx_string_new(" foo , bar , baz , tik tak toe", -1)))); - args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITERS, + args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER, filterx_literal_new(filterx_string_new(",", -1)))); // delimiter args = g_list_append(args, filterx_function_arg_new(FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRIP_WHITESPACES, diff --git a/tests/light/functional_tests/filterx/test_filterx.py b/tests/light/functional_tests/filterx/test_filterx.py index bcbe857320..46b1b0598a 100644 --- a/tests/light/functional_tests/filterx/test_filterx.py +++ b/tests/light/functional_tests/filterx/test_filterx.py @@ -1422,7 +1422,7 @@ def test_parse_csv_optional_arg_delimiters(config, syslog_ng): (file_true, file_false) = create_config( config, """ custom_message = "foo bar,baz.tik;tak!toe"; - $MSG = parse_csv(custom_message, delimiters=" ,."); + $MSG = parse_csv(custom_message, delimiter=" ,."); """, ) syslog_ng.start(config) @@ -1466,7 +1466,7 @@ def test_parse_csv_optional_arg_strip_whitespace(config, syslog_ng): (file_true, file_false) = create_config( config, """ custom_message = " foo , bar , baz, tik, tak, toe "; - $MSG = parse_csv(custom_message, delimiters=",", strip_whitespace=true); + $MSG = parse_csv(custom_message, delimiter=",", strip_whitespace=true); """, ) syslog_ng.start(config)