From 86fc424ff654898b23a88e5e9e48a8d4195afa65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 22 Apr 2022 20:32:53 +0530 Subject: [PATCH] Replace use of function deprecated in ICU 71 --- src/calibre/utils/icu.c | 7 +++++-- src/calibre/utils/icu_calibre_utils.h | 1 + src/calibre/utils/matcher.c | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/icu.c b/src/calibre/utils/icu.c index d06ea8606a..cb5e6e690a 100644 --- a/src/calibre/utils/icu.c +++ b/src/calibre/utils/icu.c @@ -499,10 +499,13 @@ icu_Collator_clone(icu_Collator *self, PyObject *args) { UCollator *collator; UErrorCode status = U_ZERO_ERROR; - int32_t bufsize = -1; icu_Collator *clone; - collator = ucol_safeClone(self->collator, NULL, &bufsize, &status); +#if U_ICU_VERSION_MAJOR_NUM > 70 + collator = ucol_clone(self->collator, &status); +#else + collator = ucol_safeClone(self->collator, NULL, NULL, &status); +#endif if (collator == NULL || U_FAILURE(status)) { PyErr_SetString(PyExc_Exception, "Failed to create collator."); diff --git a/src/calibre/utils/icu_calibre_utils.h b/src/calibre/utils/icu_calibre_utils.h index b9fe97ed1e..283a7f575d 100644 --- a/src/calibre/utils/icu_calibre_utils.h +++ b/src/calibre/utils/icu_calibre_utils.h @@ -11,6 +11,7 @@ #define PY_SSIZE_T_CLEAN #include #include +#include #include #include #include diff --git a/src/calibre/utils/matcher.c b/src/calibre/utils/matcher.c index 975c996f4f..82fa3f9722 100644 --- a/src/calibre/utils/matcher.c +++ b/src/calibre/utils/matcher.c @@ -364,7 +364,11 @@ Matcher_init(Matcher *self, PyObject *args, PyObject *kwds) if (!PyCapsule_CheckExact(collator)) { PyErr_SetString(PyExc_TypeError, "Collator must be a capsule"); return -1; } col = (UCollator*)PyCapsule_GetPointer(collator, NULL); if (col == NULL) return -1; +#if U_ICU_VERSION_MAJOR_NUM > 70 + self->collator = ucol_clone(self->collator, &status); +#else self->collator = ucol_safeClone(col, NULL, NULL, &status); +#endif col = NULL; if (U_FAILURE(status)) { self->collator = NULL; PyErr_SetString(PyExc_ValueError, u_errorName(status)); return -1; }