From 4f1a6c16c65c6c68bf1d1201dafc32d0923e93e6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Apr 2019 20:12:18 +0530 Subject: [PATCH] py3: Fix positions for non-BMP chars in the matcher All tests now pass on python3 --- src/calibre/utils/matcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/matcher.c b/src/calibre/utils/matcher.c index 2f9b9280d4..233d20bb86 100644 --- a/src/calibre/utils/matcher.c +++ b/src/calibre/utils/matcher.c @@ -164,7 +164,7 @@ static void convert_positions(int32_t *positions, int32_t *final_positions, UCha for (i = 0; i < byte_len && final_positions < end; i++) { if (positions[i] == -1) continue; #if PY_VERSION_HEX >= 0x03030000 - *final_positions = positions[i]; + *final_positions = u_countChar32(string, positions[i]); #else #ifdef Py_UNICODE_WIDE *final_positions = u_countChar32(string, positions[i]); @@ -538,4 +538,4 @@ CALIBRE_MODINIT_FUNC initmatcher(void) { #if PY_MAJOR_VERSION >= 3 return mod; #endif -} \ No newline at end of file +}