aboutsummaryrefslogtreecommitdiff
path: root/jimregexp.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-06-05 08:34:43 +1000
committerSteve Bennett <steveb@workware.net.au>2011-06-05 08:34:43 +1000
commit9049b0e26eb017529d11c9b2375d978c94a04c20 (patch)
tree5ec25b899bbb19cff5cb13e4c050967a765e63dd /jimregexp.c
parentca9506bfcc6143a617b1b4579e0b304a3bbf00f4 (diff)
downloadjimtcl-9049b0e26eb017529d11c9b2375d978c94a04c20.zip
jimtcl-9049b0e26eb017529d11c9b2375d978c94a04c20.tar.gz
jimtcl-9049b0e26eb017529d11c9b2375d978c94a04c20.tar.bz2
Fix simple * and + case for utf-8
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jimregexp.c')
-rw-r--r--jimregexp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/jimregexp.c b/jimregexp.c
index 8b78033..61fbb52 100644
--- a/jimregexp.c
+++ b/jimregexp.c
@@ -1505,14 +1505,16 @@ static int regmatch(regex_t *preg, const int *prog)
min = (OP(scan) == STARMIN) ? 0 : 1;
save = preg->reginput;
max = regrepeat(preg, OPERAND(scan));
- while (min < max) {
+ while (min <= max) {
int ch;
- preg->reginput = save + min;
+ preg->reginput = save + utf8_index(save, min);
reg_utf8_tounicode_case(preg->reginput, &ch, (preg->cflags & REG_ICASE));
/* If it could work, try it. */
- if (reg_iseol(preg, nextch) || ch == nextch)
- if (regmatch(preg, next))
+ if (reg_iseol(preg, nextch) || ch == nextch) {
+ if (regmatch(preg, next)) {
return(1);
+ }
+ }
/* Couldn't or didn't, add one more */
min++;
}
@@ -1539,6 +1541,7 @@ static int regmatch(regex_t *preg, const int *prog)
no = regrepeat(preg, OPERAND(scan));
while (no >= min) {
int ch;
+ preg->reginput = save + utf8_index(save, no);
reg_utf8_tounicode_case(preg->reginput, &ch, (preg->cflags & REG_ICASE));
/* If it could work, try it. */
if (reg_iseol(preg, nextch) || ch == nextch)
@@ -1546,7 +1549,6 @@ static int regmatch(regex_t *preg, const int *prog)
return(1);
/* Couldn't or didn't -- back up. */
no--;
- preg->reginput = save + no;
}
return(0);
}