summaryrefslogtreecommitdiffstats
path: root/extensions/spellcheck/hunspell/patches/bug1653659.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /extensions/spellcheck/hunspell/patches/bug1653659.patch
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/spellcheck/hunspell/patches/bug1653659.patch')
-rw-r--r--extensions/spellcheck/hunspell/patches/bug1653659.patch190
1 files changed, 190 insertions, 0 deletions
diff --git a/extensions/spellcheck/hunspell/patches/bug1653659.patch b/extensions/spellcheck/hunspell/patches/bug1653659.patch
new file mode 100644
index 0000000000..554844225b
--- /dev/null
+++ b/extensions/spellcheck/hunspell/patches/bug1653659.patch
@@ -0,0 +1,190 @@
+diff --git a/src/csutil.cxx b/src/csutil.cxx
+--- a/src/csutil.cxx
++++ b/src/csutil.cxx
+@@ -90,21 +90,17 @@
+ #else
+ #ifndef MOZILLA_CLIENT
+ #include "utf_info.hxx"
+ #define UTF_LST_LEN (sizeof(utf_lst) / (sizeof(unicode_info)))
+ #endif
+ #endif
+
+ #ifdef MOZILLA_CLIENT
+-#include "nsCOMPtr.h"
+-#include "nsUnicharUtils.h"
+-#include "mozilla/Encoding.h"
+-
+-using namespace mozilla;
++#include "mozHunspellRLBoxGlue.h"
+ #endif
+
+ struct unicode_info2 {
+ char cletter;
+ unsigned short cupper;
+ unsigned short clower;
+ };
+
+@@ -2277,101 +2273,18 @@ struct cs_info* get_current_cs(const std
+ "error: unknown encoding %s: using %s as fallback\n", es.c_str(),
+ encds[0].enc_name);
+ ccs = encds[0].cs_table;
+ }
+
+ return ccs;
+ }
+ #else
+-// XXX This function was rewritten for mozilla. Instead of storing the
+-// conversion tables static in this file, create them when needed
+-// with help the mozilla backend.
+ struct cs_info* get_current_cs(const std::string& es) {
+- struct cs_info* ccs = new cs_info[256];
+- // Initialze the array with dummy data so that we wouldn't need
+- // to return null in case of failures.
+- for (int i = 0; i <= 0xff; ++i) {
+- ccs[i].ccase = false;
+- ccs[i].clower = i;
+- ccs[i].cupper = i;
+- }
+-
+- auto encoding = Encoding::ForLabelNoReplacement(es);
+- if (!encoding) {
+- return ccs;
+- }
+- auto encoder = encoding->NewEncoder();
+- auto decoder = encoding->NewDecoderWithoutBOMHandling();
+-
+- for (unsigned int i = 0; i <= 0xff; ++i) {
+- bool success = false;
+- // We want to find the upper/lowercase equivalents of each byte
+- // in this 1-byte character encoding. Call our encoding/decoding
+- // APIs separately for each byte since they may reject some of the
+- // bytes, and we want to handle errors separately for each byte.
+- uint8_t lower, upper;
+- do {
+- if (i == 0)
+- break;
+- uint8_t source = uint8_t(i);
+- char16_t uni[2];
+- char16_t uniCased;
+- uint8_t destination[4];
+- auto src1 = MakeSpan(&source, 1);
+- auto dst1 = MakeSpan(uni);
+- auto src2 = MakeSpan(&uniCased, 1);
+- auto dst2 = MakeSpan(destination);
+-
+- uint32_t result;
+- size_t read;
+- size_t written;
+- Tie(result, read, written) =
+- decoder->DecodeToUTF16WithoutReplacement(src1, dst1, true);
+- if (result != kInputEmpty || read != 1 || written != 1) {
+- break;
+- }
+-
+- uniCased = ToLowerCase(uni[0]);
+- Tie(result, read, written) =
+- encoder->EncodeFromUTF16WithoutReplacement(src2, dst2, true);
+- if (result != kInputEmpty || read != 1 || written != 1) {
+- break;
+- }
+- lower = destination[0];
+-
+- uniCased = ToUpperCase(uni[0]);
+- Tie(result, read, written) =
+- encoder->EncodeFromUTF16WithoutReplacement(src2, dst2, true);
+- if (result != kInputEmpty || read != 1 || written != 1) {
+- break;
+- }
+- upper = destination[0];
+-
+- success = true;
+- } while (0);
+-
+- encoding->NewEncoderInto(*encoder);
+- encoding->NewDecoderWithoutBOMHandlingInto(*decoder);
+-
+- if (success) {
+- ccs[i].cupper = upper;
+- ccs[i].clower = lower;
+- } else {
+- ccs[i].cupper = i;
+- ccs[i].clower = i;
+- }
+-
+- if (ccs[i].clower != (unsigned char)i)
+- ccs[i].ccase = true;
+- else
+- ccs[i].ccase = false;
+- }
+-
+- return ccs;
++ return moz_hunspell_GetCurrentCS(es.c_str());
+ }
+ #endif
+
+ // primitive isalpha() replacement for tokenization
+ std::string get_casechars(const char* enc) {
+ struct cs_info* csconv = get_current_cs(enc);
+ std::string expw;
+ for (int i = 0; i <= 255; ++i) {
+@@ -2455,34 +2368,34 @@ unsigned short unicodetoupper(unsigned s
+ // There are a dotless lower case i pair of upper `I',
+ // and an upper I with dot pair of lower `i'.
+ if (c == 0x0069 && ((langnum == LANG_az) || (langnum == LANG_tr) || (langnum == LANG_crh)))
+ return 0x0130;
+ #ifdef OPENOFFICEORG
+ return static_cast<unsigned short>(u_toupper(c));
+ #else
+ #ifdef MOZILLA_CLIENT
+- return ToUpperCase((char16_t)c);
++ return moz_hunspell_ToUpperCase((char16_t)c);
+ #else
+ return (utf_tbl) ? utf_tbl[c].cupper : c;
+ #endif
+ #endif
+ }
+
+ unsigned short unicodetolower(unsigned short c, int langnum) {
+ // In Azeri and Turkish, I and i dictinct letters:
+ // There are a dotless lower case i pair of upper `I',
+ // and an upper I with dot pair of lower `i'.
+ if (c == 0x0049 && ((langnum == LANG_az) || (langnum == LANG_tr) || (langnum == LANG_crh)))
+ return 0x0131;
+ #ifdef OPENOFFICEORG
+ return static_cast<unsigned short>(u_tolower(c));
+ #else
+ #ifdef MOZILLA_CLIENT
+- return ToLowerCase((char16_t)c);
++ return moz_hunspell_ToLowerCase((char16_t)c);
+ #else
+ return (utf_tbl) ? utf_tbl[c].clower : c;
+ #endif
+ #endif
+ }
+
+ int unicodeisalpha(unsigned short c) {
+ #ifdef OPENOFFICEORG
+diff --git a/src/csutil.hxx b/src/csutil.hxx
+--- a/src/csutil.hxx
++++ b/src/csutil.hxx
+@@ -77,20 +77,16 @@
+
+ #include <fstream>
+ #include <string>
+ #include <vector>
+ #include <string.h>
+ #include "w_char.hxx"
+ #include "htypes.hxx"
+
+-#ifdef MOZILLA_CLIENT
+-#include "nscore.h" // for mozalloc headers
+-#endif
+-
+ // casing
+ #define NOCAP 0
+ #define INITCAP 1
+ #define ALLCAP 2
+ #define HUHCAP 3
+ #define HUHINITCAP 4
+
+ // default encoding and keystring