]> git.pld-linux.org Git - packages/calibre.git/blob - icu68.patch
icu rebuild
[packages/calibre.git] / icu68.patch
1 From ca0aa5f6960c09e5cf5cb20249f895628fd97449 Mon Sep 17 00:00:00 2001
2 From: Heiko Becker <heirecka@exherbo.org>
3 Date: Sat, 5 Dec 2020 11:30:42 +0100
4 Subject: [PATCH] Fix build with ICU >= 68
5
6 ICU stopped defining the macros FALSE and TRUE in its headers with 68:
7 https://github.com/unicode-org/icu/commit/c3fe7e09d844
8 ---
9  src/calibre/utils/icu.c     |  6 ++++--
10  src/calibre/utils/matcher.c | 18 ++++++++----------
11  2 files changed, 12 insertions(+), 12 deletions(-)
12
13 diff --git a/src/calibre/utils/icu.c b/src/calibre/utils/icu.c
14 index 62d05de3101..36902dbdd25 100644
15 --- a/src/calibre/utils/icu.c
16 +++ b/src/calibre/utils/icu.c
17 @@ -1,5 +1,7 @@
18  #include "icu_calibre_utils.h"
19  
20 +#include <stdbool.h>
21 +
22  #define UPPER_CASE 0
23  #define LOWER_CASE 1
24  #define TITLE_CASE 2
25 @@ -238,14 +240,14 @@ icu_Collator_contains(icu_Collator *self, PyObject *args) {
26  
27      a = python_to_icu(a_, &asz);
28      if (a == NULL) goto end;
29 -    if (asz == 0) { found = TRUE; goto end; }
30 +    if (asz == 0) { found = true; goto end; }
31      b = python_to_icu(b_, &bsz);
32      if (b == NULL) goto end;
33  
34      search = usearch_openFromCollator(a, asz, b, bsz, self->collator, NULL, &status);
35      if (U_SUCCESS(status)) {
36          pos = usearch_first(search, &status);
37 -        if (pos != USEARCH_DONE) found = TRUE;
38 +        if (pos != USEARCH_DONE) found = true;
39      }
40  end:
41      if (search != NULL) usearch_close(search);
42 diff --git a/src/calibre/utils/matcher.c b/src/calibre/utils/matcher.c
43 index f38a7082cee..72715cc0ae3 100644
44 --- a/src/calibre/utils/matcher.c
45 +++ b/src/calibre/utils/matcher.c
46 @@ -9,15 +9,13 @@
47  #define NO_PYTHON_TO_ICU32
48  #include "icu_calibre_utils.h"
49  #include <float.h>
50 +#include <stdbool.h>
51  
52  #ifdef _MSC_VER
53  // inline does not work with the visual studio C compiler
54  #define inline
55  #endif
56  
57 -typedef unsigned char bool;
58 -#define TRUE 1
59 -#define FALSE 0
60  #define MAX(x, y) ((x > y) ? x : y)
61  #define nullfree(x) if(x != NULL) free(x); x = NULL;
62  
63 @@ -240,10 +238,10 @@ static bool create_searches(UStringSearch **searches, UChar *haystack, int32_t h
64          U16_FWD_1(needle, i, needle_len);
65          if (pos == i) break;
66          searches[pos] = usearch_openFromCollator(needle + pos, i - pos, haystack, haystack_len, collator, NULL, &status);
67 -        if (U_FAILURE(status)) { PyErr_SetString(PyExc_ValueError, u_errorName(status)); searches[pos] = NULL; return FALSE; }
68 +        if (U_FAILURE(status)) { PyErr_SetString(PyExc_ValueError, u_errorName(status)); searches[pos] = NULL; return false; }
69      }
70  
71 -    return TRUE;
72 +    return true;
73  }
74  
75  static void free_searches(UStringSearch **searches, int32_t count) {
76 @@ -259,14 +257,14 @@ static bool match(UChar **items, int32_t *item_lengths, uint32_t item_count, UCh
77      int32_t i = 0, maxhl = 0;
78      int32_t r = 0, *positions = NULL;
79      MatchInfo *matches = NULL;
80 -    bool ok = FALSE;
81 +    bool ok = false;
82      MemoryItem ***memo = NULL;
83      int32_t needle_len = u_strlen(needle);
84      UStringSearch **searches = NULL;
85  
86      if (needle_len <= 0 || item_count <= 0) {
87          for (i = 0; i < (int32_t)item_count; i++) match_results[i].score = 0.0;
88 -        ok = TRUE;
89 +        ok = true;
90          goto end;
91      }
92  
93 @@ -289,7 +287,7 @@ static bool match(UChar **items, int32_t *item_lengths, uint32_t item_count, UCh
94  
95      if (maxhl <= 0) {
96          for (i = 0; i < (int32_t)item_count; i++) match_results[i].score = 0.0;
97 -        ok = TRUE;
98 +        ok = true;
99          goto end;
100      }
101  
102 @@ -308,7 +306,7 @@ static bool match(UChar **items, int32_t *item_lengths, uint32_t item_count, UCh
103          convert_positions(positions, final_positions + i * needle_char_len, matches[i].haystack, needle_char_len, needle_len, match_results[i].score);
104      }
105  
106 -    ok = TRUE;
107 +    ok = true;
108  end:
109      nullfree(positions);
110      nullfree(stack.items);
111 @@ -401,7 +399,7 @@ static PyObject *
112  Matcher_calculate_scores(Matcher *self, PyObject *args) {
113      int32_t *final_positions = NULL, *p;
114      Match *matches = NULL;
115 -    bool ok = FALSE;
116 +    bool ok = false;
117      uint32_t i = 0, needle_char_len = 0, j = 0;
118      PyObject *items = NULL, *score = NULL, *positions = NULL, *pneedle = NULL;
119      UChar *needle = NULL;
This page took 0.03061 seconds and 3 git commands to generate.