vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit e57f400e2d1a022a8043b385fb24e0840f60765b
parent f9e17429e0bf8d794c3c53090b6c1ca00cb637b1
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  9 Apr 2017 20:53:08 +0200

text: use MB_LEN_MAX instead of MB_CUR_MAX

Diffstat:
Mtext-motions.c | 5+++--
Mtext.c | 5+++--
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git 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; diff --git a/text.c b/text.c @@ -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 };