X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=49cd139dbd76bd1e4505b3184194d6066a1be11b;hb=34e095d9e7c605ded713203f21e4f00c8d6b6d44;hp=48b9bf3d764d2b12177382862061d427ad3e2a53;hpb=7aee817a090f1f825e68c3a0288a373c52e16e03;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index 48b9bf3d..49cd139d 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 @@ -65,6 +65,9 @@ extern char *c_file; %type statement_list %type entire_file +/* pass an verbose, specific error message to yyerror() */ +%error-verbose + %% string: QUOTED_STRING {$$ = unquote ($1);} @@ -109,6 +112,12 @@ option: ; block_begin: + OPENBRAC identifier CLOSEBRAC EOL + { + memset (&$$, '\0', sizeof ($$)); + $$.key = $2; + } + | OPENBRAC identifier argument_list CLOSEBRAC EOL { memset (&$$, '\0', sizeof ($$)); @@ -151,7 +160,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)); @@ -160,7 +169,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; @@ -213,8 +222,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++)