vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit a930302453082215ecdebea541359df97ee9d0e7 parent 5296f94cd259520647d8a8c341a0c609ca1d0aa9 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 4 Oct 2020 20:04:55 +0200 text: mark return value of text_iterator_text as const Diffstat:
| M | text.c | | | 8 | ++++---- |
| M | text.h | | | 2 | +- |
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/text.c b/text.c @@ -1412,7 +1412,7 @@ Iterator text_iterator_get(const Text *txt, size_t pos) { bool text_iterator_byte_get(const Iterator *it, char *b) { if (text_iterator_valid(it)) { - Text *txt = text_iterator_text(it); + const Text *txt = text_iterator_text(it); if (it->start <= it->text && it->text < it->end) { *b = *it->text; return true; @@ -1435,7 +1435,7 @@ bool text_iterator_prev(Iterator *it) { return text_iterator_init(it, it->pos-off, it->piece ? it->piece->prev : NULL, len); } -Text *text_iterator_text(const Iterator *it) { +const Text *text_iterator_text(const Iterator *it) { return it->piece ? it->piece->text : NULL; } @@ -1555,7 +1555,7 @@ bool text_iterator_char_next(Iterator *it, char *c) { if (!text_iterator_codepoint_next(it, c)) return false; mbstate_t ps = { 0 }; - Text *txt = text_iterator_text(it); + const Text *txt = text_iterator_text(it); for (;;) { char buf[MB_LEN_MAX]; size_t len = text_bytes_get(txt, it->pos, sizeof buf, buf); @@ -1581,7 +1581,7 @@ bool text_iterator_char_next(Iterator *it, char *c) { bool text_iterator_char_prev(Iterator *it, char *c) { if (!text_iterator_codepoint_prev(it, c)) return false; - Text *txt = text_iterator_text(it); + const Text *txt = text_iterator_text(it); for (;;) { char buf[MB_LEN_MAX]; size_t len = text_bytes_get(txt, it->pos, sizeof buf, buf); diff --git a/text.h b/text.h @@ -250,7 +250,7 @@ char *text_bytes_alloc0(const Text*, size_t pos, size_t len); * @{ */ Iterator text_iterator_get(const Text*, size_t pos); -Text *text_iterator_text(const Iterator*); +const Text *text_iterator_text(const Iterator*); bool text_iterator_valid(const Iterator*); bool text_iterator_has_next(const Iterator*); bool text_iterator_has_prev(const Iterator*);