diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-24 21:47:55 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-25 00:55:19 +0200 |
| commit | e57b57e47266c1ac2fded9e84e8bf59cc8fadd7f (patch) | |
| tree | 47b5c3b54c0c245d8f98bfdb8b057930ddd0d482 | |
| parent | 0329e4aee01778f67c718cd827daa6bcfcef45f7 (diff) | |
| download | vis-e57b57e47266c1ac2fded9e84e8bf59cc8fadd7f.tar.gz vis-e57b57e47266c1ac2fded9e84e8bf59cc8fadd7f.tar.xz | |
text: add text_range_overlap
| -rw-r--r-- | text.c | 6 | ||||
| -rw-r--r-- | text.h | 2 |
2 files changed, 8 insertions, 0 deletions
@@ -1496,3 +1496,9 @@ Filerange text_range_new(size_t a, size_t b) { .end = MAX(a, b), }; } + +bool text_range_overlap(Filerange *r1, Filerange *r2) { + if (!text_range_valid(r1) || !text_range_valid(r2)) + return false; + return r1->start <= r2->end && r2->start <= r1->end; +} @@ -26,6 +26,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 overlap */ +bool text_range_overlap(Filerange*, Filerange*); typedef struct Text Text; typedef struct Piece Piece; |
