Skip to content

Commit

Permalink
text-util: add text_range_contains
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Jul 28, 2015
1 parent b1302b2 commit e15edaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions text-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion text-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif

0 comments on commit e15edaa

Please sign in to comment.