* tests/range-set-test.c: Also test the range_set_clone function.
2007-06-03 Ben Pfaff <blp@gnu.org>
+ * range-set.c (range_set_clone): New function.
+
* array.c (insert_range): New function.
(insert_element): New function.
(move_range): New function.
return rs;
}
+/* Creates and returns a clone of OLD range set in the given POOL
+ (which may be null). */
+struct range_set *
+range_set_clone (const struct range_set *old, struct pool *pool)
+{
+ struct range_set *new;
+ struct range_set_node *node;
+
+ new = range_set_create_pool (pool);
+ for (node = first_node (old); node != NULL; node = next_node (old, node))
+ insert_node (new, node->start, node->end);
+ return new;
+}
+
/* Destroys range set RS. */
void
range_set_destroy (struct range_set *rs)
struct range_set *range_set_create (void);
struct range_set *range_set_create_pool (struct pool *);
+struct range_set *range_set_clone (const struct range_set *, struct pool *);
void range_set_destroy (struct range_set *);
void range_set_insert (struct range_set *,
+2007-06-03 Ben Pfaff <blp@gnu.org>
+
+ * tests/range-set-test.c: Also test the range_set_clone function.
+
2007-05-06 Ben Pfaff <blp@gnu.org>
Abstract the documents within a dictionary a little better.
for (i = 0; i < positions + 1; i++)
for (j = i; j <= positions + 1; j++)
{
- struct range_set *rs;
+ struct range_set *rs, *rs2;
unsigned int final_pat;
rs = make_pattern (init_pat);
range_set_insert (rs, i, j - i);
final_pat = init_pat | bit_range (i, j - i);
check_pattern (rs, final_pat);
+ rs2 = range_set_clone (rs, NULL);
+ check_pattern (rs2, final_pat);
range_set_destroy (rs);
+ range_set_destroy (rs2);
}
}