aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-07-28 17:19:30 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-07-28 17:19:30 +0200
commitf38ab16901a787aff37904c5f80e94f2371c7456 (patch)
tree27c250424dcd4366152642935e9d0ad6897e1db1
parent6d7aa204acaa326ce5ef1c74a7ae88875bc1752a (diff)
downloadvis-f38ab16901a787aff37904c5f80e94f2371c7456.tar.gz
vis-f38ab16901a787aff37904c5f80e94f2371c7456.tar.xz
text-util: introduce text_range_equal
-rw-r--r--text-util.c6
-rw-r--r--text-util.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/text-util.c b/text-util.c
index 38e49e1..2b48719 100644
--- 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
index 8e9eedb..80affd5 100644
--- 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 */