diff options
Diffstat (limited to 'src/segtree.c')
-rw-r--r-- | src/segtree.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/segtree.c b/src/segtree.c index 1a21c6c1..c169f8d1 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -329,13 +329,15 @@ static bool interval_conflict(const struct elementary_interval *e1, { if (mpz_cmp(e1->left, e2->left) <= 0 && mpz_cmp(e1->right, e2->left) >= 0 && - mpz_cmp(e1->size, e2->size) == 0) + mpz_cmp(e1->size, e2->size) == 0 && + !expr_cmp(e1->expr->right, e2->expr->right)) return true; else return false; } -static void set_to_segtree(struct expr *set, struct seg_tree *tree) +static int set_to_segtree(struct list_head *msgs, struct expr *set, + struct seg_tree *tree) { struct elementary_interval *intervals[set->size]; struct elementary_interval *ei; @@ -365,14 +367,19 @@ static void set_to_segtree(struct expr *set, struct seg_tree *tree) * Insert elements into tree */ for (n = 0; n < set->size; n++) { - if (n < set->size - 1 && + if (set->set_flags & SET_F_MAP && + n < set->size - 1 && interval_conflict(intervals[n], intervals[n+1])) - pr_debug("conflict\n"); + return expr_binary_error(msgs, + intervals[n]->expr, + intervals[n+1]->expr, + "conflicting intervals specified"); ei_insert(tree, intervals[n]); } mpz_clear(high); mpz_clear(low); + return 0; } static void segtree_linearize(struct list_head *list, struct seg_tree *tree) @@ -461,14 +468,15 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree, compound_expr_add(set, expr); } -void set_to_intervals(struct set *set) +int set_to_intervals(struct list_head *errs, struct set *set) { struct elementary_interval *ei, *next; struct seg_tree tree; LIST_HEAD(list); seg_tree_init(&tree, set); - set_to_segtree(set->init, &tree); + if (set_to_segtree(errs, set->init, &tree) < 0) + return -1; segtree_linearize(&list, &tree); list_for_each_entry_safe(ei, next, &list, list) { @@ -485,6 +493,7 @@ void set_to_intervals(struct set *set) expr_print(set->init); pr_debug("\n"); } + return 0; } static bool range_is_prefix(const mpz_t range) |