tregex: match patterns at utf-8 character beginnings - 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 979fba724b1590629fd7a6d45abdf68cc4f61490
(DIR) parent a7499618cabdde63d86afcb674bbca6f452cd540
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Mon, 23 May 2016 14:33:29 +0430
regex: match patterns at utf-8 character beginnings
Diffstat:
M regex.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/regex.c b/regex.c
t@@ -104,10 +104,6 @@ static int uc_len(char *s)
return 3;
if (~c & 0x08)
return 4;
- if (~c & 0x04)
- return 5;
- if (~c & 0x02)
- return 6;
return 1;
}
t@@ -587,7 +583,8 @@ int regexec(regex_t *preg, char *s, int nsub, regmatch_t psub[], int flg)
rs.flg = re->flg | flg;
rs.o = s;
while (*s) {
- rs.s = s++;
+ rs.s = s;
+ s += uc_len(s);
if (!re_recmatch(re, &rs, flg & REG_NOSUB ? 0 : nsub, psub))
return 0;
}