tmot: the number of matched utf-8 characters as length in lbuf_search() - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 174014fe69371a038454126b0b1b7fcc1d077540
(DIR) parent 6ec8f20a4a15db6ec888b4815d9b7eb426515dfa
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Mon, 15 Jun 2015 18:54:22 +0430
mot: the number of matched utf-8 characters as length in lbuf_search()
Diffstat:
M mot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/mot.c b/mot.c
t@@ -63,12 +63,12 @@ int lbuf_search(struct lbuf *lb, char *kw, int dir, int *r, int *o, int *len)
int off = dir > 0 && r0 == i ? uc_chr(s, o0 + 1) - s : 0;
int flg = off ? RE_NOTBOL : 0;
while (rset_find(re, s + off, 1, offs, flg) >= 0) {
- if (dir < 0 && r0 == i && off + offs[0] >= o0)
+ if (dir < 0 && r0 == i && uc_off(s, off + offs[0]) >= o0)
break;
found = 1;
*o = uc_off(s, off + offs[0]);
*r = i;
- *len = offs[1] - offs[0];
+ *len = uc_off(s + off + offs[0], offs[1] - offs[0]);
off += offs[1];
if (dir > 0)
break;