From: Florian Forster Date: Wed, 23 Jan 2008 10:22:53 +0000 (+0100) Subject: liboconfig: Allow the argument list of blocks to be empty. X-Git-Tag: collectd-4.3.0beta0~28 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c9230a2d9fb5cb7557edaf92cf3acd75d9573bf0;p=collectd.git liboconfig: Allow the argument list of blocks to be empty. This way the `' block doesn't need a bogus argument just to make the parser happy. --- diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index ea6ed0a0..837b6505 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -108,6 +108,12 @@ option: ; block_begin: + OPENBRAC identifier CLOSEBRAC EOL + { + memset (&$$, '\0', sizeof ($$)); + $$.key = $2; + } + | OPENBRAC identifier argument_list CLOSEBRAC EOL { memset (&$$, '\0', sizeof ($$)); @@ -150,7 +156,7 @@ statement_list: statement_list statement { $$ = $1; - if ($2.values_num > 0) + if (($2.values_num > 0) || ($2.children_num > 0)) { $$.statement_num++; $$.statement = realloc ($$.statement, $$.statement_num * sizeof (oconfig_item_t)); @@ -159,7 +165,7 @@ statement_list: } | statement { - if ($1.values_num > 0) + if (($1.values_num > 0) || ($1.children_num > 0)) { $$.statement = malloc (sizeof (oconfig_item_t)); $$.statement[0] = $1;