commit 9e63df1ef20e2e6ebe006c6b8b5c27d34ece4771
Author: Stephan Witt <[email protected]>
Date:   Mon Dec 15 15:27:34 2025 +0100

    Use appropriate numeric data types for spell checker interface.
---
 src/AppleSpellChecker.cpp  | 12 ++++++------
 src/AppleSpellChecker.h    |  6 +++---
 src/AspellChecker.cpp      |  8 ++++----
 src/AspellChecker.h        |  2 +-
 src/EnchantChecker.cpp     |  2 +-
 src/EnchantChecker.h       |  2 +-
 src/HunspellChecker.cpp    |  8 ++++----
 src/HunspellChecker.h      |  2 +-
 src/Paragraph.cpp          |  8 ++++----
 src/SpellChecker.h         |  8 ++++----
 src/support/AppleSpeller.h |  6 +++---
 src/support/AppleSpeller.m |  8 ++++----
 12 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/AppleSpellChecker.cpp b/src/AppleSpellChecker.cpp
index b4b010048d..9c153e8da0 100644
--- a/src/AppleSpellChecker.cpp
+++ b/src/AppleSpellChecker.cpp
@@ -177,9 +177,9 @@ bool AppleSpellChecker::hasDictionary(Language const * 
lang) const
 }
 
 
-int AppleSpellChecker::numDictionaries() const
+size_t AppleSpellChecker::numDictionaries() const
 {
-       int result = 0;
+       size_t result = 0;
        map<string, string>::const_iterator it = d->languageMap.begin();
        map<string, string>::const_iterator et = d->languageMap.end();
 
@@ -191,17 +191,17 @@ int AppleSpellChecker::numDictionaries() const
 }
 
 
-int AppleSpellChecker::numMisspelledWords() const
+size_t AppleSpellChecker::numMisspelledWords() const
 {
        return AppleSpeller_numMisspelledWords(d->speller);
 }
 
 
-void AppleSpellChecker::misspelledWord(int index, pos_type & start, int & 
length) const
+void AppleSpellChecker::misspelledWord(size_t index, pos_type & start, size_t 
& length) const
 {
-       int start_ = start;
+       size_t start_ = start;
        AppleSpeller_misspelledWord(d->speller, index, &start_, &length);
-       start = (pos_type)start_;
+       start = start_;
 }
 
 
diff --git a/src/AppleSpellChecker.h b/src/AppleSpellChecker.h
index bdcaf0efb1..3429edbdbb 100644
--- a/src/AppleSpellChecker.h
+++ b/src/AppleSpellChecker.h
@@ -32,10 +32,10 @@ public:
        void remove(WordLangTuple const &) override;
        void accept(WordLangTuple const &) override;
        bool hasDictionary(Language const * lang) const override;
-       int numDictionaries() const override;
+       size_t numDictionaries() const override;
        bool canCheckParagraph() const override { return true; }
-       int numMisspelledWords() const override;
-       void misspelledWord(int index, pos_type & start, int & length) const 
override;
+       size_t numMisspelledWords() const override;
+       void misspelledWord(size_t index, pos_type & start, size_t & length) 
const override;
        docstring const error() override;
        void advanceChangeNumber() override;
        //@}
diff --git a/src/AspellChecker.cpp b/src/AspellChecker.cpp
index 496d009c33..84dbc8f0bd 100644
--- a/src/AspellChecker.cpp
+++ b/src/AspellChecker.cpp
@@ -66,7 +66,7 @@ struct AspellChecker::Private
 
        bool isValidDictionary(AspellConfig * config,
                        string const & lang, string const & variety);
-       int numDictionaries() const;
+       size_t numDictionaries() const;
        bool checkAspellData(AspellConfig * config,
                string const & basepath, string const & datapath, string const 
& dictpath,
                string const & lang, string const & variety);
@@ -325,9 +325,9 @@ AspellSpeller * AspellChecker::Private::speller(Language 
const * lang)
 }
 
 
-int AspellChecker::Private::numDictionaries() const
+size_t AspellChecker::Private::numDictionaries() const
 {
-       int result = 0;
+       size_t result = 0;
        Spellers::const_iterator it = spellers_.begin();
        Spellers::const_iterator et = spellers_.end();
 
@@ -531,7 +531,7 @@ bool AspellChecker::hasDictionary(Language const * lang) 
const
 }
 
 
-int AspellChecker::numDictionaries() const
+size_t AspellChecker::numDictionaries() const
 {
        return d->numDictionaries();
 }
diff --git a/src/AspellChecker.h b/src/AspellChecker.h
index 18aafed052..a0a1706fa3 100644
--- a/src/AspellChecker.h
+++ b/src/AspellChecker.h
@@ -33,7 +33,7 @@ public:
        void remove(WordLangTuple const &) override;
        void accept(WordLangTuple const &) override;
        bool hasDictionary(Language const * lang) const override;
-       int numDictionaries() const override;
+       size_t numDictionaries() const override;
        docstring const error() override;
        void advanceChangeNumber() override;
        //@}
diff --git a/src/EnchantChecker.cpp b/src/EnchantChecker.cpp
index c09a7d687a..e4eddeffd0 100644
--- a/src/EnchantChecker.cpp
+++ b/src/EnchantChecker.cpp
@@ -208,7 +208,7 @@ bool EnchantChecker::hasDictionary(Language const * lang) 
const
 }
 
 
-int EnchantChecker::numDictionaries() const
+size_t EnchantChecker::numDictionaries() const
 {
        return d->spellers_.size();
 }
diff --git a/src/EnchantChecker.h b/src/EnchantChecker.h
index a79714eb30..6870fac03a 100644
--- a/src/EnchantChecker.h
+++ b/src/EnchantChecker.h
@@ -40,7 +40,7 @@ public:
        void remove(WordLangTuple const &) override;
        void accept(WordLangTuple const &) override;
        bool hasDictionary(Language const * lang) const override;
-       int numDictionaries() const override;
+       size_t numDictionaries() const override;
        docstring const error() override;
        void advanceChangeNumber() override;
        ///@}
diff --git a/src/HunspellChecker.cpp b/src/HunspellChecker.cpp
index 01ec19498b..90910132da 100644
--- a/src/HunspellChecker.cpp
+++ b/src/HunspellChecker.cpp
@@ -62,7 +62,7 @@ struct HunspellChecker::Private
        bool haveLanguageFiles(string const & hpath);
        bool haveDictionary(Language const * lang, string & hpath);
        bool haveDictionary(Language const * lang);
-       int numDictionaries() const;
+       size_t numDictionaries() const;
        Hunspell * addSpeller(Language const * lang, string & hpath);
        Hunspell * addSpeller(Language const * lang);
        Hunspell * speller(Language const * lang);
@@ -267,9 +267,9 @@ Hunspell * HunspellChecker::Private::addSpeller(Language 
const * lang)
 }
 
 
-int HunspellChecker::Private::numDictionaries() const
+size_t HunspellChecker::Private::numDictionaries() const
 {
-       int result = 0;
+       size_t result = 0;
        Spellers::const_iterator it = spellers_.begin();
        Spellers::const_iterator et = spellers_.end();
 
@@ -474,7 +474,7 @@ bool HunspellChecker::hasDictionary(Language const * lang) 
const
 }
 
 
-int HunspellChecker::numDictionaries() const
+size_t HunspellChecker::numDictionaries() const
 {
        return d->numDictionaries();
 }
diff --git a/src/HunspellChecker.h b/src/HunspellChecker.h
index e3299def3d..ccbc15f3ef 100644
--- a/src/HunspellChecker.h
+++ b/src/HunspellChecker.h
@@ -33,7 +33,7 @@ public:
        void remove(WordLangTuple const &) override;
        void accept(WordLangTuple const &) override;
        bool hasDictionary(Language const * lang) const override;
-       int numDictionaries() const override;
+       size_t numDictionaries() const override;
        docstring const error() override;
        void advanceChangeNumber() override;
        ///@}
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 83446b0ccb..7449faad4f 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -5274,14 +5274,14 @@ void Paragraph::Private::markMisspelledWords(
        pos_type snext = first;
        SpellChecker * speller = theSpellChecker();
        // locate and enumerate the error positions
-       int nerrors = speller->numMisspelledWords();
+       size_t nerrors = speller->numMisspelledWords();
        pos_type numskipped = 0;
        SkipPositionsIterator it = skips.begin();
        SkipPositionsIterator et = skips.end();
-       int wsize = word.size();
-       for (int index = 0; index < nerrors; ++index) {
+       size_t wsize = word.size();
+       for (size_t index = 0; index < nerrors; ++index) {
                pos_type wstart;
-               int wlen = 0;
+               size_t wlen = 0;
                speller->misspelledWord(index, wstart, wlen);
                /// should not happen if speller supports range checks
                if (0 == wlen)
diff --git a/src/SpellChecker.h b/src/SpellChecker.h
index 10783fefe7..500f7119cb 100644
--- a/src/SpellChecker.h
+++ b/src/SpellChecker.h
@@ -86,18 +86,18 @@ public:
        virtual bool hasDictionary(Language const *) const = 0;
 
        /// how many valid dictionaries were found
-       virtual int numDictionaries() const = 0;
+       virtual size_t numDictionaries() const = 0;
 
        /// if speller can spell check whole paragraph return true
        virtual bool canCheckParagraph() const { return false; }
 
        /// count of misspelled words
-       virtual int numMisspelledWords() const { return 0; }
+       virtual size_t numMisspelledWords() const { return 0; }
 
        /// start position and length of misspelled word at index
        virtual void misspelledWord(
-               int /* index */,
-               pos_type & start, int & length) const
+               size_t /* index */,
+               pos_type & start, size_t & length) const
        {
                /// index is used here to make the compiler happy
                start = 0;
diff --git a/src/support/AppleSpeller.h b/src/support/AppleSpeller.h
index 62f3fe2de6..9d608188be 100644
--- a/src/support/AppleSpeller.h
+++ b/src/support/AppleSpeller.h
@@ -34,9 +34,9 @@ size_t AppleSpeller_makeSuggestion(AppleSpeller speller, 
const wchar_t * word, c
 const char * AppleSpeller_getSuggestion(AppleSpeller speller, size_t pos);
 void AppleSpeller_learn(AppleSpeller speller, const wchar_t * word);
 void AppleSpeller_unlearn(AppleSpeller speller, const wchar_t * word);
-int AppleSpeller_hasLanguage(AppleSpeller speller, const char * lang);
-int AppleSpeller_numMisspelledWords(AppleSpeller speller);
-void AppleSpeller_misspelledWord(AppleSpeller speller, int index, int * start, 
int * length);
+bool AppleSpeller_hasLanguage(AppleSpeller speller, const char * lang);
+size_t AppleSpeller_numMisspelledWords(AppleSpeller speller);
+void AppleSpeller_misspelledWord(AppleSpeller speller, size_t index, size_t * 
start, size_t * length);
 
 #ifdef __cplusplus
 } // extern "C"
diff --git a/src/support/AppleSpeller.m b/src/support/AppleSpeller.m
index 593999812b..fe2bf0c14d 100644
--- a/src/support/AppleSpeller.m
+++ b/src/support/AppleSpeller.m
@@ -267,21 +267,21 @@ void AppleSpeller_unlearn(AppleSpeller speller, const 
wchar_t * word)
 }
 
 
-int AppleSpeller_numMisspelledWords(AppleSpeller speller)
+size_t AppleSpeller_numMisspelledWords(AppleSpeller speller)
 {
        return [speller->misspelled count];
 }
 
 
-void AppleSpeller_misspelledWord(AppleSpeller speller, int index, int * start, 
int * length)
+void AppleSpeller_misspelledWord(AppleSpeller speller, size_t index, size_t * 
start, size_t * length)
 {
-       NSRange range = [[speller->misspelled objectAtIndex:(NSUInteger)index] 
rangeValue];
+       NSRange range = [[speller->misspelled objectAtIndex:index] rangeValue];
        *start = range.location;
        *length = range.length;
 }
 
 
-int AppleSpeller_hasLanguage(AppleSpeller speller, const char * lang)
+bool AppleSpeller_hasLanguage(AppleSpeller speller, const char * lang)
 {
        return toLanguage(speller, lang) != nil;
 }
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to