From b1df972d4e6c35e54562fa27083632514d38d354 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 20 Nov 2019 16:22:49 -0500 Subject: [PATCH] param-parse: allow duplicate map keys It is a bit odd that this is accepted (the second value overwrites the first): -p a=3 -p a=4 but this isn't: -p a=3,a=4 Remove the check that prevents duplicate keys from being defined in a map. Change-Id: Id39e86bb48ac52c6714db3128b7d767f5347de64 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2423 --- src/param-parse/param-parse.c | 8 -------- tests/cli/params/test_params | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/param-parse/param-parse.c b/src/param-parse/param-parse.c index 566c61ef..dd40b4f0 100644 --- a/src/param-parse/param-parse.c +++ b/src/param-parse/param-parse.c @@ -500,14 +500,6 @@ int ini_handle_state(struct ini_parsing_state *state) g_string_assign(state->last_map_key, state->scanner->value.v_identifier); - if (bt_value_map_has_entry(state->params, - state->last_map_key->str)) { - g_string_append_printf(state->ini_error, - "Duplicate parameter key: `%s`\n", - state->last_map_key->str); - goto error; - } - state->expecting = INI_EXPECT_EQUAL; goto success; case INI_EXPECT_EQUAL: diff --git a/tests/cli/params/test_params b/tests/cli/params/test_params index 7403fea7..65ba0cec 100755 --- a/tests/cli/params/test_params +++ b/tests/cli/params/test_params @@ -65,7 +65,7 @@ expect_success 'float scientific notation' 'a=10.5e6, b=10.5E6, c=10.5e-6, d=10. '{a=10500000.0, b=10500000.0, c=1.05e-05, d=1.05e-05}' expect_success 'array' 'a=[1, [["hi",]]]' \ '{a=[1, [[hi]]]}' -expect_success 'map' 'a={},b={salut="la gang",comment="ca va",oh={x=2}}' \ +expect_success 'map' 'a=4,a={},b={salut="la gang",comment="ca va",oh={x=2}}' \ '{a={}, b={comment=ca va, oh={x=2}, salut=la gang}}' rm -f "$expected_file" -- 2.34.1