From 27ed764fa513ea55f92ea1e6be500fb22b30007b Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 28 Oct 2019 07:40:57 +1000 Subject: regexp: Fix -indices in the utf-8 case The calculation of the end index was wrong. Signed-off-by: Steve Bennett --- jim-regexp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'jim-regexp.c') diff --git a/jim-regexp.c b/jim-regexp.c index 3134598..b0411f8 100644 --- a/jim-regexp.c +++ b/jim-regexp.c @@ -284,7 +284,7 @@ int Jim_RegexpCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (opt_indices) { /* rm_so and rm_eo are byte offsets. We need char offsets */ int so = utf8_strlen(source_str, pmatch[j].rm_so); - int eo = utf8_strlen(source_str + pmatch[j].rm_so, pmatch[j].rm_eo); + int eo = utf8_strlen(source_str, pmatch[j].rm_eo); Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, offset + so)); Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, offset + eo - 1)); } -- cgit v1.1