}
}
+static void interval_expr_copy(struct expr *dst, struct expr *src)
+{
+ if (src->comment)
+ dst->comment = xstrdup(src->comment);
+ if (src->timeout)
+ dst->timeout = src->timeout;
+ if (src->expiration)
+ dst->expiration = src->expiration;
+ if (src->stmt) {
+ dst->stmt = src->stmt;
+ src->stmt = NULL;
+ }
+}
+
void interval_map_decompose(struct expr *set)
{
struct expr **elements, **ranges;
tmp = set_elem_expr_alloc(&low->location, tmp);
if (low->etype == EXPR_MAPPING) {
- if (low->left->comment)
- tmp->comment = xstrdup(low->left->comment);
- if (low->left->timeout)
- tmp->timeout = low->left->timeout;
- if (low->left->expiration)
- tmp->expiration = low->left->expiration;
- if (low->left->stmt) {
- tmp->stmt = low->left->stmt;
- low->left->stmt = NULL;
- }
+ interval_expr_copy(tmp, low->left);
tmp = mapping_expr_alloc(&tmp->location, tmp,
expr_clone(low->right));
} else {
- if (low->comment)
- tmp->comment = xstrdup(low->comment);
- if (low->timeout)
- tmp->timeout = low->timeout;
- if (low->expiration)
- tmp->expiration = low->expiration;
- if (low->stmt) {
- tmp->stmt = low->stmt;
- low->stmt = NULL;
- }
+ interval_expr_copy(tmp, low);
}
compound_expr_add(set, tmp);
prefix = set_elem_expr_alloc(&low->location, prefix);
if (low->etype == EXPR_MAPPING) {
- if (low->left->comment)
- prefix->comment = xstrdup(low->left->comment);
- if (low->left->timeout)
- prefix->timeout = low->left->timeout;
- if (low->left->expiration)
- prefix->expiration = low->left->expiration;
- if (low->left->stmt) {
- prefix->stmt = low->left->stmt;
- low->left->stmt = NULL;
- }
+ interval_expr_copy(prefix, low->left);
prefix = mapping_expr_alloc(&low->location, prefix,
expr_clone(low->right));
} else {
- if (low->comment)
- prefix->comment = xstrdup(low->comment);
- if (low->timeout)
- prefix->timeout = low->timeout;
- if (low->expiration)
- prefix->expiration = low->expiration;
- if (low->stmt) {
- prefix->stmt = low->stmt;
- low->stmt = NULL;
- }
+ interval_expr_copy(prefix, low);
}
compound_expr_add(set, prefix);
i = mapping_expr_alloc(&i->location, i,
expr_clone(low->right));
+ interval_expr_copy(i, low);
expr_free(low);
}