projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.8'
[collectd.git]
/
src
/
liboconfig
/
parser.y
diff --git
a/src/liboconfig/parser.y
b/src/liboconfig/parser.y
index
0494107
..
1b2d6cc
100644
(file)
--- a/
src/liboconfig/parser.y
+++ b/
src/liboconfig/parser.y
@@
-31,7
+31,7
@@
#include "aux_types.h"
static char *unquote (const char *orig);
#include "aux_types.h"
static char *unquote (const char *orig);
-static
int yyerror
(const char *s);
+static
void yyerror
(const char *s);
/* Lexer variables */
extern int yylineno;
/* Lexer variables */
extern int yylineno;
@@
-123,7
+123,7
@@
identifier:
option:
identifier argument_list EOL
{
option:
identifier argument_list EOL
{
- memset
(&$$, '\0', sizeof
($$));
+ memset
(&$$, 0, sizeof
($$));
$$.key = $1;
$$.values = $2.argument;
$$.values_num = $2.argument_num;
$$.key = $1;
$$.values = $2.argument;
$$.values_num = $2.argument_num;
@@
-133,13
+133,13
@@
option:
block_begin:
OPENBRAC identifier CLOSEBRAC EOL
{
block_begin:
OPENBRAC identifier CLOSEBRAC EOL
{
- memset
(&$$, '\0', sizeof
($$));
+ memset
(&$$, 0, sizeof
($$));
$$.key = $2;
}
|
OPENBRAC identifier argument_list CLOSEBRAC EOL
{
$$.key = $2;
}
|
OPENBRAC identifier argument_list CLOSEBRAC EOL
{
- memset
(&$$, '\0', sizeof
($$));
+ memset
(&$$, 0, sizeof
($$));
$$.key = $2;
$$.values = $3.argument;
$$.values_num = $3.argument_num;
$$.key = $2;
$$.values = $3.argument;
$$.values_num = $3.argument_num;
@@
-156,11
+156,11
@@
block_end:
block:
block_begin statement_list block_end
{
block:
block_begin statement_list block_end
{
- if (strcmp
($1.key, $3) != 0)
+ if (strcmp($1.key, $3) != 0)
{
{
- printf
("block_begin = %s; block_end = %s;\n", $1.key, $3);
- yyerror
("Block not closed..\n
");
-
exit (1)
;
+ printf("block_begin = %s; block_end = %s;\n", $1.key, $3);
+ yyerror
("block not closed
");
+
YYERROR
;
}
free ($3); $3 = NULL;
$$ = $1;
}
free ($3); $3 = NULL;
$$ = $1;
@@
-169,11
+169,11
@@
block:
}
| block_begin block_end
{
}
| block_begin block_end
{
- if (strcmp
($1.key, $2) != 0)
+ if (strcmp($1.key, $2) != 0)
{
{
- printf
("block_begin = %s; block_end = %s;\n", $1.key, $2);
- yyerror
("Block not closed..\n
");
-
exit (1)
;
+ printf("block_begin = %s; block_end = %s;\n", $1.key, $2);
+ yyerror
("block not closed
");
+
YYERROR
;
}
free ($2); $2 = NULL;
$$ = $1;
}
free ($2); $2 = NULL;
$$ = $1;
@@
-247,38
+247,37
@@
entire_file:
;
%%
;
%%
-static
int yyerror
(const char *s)
+static
void yyerror
(const char *s)
{
const char *text;
{
const char *text;
- if (*yytext == '\n')
+ if (yytext == NULL)
+ text = "<empty>";
+ else if (*yytext == '\n')
text = "<newline>";
else
text = yytext;
text = "<newline>";
else
text = yytext;
- fprintf
(stderr, "Parse error in file `%s', line %i near `%s': %s\n",
+ fprintf(stderr, "Parse error in file `%s', line %i near `%s': %s\n",
c_file, yylineno, text, s);
c_file, yylineno, text, s);
- return (-1);
} /* int yyerror */
static char *unquote (const char *orig)
{
char *ret = strdup (orig);
} /* int yyerror */
static char *unquote (const char *orig)
{
char *ret = strdup (orig);
- int len;
-
if (ret == NULL)
if (ret == NULL)
- return
(NULL)
;
+ return
NULL
;
- len = strlen (ret);
+
size_t
len = strlen (ret);
if ((len < 2) || (ret[0] != '"') || (ret[len - 1] != '"'))
if ((len < 2) || (ret[0] != '"') || (ret[len - 1] != '"'))
- return
(ret)
;
+ return
ret
;
len -= 2;
memmove (ret, ret + 1, len);
len -= 2;
memmove (ret, ret + 1, len);
- ret[len] =
'\0'
;
+ ret[len] =
0
;
- for (
in
t i = 0; i < len; i++)
+ for (
size_
t i = 0; i < len; i++)
{
if (ret[i] == '\\')
{
{
if (ret[i] == '\\')
{
@@
-287,5
+286,5
@@
static char *unquote (const char *orig)
}
}
}
}
- return
(ret)
;
+ return
ret
;
} /* char *unquote */
} /* char *unquote */