From 9049b0e26eb017529d11c9b2375d978c94a04c20 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 5 Jun 2011 08:34:43 +1000 Subject: Fix simple * and + case for utf-8 Signed-off-by: Steve Bennett --- jimregexp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'jimregexp.c') 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); } -- cgit v1.1