From 97047f979626011fa1a3288d4ea78e5cb39eb736 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Mon, 23 Sep 2019 14:31:57 +0300 Subject: [PATCH] pango-x: apply bsearch() workaround See issue https://github.com/termux/termux-packages/issues/4284. --- x11-packages/pango-x/bsearch-fix.patch | 88 ++++++++++++++++++++++++++ x11-packages/pango-x/build.sh | 1 + 2 files changed, 89 insertions(+) create mode 100644 x11-packages/pango-x/bsearch-fix.patch diff --git a/x11-packages/pango-x/bsearch-fix.patch b/x11-packages/pango-x/bsearch-fix.patch new file mode 100644 index 000000000..aee11b0e8 --- /dev/null +++ b/x11-packages/pango-x/bsearch-fix.patch @@ -0,0 +1,88 @@ +diff -uNr pango-1.44.6/pango/musl_bsearch.h pango-1.44.6.mod/pango/musl_bsearch.h +--- pango-1.44.6/pango/musl_bsearch.h 1970-01-01 03:00:00.000000000 +0300 ++++ pango-1.44.6.mod/pango/musl_bsearch.h 2019-09-23 14:15:30.721769563 +0300 +@@ -0,0 +1,23 @@ ++#include ++// ++// bsearch() implementation from Musl libc. ++// ++ ++static void *musl_bsearch(const void *key, const void *base, size_t nel, size_t width, int (*cmp)(const void *, const void *)) ++{ ++ void *try; ++ int sign; ++ while (nel > 0) { ++ try = (char *)base + width*(nel/2); ++ sign = cmp(key, try); ++ if (sign < 0) { ++ nel /= 2; ++ } else if (sign > 0) { ++ base = (char *)try + width; ++ nel -= nel/2+1; ++ } else { ++ return try; ++ } ++ } ++ return NULL; ++} +diff -uNr pango-1.44.6/pango/pango-color.c pango-1.44.6.mod/pango/pango-color.c +--- pango-1.44.6/pango/pango-color.c 2019-09-03 15:11:42.000000000 +0300 ++++ pango-1.44.6.mod/pango/pango-color.c 2019-09-23 14:15:01.798237443 +0300 +@@ -144,6 +144,7 @@ + */ + + #include "pango-color-table.h" ++#include "musl_bsearch.h" + + #define ISUPPER(c) ((c) >= 'A' && (c) <= 'Z') + #define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c)) +@@ -175,7 +176,7 @@ + { + ColorEntry *found; + +- found = bsearch (name, color_entries, G_N_ELEMENTS (color_entries), ++ found = musl_bsearch (name, color_entries, G_N_ELEMENTS (color_entries), + sizeof (ColorEntry), + compare_xcolor_entries); + if (found == NULL) +diff -uNr pango-1.44.6/pango/pango-emoji.c pango-1.44.6.mod/pango/pango-emoji.c +--- pango-1.44.6/pango/pango-emoji.c 2019-09-03 15:11:42.000000000 +0300 ++++ pango-1.44.6.mod/pango/pango-emoji.c 2019-09-23 14:14:46.718134698 +0300 +@@ -51,7 +51,7 @@ + + #include "pango-emoji-private.h" + #include "pango-emoji-table.h" +- ++#include "musl_bsearch.h" + + static int + interval_compare (const void *key, const void *elt) +@@ -78,7 +78,7 @@ + return FALSE; \ + */ \ + \ +- if (bsearch (GUINT_TO_POINTER (ch), \ ++ if (musl_bsearch (GUINT_TO_POINTER (ch), \ + _pango_##name##_table, \ + G_N_ELEMENTS (_pango_##name##_table), \ + sizeof _pango_##name##_table[0], \ +diff -uNr pango-1.44.6/pango/pango-language.c pango-1.44.6.mod/pango/pango-language.c +--- pango-1.44.6/pango/pango-language.c 2019-09-03 15:11:42.000000000 +0300 ++++ pango-1.44.6.mod/pango/pango-language.c 2019-09-23 14:14:16.651265104 +0300 +@@ -28,6 +28,7 @@ + + #include "pango-language.h" + #include "pango-impl-utils.h" ++#include "musl_bsearch.h" + + #ifdef HAVE_CORE_TEXT + #include +@@ -467,7 +468,7 @@ + + lang_str = pango_language_to_string (language); + +- record = bsearch (lang_str, ++ record = musl_bsearch (lang_str, + records, num_records, record_size, + lang_compare_first_component); + if (!record) diff --git a/x11-packages/pango-x/build.sh b/x11-packages/pango-x/build.sh index a0f222d72..0332a32a8 100644 --- a/x11-packages/pango-x/build.sh +++ b/x11-packages/pango-x/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Library for laying out and rendering text (with X)" TERMUX_PKG_LICENSE="LGPL-2.0" TERMUX_PKG_MAINTAINER="Leonid Plyushch " TERMUX_PKG_VERSION=1.44.6 +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://ftp.gnome.org/pub/GNOME/sources/pango/${TERMUX_PKG_VERSION:0:4}/pango-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=3e1e41ba838737e200611ff001e3b304c2ca4cdbba63d200a20db0b0ddc0f86c TERMUX_PKG_DEPENDS="fontconfig, fribidi, glib, harfbuzz, libcairo-x, libxft, zlib"