diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-04-09 20:53:08 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-04-09 20:53:08 +0200 |
| commit | 7530c6411b64c8a4a7790240315628ea94c7a6ba (patch) | |
| tree | 529413a6192874c88797a3252eea7c67893bd32c | |
| parent | f59bebc98fb19ca5c2a13288f0593395f3c0d6d1 (diff) | |
| download | vis-7530c6411b64c8a4a7790240315628ea94c7a6ba.tar.gz vis-7530c6411b64c8a4a7790240315628ea94c7a6ba.tar.xz | |
text: use MB_LEN_MAX instead of MB_CUR_MAX
| -rw-r--r-- | text-motions.c | 5 | ||||
| -rw-r--r-- | text.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/text-motions.c b/text-motions.c index 6221f31..4dd7b89 100644 --- a/text-motions.c +++ b/text-motions.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <wchar.h> #include <errno.h> +#include <limits.h> #include "text-motions.h" #include "text-util.h" #include "util.h" @@ -191,7 +192,7 @@ int text_line_width_get(Text *txt, size_t pos) { Iterator it = text_iterator_get(txt, bol); while (it.pos < pos) { - char buf[MB_CUR_MAX]; + char buf[MB_LEN_MAX]; size_t len = text_bytes_get(txt, it.pos, sizeof buf, buf); if (len == 0 || buf[0] == '\n') break; @@ -228,7 +229,7 @@ size_t text_line_width_set(Text *txt, size_t pos, int width) { Iterator it = text_iterator_get(txt, bol); for (;;) { - char buf[MB_CUR_MAX]; + char buf[MB_LEN_MAX]; size_t len = text_bytes_get(txt, it.pos, sizeof buf, buf); if (len == 0 || buf[0] == '\n') break; @@ -9,6 +9,7 @@ #include <wchar.h> #include <stdint.h> #include <libgen.h> +#include <limits.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> @@ -1470,7 +1471,7 @@ bool text_iterator_char_next(Iterator *it, char *c) { return false; mbstate_t ps = { 0 }; for (;;) { - char buf[MB_CUR_MAX]; + char buf[MB_LEN_MAX]; size_t len = text_bytes_get(it->piece->text, it->pos, sizeof buf, buf); wchar_t wc; size_t wclen = mbrtowc(&wc, buf, len, &ps); @@ -1495,7 +1496,7 @@ bool text_iterator_char_prev(Iterator *it, char *c) { if (!text_iterator_codepoint_prev(it, c)) return false; for (;;) { - char buf[MB_CUR_MAX]; + char buf[MB_LEN_MAX]; size_t len = text_bytes_get(it->piece->text, it->pos, sizeof buf, buf); wchar_t wc; mbstate_t ps = { 0 }; |
