From 3c52f7da5d909d04b0febbe639cf1f14bcdd2dfa Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Wed, 22 Dec 2021 20:52:46 +0100 Subject: imv: update libgrapheme patch --- wayland/imv/build | 4 +- wayland/imv/checksums | 3 +- wayland/imv/patches/0001-support-libgrapheme.patch | 129 +++++++++++++++++++++ ...nsole-update-libgrapheme-API-to-version-1.patch | 39 +++++++ wayland/imv/patches/support-libgrapheme.patch | 129 --------------------- wayland/imv/sources | 3 +- wayland/imv/version | 2 +- 7 files changed, 176 insertions(+), 133 deletions(-) create mode 100644 wayland/imv/patches/0001-support-libgrapheme.patch create mode 100644 wayland/imv/patches/0002-console-update-libgrapheme-API-to-version-1.patch delete mode 100644 wayland/imv/patches/support-libgrapheme.patch (limited to 'wayland') diff --git a/wayland/imv/build b/wayland/imv/build index 1d28baa4..4ca5d07e 100755 --- a/wayland/imv/build +++ b/wayland/imv/build @@ -1,6 +1,8 @@ #!/bin/sh -e -patch -p1 < support-libgrapheme.patch +for patch in *.patch; do + [ -f "$patch" ] && patch -p1 < "$patch" +done export DESTDIR="$1" diff --git a/wayland/imv/checksums b/wayland/imv/checksums index 576594d6..d99e1e2f 100644 --- a/wayland/imv/checksums +++ b/wayland/imv/checksums @@ -1,4 +1,5 @@ %BLAKE3 154ed94c58e3c97ca1d9d8c9dbf1bd86e8661be07454822048eaa80886ddeffd v4.3.1.tar.gz 3f3775e97c033b812a8a45c1587d6003fff54c99b64102ec366fe2e86f649e9b r52.tar.gz -2ad333e1c8f277be3961bede9696a9c111636f63a8797b17b8780a6fb4c1e483 support-libgrapheme.patch +2ad333e1c8f277be3961bede9696a9c111636f63a8797b17b8780a6fb4c1e483 0001-support-libgrapheme.patch +7f4a255e11eaff0ece1051e27b190e47b4893728fe40d1e4f17ef8c7c17d3863 0002-console-update-libgrapheme-API-to-version-1.patch diff --git a/wayland/imv/patches/0001-support-libgrapheme.patch b/wayland/imv/patches/0001-support-libgrapheme.patch new file mode 100644 index 00000000..693a8921 --- /dev/null +++ b/wayland/imv/patches/0001-support-libgrapheme.patch @@ -0,0 +1,129 @@ +From a83304d4d673aae6efed51da1986bd7315a4d642 Mon Sep 17 00:00:00 2001 +From: Cem Keylan +Date: Tue, 7 Dec 2021 14:40:57 +0100 +Subject: [PATCH] Add support for libgrapheme as an icu replacement + +--- + meson.build | 11 ++++++++++- + meson_options.txt | 8 ++++++++ + src/console.c | 28 ++++++++++++++++++++++++++++ + 3 files changed, 46 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 7cf64b5..26ee0a1 100644 +--- a/meson.build ++++ b/meson.build +@@ -38,6 +38,15 @@ else + target_single_ws = false + endif + ++_unicode = get_option('unicode') ++if _unicode == 'icu' ++ unicode_lib = dependency('icu-io') ++ add_project_arguments('-DIMV_USE_ICU', language: 'c') ++elif _unicode == 'grapheme' ++ unicode_lib = cc.find_library('grapheme') ++ add_project_arguments('-DIMV_USE_GRAPHEME', language: 'c') ++endif ++ + gl_dep = dependency('gl', required: false) + if not gl_dep.found() + # libglvnd fallback for pure-wayland systems +@@ -49,7 +58,7 @@ deps_for_imv = [ + gl_dep, + dependency('threads'), + dependency('xkbcommon'), +- dependency('icu-io'), ++ unicode_lib, + dependency('inih', fallback : ['inih', 'inih_dep']), + m_dep, + ] +diff --git a/meson_options.txt b/meson_options.txt +index 389b7fd..c13ef7a 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -8,6 +8,14 @@ option('windows', + description : 'window system to use' + ) + ++# Unicode backend - default is ICU ++option('unicode', ++ type: 'combo', ++ value: 'icu', ++ choices : ['icu', 'grapheme'], ++ description : 'unicode library to use' ++) ++ + option('test', + type : 'feature', + description : 'enable tests' +diff --git a/src/console.c b/src/console.c +index 073274f..323383f 100644 +--- a/src/console.c ++++ b/src/console.c +@@ -6,8 +6,15 @@ + #include + #include + #include ++ ++#ifdef IMV_USE_ICU + #include + #include ++#endif ++ ++#ifdef IMV_USE_GRAPHEME ++#include ++#endif + + struct imv_console { + char *buffer; +@@ -25,6 +32,7 @@ struct imv_console { + /* Iterates forwards over characters in a UTF-8 string */ + static size_t next_char(char *buffer, size_t position) + { ++ #if defined(IMV_USE_ICU) + size_t result = position; + UErrorCode status = U_ZERO_ERROR; + UText *ut = utext_openUTF8(NULL, buffer, -1, &status); +@@ -42,11 +50,19 @@ static size_t next_char(char *buffer, size_t position) + utext_close(ut); + assert(U_SUCCESS(status)); + return result; ++ #elif defined(IMV_USE_GRAPHEME) ++ if (buffer[position] != 0) { ++ return position + grapheme_bytelen(buffer + position); ++ } else { ++ return position; ++ } ++ #endif + } + + /* Iterates backwards over characters in a UTF-8 string */ + static size_t prev_char(char *buffer, size_t position) + { ++ #if defined(IMV_USE_ICU) + size_t result = position; + UErrorCode status = U_ZERO_ERROR; + UText *ut = utext_openUTF8(NULL, buffer, -1, &status); +@@ -64,6 +80,18 @@ static size_t prev_char(char *buffer, size_t position) + utext_close(ut); + assert(U_SUCCESS(status)); + return result; ++ ++ #elif defined(IMV_USE_GRAPHEME) ++ size_t result = 0; ++ size_t step; ++ do { ++ step = grapheme_bytelen(buffer + result); ++ if (result + step >= position) ++ break; ++ result += step; ++ } while (step > 0); ++ return result; ++ #endif + } + + static void add_to_history(struct list *history, const char *line) +-- +2.32.0 + diff --git a/wayland/imv/patches/0002-console-update-libgrapheme-API-to-version-1.patch b/wayland/imv/patches/0002-console-update-libgrapheme-API-to-version-1.patch new file mode 100644 index 00000000..d92eaef2 --- /dev/null +++ b/wayland/imv/patches/0002-console-update-libgrapheme-API-to-version-1.patch @@ -0,0 +1,39 @@ +From 3e76c68e6de460e0b49402962eee47555e2711ce Mon Sep 17 00:00:00 2001 +From: Cem Keylan +Date: Wed, 22 Dec 2021 18:45:43 +0100 +Subject: [PATCH imv] console: update libgrapheme API to version 1 + +--- +libgrapheme has recently seen its first release, along with some API +changes. I have updated the functions to match the current API. The +dedicated page for the library is now on +. + + src/console.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/console.c b/src/console.c +index 323383f..9db18e7 100644 +--- a/src/console.c ++++ b/src/console.c +@@ -52,7 +52,7 @@ static size_t next_char(char *buffer, size_t position) + return result; + #elif defined(IMV_USE_GRAPHEME) + if (buffer[position] != 0) { +- return position + grapheme_bytelen(buffer + position); ++ return position + grapheme_next_character_break(buffer + position, SIZE_MAX); + } else { + return position; + } +@@ -85,7 +85,7 @@ static size_t prev_char(char *buffer, size_t position) + size_t result = 0; + size_t step; + do { +- step = grapheme_bytelen(buffer + result); ++ step = grapheme_next_character_break(buffer + result, SIZE_MAX); + if (result + step >= position) + break; + result += step; +-- +2.34.1 + diff --git a/wayland/imv/patches/support-libgrapheme.patch b/wayland/imv/patches/support-libgrapheme.patch deleted file mode 100644 index 693a8921..00000000 --- a/wayland/imv/patches/support-libgrapheme.patch +++ /dev/null @@ -1,129 +0,0 @@ -From a83304d4d673aae6efed51da1986bd7315a4d642 Mon Sep 17 00:00:00 2001 -From: Cem Keylan -Date: Tue, 7 Dec 2021 14:40:57 +0100 -Subject: [PATCH] Add support for libgrapheme as an icu replacement - ---- - meson.build | 11 ++++++++++- - meson_options.txt | 8 ++++++++ - src/console.c | 28 ++++++++++++++++++++++++++++ - 3 files changed, 46 insertions(+), 1 deletion(-) - -diff --git a/meson.build b/meson.build -index 7cf64b5..26ee0a1 100644 ---- a/meson.build -+++ b/meson.build -@@ -38,6 +38,15 @@ else - target_single_ws = false - endif - -+_unicode = get_option('unicode') -+if _unicode == 'icu' -+ unicode_lib = dependency('icu-io') -+ add_project_arguments('-DIMV_USE_ICU', language: 'c') -+elif _unicode == 'grapheme' -+ unicode_lib = cc.find_library('grapheme') -+ add_project_arguments('-DIMV_USE_GRAPHEME', language: 'c') -+endif -+ - gl_dep = dependency('gl', required: false) - if not gl_dep.found() - # libglvnd fallback for pure-wayland systems -@@ -49,7 +58,7 @@ deps_for_imv = [ - gl_dep, - dependency('threads'), - dependency('xkbcommon'), -- dependency('icu-io'), -+ unicode_lib, - dependency('inih', fallback : ['inih', 'inih_dep']), - m_dep, - ] -diff --git a/meson_options.txt b/meson_options.txt -index 389b7fd..c13ef7a 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -8,6 +8,14 @@ option('windows', - description : 'window system to use' - ) - -+# Unicode backend - default is ICU -+option('unicode', -+ type: 'combo', -+ value: 'icu', -+ choices : ['icu', 'grapheme'], -+ description : 'unicode library to use' -+) -+ - option('test', - type : 'feature', - description : 'enable tests' -diff --git a/src/console.c b/src/console.c -index 073274f..323383f 100644 ---- a/src/console.c -+++ b/src/console.c -@@ -6,8 +6,15 @@ - #include - #include - #include -+ -+#ifdef IMV_USE_ICU - #include - #include -+#endif -+ -+#ifdef IMV_USE_GRAPHEME -+#include -+#endif - - struct imv_console { - char *buffer; -@@ -25,6 +32,7 @@ struct imv_console { - /* Iterates forwards over characters in a UTF-8 string */ - static size_t next_char(char *buffer, size_t position) - { -+ #if defined(IMV_USE_ICU) - size_t result = position; - UErrorCode status = U_ZERO_ERROR; - UText *ut = utext_openUTF8(NULL, buffer, -1, &status); -@@ -42,11 +50,19 @@ static size_t next_char(char *buffer, size_t position) - utext_close(ut); - assert(U_SUCCESS(status)); - return result; -+ #elif defined(IMV_USE_GRAPHEME) -+ if (buffer[position] != 0) { -+ return position + grapheme_bytelen(buffer + position); -+ } else { -+ return position; -+ } -+ #endif - } - - /* Iterates backwards over characters in a UTF-8 string */ - static size_t prev_char(char *buffer, size_t position) - { -+ #if defined(IMV_USE_ICU) - size_t result = position; - UErrorCode status = U_ZERO_ERROR; - UText *ut = utext_openUTF8(NULL, buffer, -1, &status); -@@ -64,6 +80,18 @@ static size_t prev_char(char *buffer, size_t position) - utext_close(ut); - assert(U_SUCCESS(status)); - return result; -+ -+ #elif defined(IMV_USE_GRAPHEME) -+ size_t result = 0; -+ size_t step; -+ do { -+ step = grapheme_bytelen(buffer + result); -+ if (result + step >= position) -+ break; -+ result += step; -+ } while (step > 0); -+ return result; -+ #endif - } - - static void add_to_history(struct list *history, const char *line) --- -2.32.0 - diff --git a/wayland/imv/sources b/wayland/imv/sources index f0a9793e..9031fbaf 100644 --- a/wayland/imv/sources +++ b/wayland/imv/sources @@ -1,3 +1,4 @@ https://git.sr.ht/~exec64/imv/archive/v4.3.1.tar.gz https://github.com/benhoyt/inih/archive/r52.tar.gz subprojects/inih -patches/support-libgrapheme.patch +patches/0001-support-libgrapheme.patch +patches/0002-console-update-libgrapheme-API-to-version-1.patch diff --git a/wayland/imv/version b/wayland/imv/version index bbb23c33..529d54cc 100644 --- a/wayland/imv/version +++ b/wayland/imv/version @@ -1 +1 @@ -4.3.1 1 +4.3.1 2 -- cgit v1.2.3