X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=8df2c6e5fb230eaed09db85d73e6ad8d5294a819;hb=6ba3ecd88fec2fa10b698b2a91eea2e5cc9ef027;hp=ea6ed0a099a2a822bd119dc6c16ebadcad594c25;hpb=06adec208286b5a136ffa5c5f3832c35e9f62844;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index ea6ed0a0..8df2c6e5 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -1,6 +1,6 @@ /** * oconfig - src/parser.y - * Copyright (C) 2007 Florian octo Forster + * Copyright (C) 2007,2008 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -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; @@ -204,8 +210,8 @@ static char *unquote (const char *orig) if ((len < 2) || (ret[0] != '"') || (ret[len - 1] != '"')) return (ret); - ret++; len -= 2; + memmove (ret, ret + 1, len); ret[len] = '\0'; for (i = 0; i < len; i++)