tmot: skipping zero-length matches 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 e7975f55419e9eea1dc579bcf0aa7e53b0db479b
(DIR) parent 234b9325f5437b813bad047f5bead5ec64335c87
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Fri, 14 Aug 2015 10:42:37 +0430
mot: skipping zero-length matches in lbuf_search()
Diffstat:
M mot.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/mot.c b/mot.c
t@@ -61,15 +61,16 @@ int lbuf_search(struct lbuf *lb, char *kw, int dir, int *r, int *o, int *len)
for (i = r0; !found && i >= 0 && i < lbuf_len(lb); i += dir) {
char *s = lbuf_get(lb, i);
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 && uc_off(s, off + offs[0]) >= o0)
+ while (rset_find(re, s + off, 1, offs,
+ off ? RE_NOTBOL : 0) >= 0) {
+ 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 = uc_off(s + off + offs[0], offs[1] - offs[0]);
- off += offs[1];
+ off += offs[1] > offs[0] ? offs[1] : offs[1] + 1;
if (dir > 0)
break;
}