summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1d98288)
raw | patch | inline | side by side (parent: 1d98288)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 4 Nov 2014 22:36:11 +0000 (23:36 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 4 Nov 2014 22:36:11 +0000 (23:36 +0100) |
src/frontend/grammar.y | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 97be55d0c7dfa5b397fade235888bafe4f505a27..4dc6cb22411ce756991d07c0a01cd078d6949abd 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
void
sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
+void
+sdb_fe_yyerrorf(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *fmt, ...);
/* quick access to the current parse tree */
#define pt sdb_fe_yyget_extra(scanner)->parsetree
{
/* only accepted in default parse mode */
if (parser_mode != SDB_PARSE_DEFAULT) {
- char errmsg[1024];
- snprintf(errmsg, sizeof(errmsg),
+ sdb_fe_yyerrorf(&yylloc, scanner,
YY_("syntax error, unexpected statement, "
"expecting %s"), MODE_TO_STRING(parser_mode));
- sdb_fe_yyerror(&yylloc, scanner, errmsg);
sdb_object_deref(SDB_OBJ($3));
YYABORT;
}
{
/* only accepted in default parse mode */
if (parser_mode != SDB_PARSE_DEFAULT) {
- char errmsg[1024];
- snprintf(errmsg, sizeof(errmsg),
+ sdb_fe_yyerrorf(&yylloc, scanner,
YY_("syntax error, unexpected statement, "
"expecting %s"), MODE_TO_STRING(parser_mode));
- sdb_fe_yyerror(&yylloc, scanner, errmsg);
sdb_object_deref(SDB_OBJ($1));
YYABORT;
}
{
/* only accepted in condition parse mode */
if (! (parser_mode & SDB_PARSE_COND)) {
- char errmsg[1024];
- snprintf(errmsg, sizeof(errmsg),
+ sdb_fe_yyerrorf(&yylloc, scanner,
YY_("syntax error, unexpected condition, "
"expecting %s"), MODE_TO_STRING(parser_mode));
- sdb_fe_yyerror(&yylloc, scanner, errmsg);
sdb_object_deref(SDB_OBJ($1));
YYABORT;
}
{
/* only accepted in expression parse mode */
if (! (parser_mode & SDB_PARSE_EXPR)) {
- char errmsg[1024];
- snprintf(errmsg, sizeof(errmsg),
+ sdb_fe_yyerrorf(&yylloc, scanner,
YY_("syntax error, unexpected expression, "
"expecting %s"), MODE_TO_STRING(parser_mode));
- sdb_fe_yyerror(&yylloc, scanner, errmsg);
sdb_object_deref(SDB_OBJ($1));
YYABORT;
}
unit = sdb_strpunit($2);
if (! unit) {
- char errmsg[strlen($2) + 32];
- snprintf(errmsg, sizeof(errmsg),
+ sdb_fe_yyerrorf(&yylloc, scanner,
YY_("invalid time unit %s"), $2);
- sdb_fe_yyerror(&yylloc, scanner, errmsg);
free($2); $2 = NULL;
YYABORT;
}
sdb_log(SDB_LOG_ERR, "frontend: parse error: %s", msg);
} /* sdb_fe_yyerror */
+void
+sdb_fe_yyerrorf(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ sdb_vlog(SDB_LOG_ERR, fmt, ap);
+ va_end(ap);
+} /* sdb_fe_yyerrorf */
+
static sdb_store_matcher_t *
name_iter_matcher(int m_type, int type, const char *cmp,
sdb_store_expr_t *expr)