mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Birdtest: Add function format in grammar for stringify expression
This commit is contained in:
@@ -563,6 +563,14 @@ f_rta_cow(void)
|
||||
(*f_rte)->attrs = rta_do_cow((*f_rte)->attrs, f_pool);
|
||||
}
|
||||
|
||||
static char *
|
||||
val_format_str(struct f_val v) {
|
||||
buffer b;
|
||||
LOG_BUFFER_INIT(b);
|
||||
val_format(v, &b);
|
||||
return lp_strdup(f_pool, b.start);
|
||||
}
|
||||
|
||||
static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
|
||||
|
||||
#define runtime(fmt, ...) do { \
|
||||
@@ -1477,6 +1485,13 @@ interpret(struct f_inst *what)
|
||||
|
||||
break;
|
||||
|
||||
case P('f','m'): /* Format */
|
||||
ONEARG;
|
||||
|
||||
res.type = T_STRING;
|
||||
res.val.s = val_format_str(v1);
|
||||
break;
|
||||
|
||||
case P('a','s'): /* Birdtest Assert */
|
||||
ONEARG;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user