vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 603ba5e6a2b1b660f01d87cf07ddb6c3ff9b03ec parent 8299bb8f6e5bc69ccbd30f4da0e63c615f2f295a Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 28 Jul 2015 17:19:30 +0200 text-util: introduce text_range_equal Diffstat:
| M | text-util.c | | | 6 | ++++++ |
| M | text-util.h | | | 2 | ++ |
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/text-util.c b/text-util.c @@ -31,6 +31,12 @@ Filerange text_range_new(size_t a, size_t b) { }; } +bool text_range_equal(Filerange *r1, Filerange *r2) { + if (!text_range_valid(r1) && !text_range_valid(r2)) + return true; + return r1->start == r2->start && r1->end == r2->end; +} + bool text_range_overlap(Filerange *r1, Filerange *r2) { if (!text_range_valid(r1) || !text_range_valid(r2)) return false; diff --git a/text-util.h b/text-util.h @@ -15,6 +15,8 @@ Filerange text_range_empty(void); Filerange text_range_union(Filerange*, Filerange*); /* create new range [min(a,b), max(a,b)] */ Filerange text_range_new(size_t a, size_t b); +/* test whether two ranges are equal */ +bool text_range_equal(Filerange*, Filerange*); /* test whether two ranges overlap */ bool text_range_overlap(Filerange*, Filerange*); /* test whether a given position is within a certain range */