diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-23 15:25:54 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-23 17:32:51 +0200 |
commit | 9fda7a0c938fdae3e57c7a8121a94459f2749dc2 (patch) | |
tree | 97c1a331496e1d98521d534ea30a1c33df78019e /external/hunspell | |
parent | 4c27aaa787a67e05a592adcf6cf42e49b7a02eaf (diff) |
backport some upstream hunspell commits
Change-Id: I0c2b94a27af8c25c69579b367b944a4f77036487
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138735
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'external/hunspell')
4 files changed, 122 insertions, 0 deletions
diff --git a/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch b/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch new file mode 100644 index 000000000000..58b68d0dda43 --- /dev/null +++ b/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch @@ -0,0 +1,27 @@ +From 56ad6310c95695d25f936d3f89f6ee3d787df274 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> +Date: Mon, 22 Aug 2022 21:21:36 +0100 +Subject: [PATCH] check 'len' in cpdpat_check like 'r1->blen' is checked (#633) + (#780) + +we should check len against pos like we do r1->blen in the line above +--- + src/hunspell/affixmgr.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx +index 7ea1ea5..c2432c0 100644 +--- a/src/hunspell/affixmgr.cxx ++++ b/src/hunspell/affixmgr.cxx +@@ -1330,7 +1330,7 @@ int AffixMgr::cpdpat_check(const char* word, + ((checkcpdtable[i].pattern[0] == '0' && r1->blen <= pos && + strncmp(word + pos - r1->blen, r1->word, r1->blen) == 0) || + (checkcpdtable[i].pattern[0] != '0' && +- ((len = checkcpdtable[i].pattern.size()) != 0) && ++ ((len = checkcpdtable[i].pattern.size()) != 0) && len <= pos && + strncmp(word + pos - len, checkcpdtable[i].pattern.c_str(), len) == 0)))) { + return 1; + } +-- +2.37.2 + diff --git a/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch b/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch new file mode 100644 index 000000000000..a42d38f5153a --- /dev/null +++ b/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch @@ -0,0 +1,52 @@ +From 75ebf084f941c0fe72904b6167079d9190f885e5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> +Date: Tue, 23 Aug 2022 11:44:36 +0100 +Subject: [PATCH] improve #630 test case from 0m1.836s -> 0m1.223s (#785) + +--- + src/hunspell/csutil.cxx | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx +index e9cce47..5caa771 100644 +--- a/src/hunspell/csutil.cxx ++++ b/src/hunspell/csutil.cxx +@@ -171,8 +171,10 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + } + + int u8_u16(std::vector<w_char>& dest, const std::string& src) { +- dest.clear(); +- dest.reserve(src.size()); ++ // faster to oversize initially, assign to elements and resize to what's used ++ // than to reserve and push_back ++ dest.resize(src.size()); ++ std::vector<w_char>::iterator u16 = dest.begin(); + std::string::const_iterator u8 = src.begin(); + std::string::const_iterator u8_max = src.end(); + +@@ -254,16 +256,18 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { + src.c_str()); + u2.h = 0xff; + u2.l = 0xfd; +- dest.push_back(u2); ++ *u16++ = u2; ++ dest.resize(u16 - dest.begin()); + return -1; + } + } +- dest.push_back(u2); ++ *u16++ = u2; + ++u8; + } + +- dest.shrink_to_fit(); +- return dest.size(); ++ int size = u16 - dest.begin(); ++ dest.resize(size); ++ return size; + } + + namespace { +-- +2.37.2 + diff --git a/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch b/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch new file mode 100644 index 000000000000..c3de49178ada --- /dev/null +++ b/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch @@ -0,0 +1,40 @@ +From 211e1e6f36756579b86fa12891af3e5843cd8907 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> +Date: Tue, 23 Aug 2022 10:18:31 +0100 +Subject: [PATCH] improve #630 test case from 0m2.427s -> 0m1.836s (#781) + +--- + src/hunspell/csutil.cxx | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx +index fbaa768..e9cce47 100644 +--- a/src/hunspell/csutil.cxx ++++ b/src/hunspell/csutil.cxx +@@ -134,6 +134,7 @@ void myopen(std::ifstream& stream, const char* path, std::ios_base::openmode mod + + std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + dest.clear(); ++ dest.reserve(src.size()); + std::vector<w_char>::const_iterator u2 = src.begin(); + std::vector<w_char>::const_iterator u2_max = src.end(); + while (u2 < u2_max) { +@@ -171,6 +172,7 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + + int u8_u16(std::vector<w_char>& dest, const std::string& src) { + dest.clear(); ++ dest.reserve(src.size()); + std::string::const_iterator u8 = src.begin(); + std::string::const_iterator u8_max = src.end(); + +@@ -260,6 +262,7 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { + ++u8; + } + ++ dest.shrink_to_fit(); + return dest.size(); + } + +-- +2.37.2 + diff --git a/external/hunspell/UnpackedTarball_hunspell.mk b/external/hunspell/UnpackedTarball_hunspell.mk index 37a2d196fbf5..33614a39292d 100644 --- a/external/hunspell/UnpackedTarball_hunspell.mk +++ b/external/hunspell/UnpackedTarball_hunspell.mk @@ -22,6 +22,9 @@ endif $(eval $(call gb_UnpackedTarball_set_patchlevel,hunspell,1)) $(eval $(call gb_UnpackedTarball_add_patches,hunspell, \ + external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch \ + external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch \ + external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch \ )) # vim: set noet sw=4 ts=4: |