aboutsummaryrefslogtreecommitdiffstats
path: root/src/ucl
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-24 22:12:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-24 22:12:44 +0000
commitfd2259322f17d95700c9eea1d83710a564a42a0a (patch)
treeb124ea1dc50dd3fc192528606f1db667fb10eade /src/ucl
parentcfbcd61e076af28f8ac0aeedc15fd871ef393bc2 (diff)
downloadrspamd-fd2259322f17d95700c9eea1d83710a564a42a0a.tar.gz
rspamd-fd2259322f17d95700c9eea1d83710a564a42a0a.zip
Import from libucl.
Diffstat (limited to 'src/ucl')
-rw-r--r--src/ucl/src/ucl_parser.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ucl/src/ucl_parser.c b/src/ucl/src/ucl_parser.c
index f93886427..2e4816874 100644
--- a/src/ucl/src/ucl_parser.c
+++ b/src/ucl/src/ucl_parser.c
@@ -1393,6 +1393,7 @@ ucl_state_machine (struct ucl_parser *parser)
struct ucl_chunk *chunk = parser->chunks;
struct ucl_stack *st;
const unsigned char *p, *c = NULL, *macro_start = NULL;
+ unsigned char *macro_escaped;
size_t macro_len = 0;
struct ucl_macro *macro = NULL;
@@ -1495,7 +1496,8 @@ ucl_state_machine (struct ucl_parser *parser)
/* We got macro name */
HASH_FIND (hh, parser->macroes, c, (p - c), macro);
if (macro == NULL) {
- ucl_set_err (chunk, UCL_EMACRO, "unknown macro", &parser->err);
+ ucl_create_err (&parser->err, "error on line %d at column %d: unknown macro: '%.*s', character: '%c'",
+ chunk->line, chunk->column, (int)(p - c), c, *chunk->pos);
parser->state = UCL_STATE_ERROR;
return false;
}
@@ -1523,9 +1525,19 @@ ucl_state_machine (struct ucl_parser *parser)
parser->state = UCL_STATE_ERROR;
return false;
}
- parser->state = parser->prev_state;
- if (!macro->handler (macro_start, macro_len, macro->ud)) {
- return false;
+ macro_len = ucl_expand_variable (parser, &macro_escaped, macro_start, macro_len);
+ parser->state = UCL_STATE_AFTER_VALUE;
+ if (macro_escaped == macro_start) {
+ if (!macro->handler (macro_start, macro_len, macro->ud)) {
+ return false;
+ }
+ }
+ else {
+ if (!macro->handler (macro_escaped, macro_len, macro->ud)) {
+ UCL_FREE (macro_len + 1, macro_escaped);
+ return false;
+ }
+ UCL_FREE (macro_len + 1, macro_escaped);
}
p = chunk->pos;
break;