diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-27 15:08:41 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-28 13:21:49 +0200 |
| commit | e15edaaa06b9a08aa4131588da6aa9adca610ea6 (patch) | |
| tree | 2f63441c5573466603190283eecd6206200f730b | |
| parent | b1302b29d9158bb62707203ea54fa5b13904ac15 (diff) | |
| download | vis-e15edaaa06b9a08aa4131588da6aa9adca610ea6.tar.gz vis-e15edaaa06b9a08aa4131588da6aa9adca610ea6.tar.xz | |
text-util: add text_range_contains
| -rw-r--r-- | text-util.c | 4 | ||||
| -rw-r--r-- | text-util.h | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/text-util.c b/text-util.c index 4139454..38e49e1 100644 --- a/text-util.c +++ b/text-util.c @@ -36,3 +36,7 @@ bool text_range_overlap(Filerange *r1, Filerange *r2) { return false; return r1->start <= r2->end && r2->start <= r1->end; } + +bool text_range_contains(Filerange *r, size_t pos) { + return text_range_valid(r) && r->start <= pos && pos <= r->end; +} diff --git a/text-util.h b/text-util.h index d81c645..8e9eedb 100644 --- a/text-util.h +++ b/text-util.h @@ -17,5 +17,7 @@ Filerange text_range_union(Filerange*, Filerange*); Filerange text_range_new(size_t a, size_t b); /* test whether two ranges overlap */ bool text_range_overlap(Filerange*, Filerange*); +/* test whether a given position is within a certain range */ +bool text_range_contains(Filerange*, size_t pos); -#endif
\ No newline at end of file +#endif |
