diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-02-25 19:57:02 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-02-25 19:57:02 +0100 |
| commit | 28a9ce8ad8a18eaabca7cc0674624d32318fb3d8 (patch) | |
| tree | 63f873557e193194079531626d809e0f62b47677 /text.c | |
| parent | 563c2abacfa1ae0af3323f98fb753c9c91f927f5 (diff) | |
| download | vis-28a9ce8ad8a18eaabca7cc0674624d32318fb3d8.tar.gz vis-28a9ce8ad8a18eaabca7cc0674624d32318fb3d8.tar.xz | |
text: add iterator accessor function which translates \r\n to \n
Diffstat (limited to 'text.c')
| -rw-r--r-- | text.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1379,6 +1379,17 @@ bool text_iterator_byte_get(Iterator *it, char *b) { return false; } +bool text_iterator_char_get(Iterator *it, char *c) { + bool ret = text_iterator_byte_get(it, c); + if (ret && *c == '\r') { + char d; + if (text_iterator_byte_next(it, &d) && d == '\n') + *c = '\n'; + return text_iterator_byte_prev(it, NULL); + } + return ret; +} + bool text_iterator_next(Iterator *it) { return text_iterator_init(it, it->pos, it->piece ? it->piece->next : NULL, 0); } |
