File 0005-Use-system-hunspell.patch of Package rstudio

From 8baa44c18668f4af96fc0838ac66c745a0d14c0b Mon Sep 17 00:00:00 2001
From: Aaron Puchert <aaronpuchert@alice-dsl.net>
Date: Mon, 7 Sep 2020 11:09:01 +0200
Subject: [PATCH 5/8] Use system hunspell

---
 src/cpp/core/CMakeLists.txt                      | 6 +++++-
 src/cpp/core/spelling/HunspellSpellingEngine.cpp | 7 +++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/cpp/core/CMakeLists.txt b/src/cpp/core/CMakeLists.txt
index 06303de4aa..377c377721 100644
--- a/src/cpp/core/CMakeLists.txt
+++ b/src/cpp/core/CMakeLists.txt
@@ -15,7 +15,11 @@
 
 project (CORE)
 
-add_subdirectory(spelling/hunspell)
+add_library(rstudio-core-hunspell SHARED IMPORTED GLOBAL)
+find_library(HUNSPELL_LIB NAMES hunspell REQUIRED)
+set_target_properties(rstudio-core-hunspell PROPERTIES
+                      IMPORTED_LOCATION "${HUNSPELL_LIB}")
+
 add_subdirectory(tex/synctex)
 
 # include files
diff --git a/src/cpp/core/spelling/HunspellSpellingEngine.cpp b/src/cpp/core/spelling/HunspellSpellingEngine.cpp
index 861417db6e..60763c5fc1 100644
--- a/src/cpp/core/spelling/HunspellSpellingEngine.cpp
+++ b/src/cpp/core/spelling/HunspellSpellingEngine.cpp
@@ -195,11 +195,10 @@ public:
 
    Error wordChars(std::wstring *pWordChars)
    {
-      int len;
-      unsigned short *pChars = pHunspell_->get_wordchars_utf16(&len);
+      const std::vector<w_char> &pChars = pHunspell_->get_wordchars_utf16();
 
-      for (int i = 0; i < len; i++)
-         pWordChars->push_back(pChars[i]);
+      for (w_char pChar : pChars)
+         pWordChars->push_back((pChar.h << 8) + pChar.l);
 
       return Success();
    }
-- 
2.31.1

openSUSE Build Service is sponsored by