param-parse: allow duplicate map keys
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 20 Nov 2019 21:22:49 +0000 (16:22 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 20 Nov 2019 23:06:30 +0000 (18:06 -0500)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2423

src/param-parse/param-parse.c
tests/cli/params/test_params

index 566c61efea56761def7039812a811d41ae0747ef..dd40b4f01bd4ec9952eae0b8b4ffedc2e9ad9de1 100644 (file)
@@ -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:
index 7403fea719ea62d9d5c52af91f160f4b24831c4f..65ba0cec1352335e06b06a44b4837631df103384 100755 (executable)
@@ -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"
This page took 0.02522 seconds and 4 git commands to generate.