commit 170f840c49b1a5a84cf71d59c89e1371610aa830
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Sep 22 18:34:41 2026 +0200

    Constify some parameters passed by pointer
    
    Spotted by cppcheck.
---
 src/AspellChecker.cpp          | 23 +++++++++--------------
 src/Buffer.cpp                 |  2 +-
 src/Buffer.h                   |  2 +-
 src/BufferList.cpp             |  2 +-
 src/BufferList.h               |  2 +-
 src/BufferView.cpp             |  2 +-
 src/BufferView.h               |  2 +-
 src/Font.cpp                   |  2 +-
 src/Font.h                     |  2 +-
 src/Text.cpp                   |  3 +--
 src/Text.h                     |  3 +--
 src/frontends/qt/GuiVSpace.cpp |  2 +-
 src/frontends/qt/GuiView.cpp   |  6 +++---
 src/insets/InsetLabel.cpp      |  3 +--
 src/insets/InsetLabel.h        |  2 +-
 src/support/lstrings.cpp       |  2 +-
 src/support/lstrings.h         |  2 +-
 17 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/src/AspellChecker.cpp b/src/AspellChecker.cpp
index 84dbc8f0bd..81a18fc25a 100644
--- a/src/AspellChecker.cpp
+++ b/src/AspellChecker.cpp
@@ -77,7 +77,7 @@ struct AspellChecker::Private
        SpellChecker::Result check(AspellSpeller * m,
                WordLangTuple const & word) const;
 
-       void initSessionDictionary(Speller const & speller, PersonalWordList * 
pd);
+       void initSessionDictionary(Speller const & speller, PersonalWordList 
const * pd);
        void addToSession(AspellCanHaveError * speller, docstring const & word);
        void insert(WordLangTuple const & word);
        void remove(WordLangTuple const & word);
@@ -232,22 +232,17 @@ void 
AspellChecker::Private::addToSession(AspellCanHaveError * speller, docstrin
 }
 
 
-void AspellChecker::Private::initSessionDictionary(
-       Speller const & speller,
-       PersonalWordList * pd)
+void AspellChecker::Private::initSessionDictionary(Speller const & speller,
+       PersonalWordList const * pd)
 {
        AspellSpeller * aspell = to_aspell_speller(speller.e_speller);
        aspell_speller_clear_session(aspell);
-       docstring_list::const_iterator it = pd->begin();
-       docstring_list::const_iterator et = pd->end();
-       for (; it != et; ++it) {
-               addToSession(speller.e_speller, *it);
-       }
-       it = speller.ignored_words_.begin();
-       et = speller.ignored_words_.end();
-       for (; it != et; ++it) {
-               addToSession(speller.e_speller, *it);
-       }
+
+       for (auto const & word : *pd)
+               addToSession(speller.e_speller, word);
+
+       for (auto const & word : speller.ignored_words_)
+               addToSession(speller.e_speller, word);
 }
 
 
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index f727ffdd08..7af7398d5d 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3734,7 +3734,7 @@ Buffer const * Buffer::masterBuffer() const
 }
 
 
-bool Buffer::isChild(Buffer * child) const
+bool Buffer::isChild(Buffer const * child) const
 {
        return d->children_positions.find(child) != d->children_positions.end();
 }
diff --git a/src/Buffer.h b/src/Buffer.h
index dc37e40f5c..9ee1f61842 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -460,7 +460,7 @@ public:
        Buffer const * masterBuffer() const;
 
        /// \return true if \p child is a child of this \c Buffer.
-       bool isChild(Buffer * child) const;
+       bool isChild(Buffer const * child) const;
 
        /// \return true if this \c Buffer has children
        bool hasChildren() const;
diff --git a/src/BufferList.cpp b/src/BufferList.cpp
index 757bf46cf7..62780ceb2e 100644
--- a/src/BufferList.cpp
+++ b/src/BufferList.cpp
@@ -272,7 +272,7 @@ bool BufferList::isInternal(Buffer const * b) const
 }
 
 
-bool BufferList::isOthersChild(Buffer * parent, Buffer * child) const
+bool BufferList::isOthersChild(Buffer const * parent, Buffer const * child) 
const
 {
        LASSERT(parent, return false);
        LASSERT(child, return false);
diff --git a/src/BufferList.h b/src/BufferList.h
index 1384467c73..0fac867e23 100644
--- a/src/BufferList.h
+++ b/src/BufferList.h
@@ -57,7 +57,7 @@ public:
        /// Is child a child of some Buffer other than parent?
        /// NOTE: child must be a child of parent, and both must be non-null.
        /// Otherwise we assert.
-       bool isOthersChild(Buffer * parent, Buffer * child) const;
+       bool isOthersChild(Buffer const * parent, Buffer const * child) const;
 
        /// delete a buffer
        void release(Buffer * b);
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index ac79eec53c..d2319b1a02 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2901,7 +2901,7 @@ void BufferView::updateHoveredInset() const
 }
 
 
-void BufferView::clearLastInset(Inset * inset) const
+void BufferView::clearLastInset(Inset const * inset) const
 {
        if (d->last_inset_ != inset) {
                LYXERR0("Wrong last_inset!");
diff --git a/src/BufferView.h b/src/BufferView.h
index 91fe571b96..f3296e424e 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -397,7 +397,7 @@ public:
        /// Associate an inset associated with given dialog name.
        void editInset(std::string const & name, Inset * inset);
        ///
-       void clearLastInset(Inset * inset) const;
+       void clearLastInset(Inset const * inset) const;
        /// Is the mouse hovering a clickable inset or element?
        bool clickableInset() const;
        ///
diff --git a/src/Font.cpp b/src/Font.cpp
index 6c2baeadd1..3f301e0d6f 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -138,7 +138,7 @@ void Font::update(Font const & newfont,
 }
 
 
-docstring const Font::stateText(BufferParams * params, bool const terse) const
+docstring const Font::stateText(BufferParams const * params, bool const terse) 
const
 {
        odocstringstream os;
        os << bits_.stateText(terse);
diff --git a/src/Font.h b/src/Font.h
index 50b26c5358..fd631cda23 100644
--- a/src/Font.h
+++ b/src/Font.h
@@ -93,7 +93,7 @@ public:
 
 
        /// Build GUI description of font state
-       docstring const stateText(BufferParams * params = nullptr, bool const 
terse = false) const;
+       docstring const stateText(BufferParams const * params = nullptr, bool 
const terse = false) const;
 
        ///
        void validate(LaTeXFeatures & features) const;
diff --git a/src/Text.cpp b/src/Text.cpp
index c34231b1aa..577c48922d 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -2049,8 +2049,7 @@ void Text::write(ostream & os) const
 }
 
 
-bool Text::read(Lexer & lex,
-               ErrorList & errorList, InsetText * insetPtr)
+bool Text::read(Lexer & lex, ErrorList & errorList, InsetText const * insetPtr)
 {
        Buffer const & buf = owner_->buffer();
        depth_type depth = 0;
diff --git a/src/Text.h b/src/Text.h
index 6e808b8ea0..22f5694878 100644
--- a/src/Text.h
+++ b/src/Text.h
@@ -300,8 +300,7 @@ public:
        void write(std::ostream & os) const;
        /// returns true if \end_document has not been read
        /// insetPtr is the containing Inset
-       bool read(support::Lexer & lex, ErrorList & errorList,
-                 InsetText * insetPtr);
+       bool read(support::Lexer & lex, ErrorList & errorList, InsetText const 
* insetPtr);
 
        /// delete double spaces, leading spaces, and empty paragraphs around 
old cursor.
        /// \retval true if a change has happened and we need a redraw.
diff --git a/src/frontends/qt/GuiVSpace.cpp b/src/frontends/qt/GuiVSpace.cpp
index 517bbe801c..9a9d193618 100644
--- a/src/frontends/qt/GuiVSpace.cpp
+++ b/src/frontends/qt/GuiVSpace.cpp
@@ -120,7 +120,7 @@ static void setWidgetsFromVSpace(VSpace const & space,
 
 
 static VSpace setVSpaceFromWidgets(int spacing,
-       QLineEdit * value, LengthCombo * unit, bool keep)
+       QLineEdit const * value, LengthCombo const * unit, bool keep)
 {
        VSpace space;
 
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 4f15510200..d717a77e5e 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -488,7 +488,7 @@ public:
 
        template<class T>
        static Buffer::ExportStatus runAndDestroy(const T& func,
-                       Buffer const * orig, Buffer * buffer, string const & 
format);
+                       Buffer const * orig, Buffer const * buffer, string 
const & format);
 
        // TODO syncFunc/previewFunc: use bind
        bool asyncBufferProcessing(string const & argument,
@@ -4155,7 +4155,7 @@ void GuiView::gotoNextTabWorkArea(NextOrPrevious np)
 
 
 /// make sure the document is saved
-static bool ensureBufferClean(Buffer * buffer)
+static bool ensureBufferClean(Buffer const * buffer)
 {
        LASSERT(buffer, return false);
        if (buffer->isClean() && !buffer->isUnnamed())
@@ -4492,7 +4492,7 @@ bool GuiView::goToFileRow(string const & argument)
 
 template<class T>
 Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func,
-               Buffer const * orig, Buffer * clone, string const & format)
+               Buffer const * orig, Buffer const * clone, string const & 
format)
 {
        Buffer::ExportStatus const status = func(format);
 
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index d90328e5f8..a00199b8e6 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -90,8 +90,7 @@ void InsetLabel::updateLabel(docstring const & new_label, 
bool const active)
 }
 
 
-void InsetLabel::updateLabelAndRefs(docstring const & new_label,
-               Cursor * cursor)
+void InsetLabel::updateLabelAndRefs(docstring const & new_label, Cursor const 
* cursor)
 {
        docstring const old_label = getParam("name");
        docstring label = new_label;
diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h
index b51159ebf7..4075c539b3 100644
--- a/src/insets/InsetLabel.h
+++ b/src/insets/InsetLabel.h
@@ -47,7 +47,7 @@ public:
        void updateLabel(docstring const & new_label, bool active = true);
        /// Updates the label and the references to it.
        /// Will also handle undo/redo if \p cursor is passed.
-       void updateLabelAndRefs(docstring const & new_label, Cursor * cursor = 
nullptr);
+       void updateLabelAndRefs(docstring const & new_label, Cursor const * 
cursor = nullptr);
 
        /// \name Public functions inherited from Inset class
        //@{
diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index b5534a096f..f692789f7c 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -1562,7 +1562,7 @@ docstring bformat(docstring const & fmt, docstring const 
& arg1)
 }
 
 
-docstring bformat(docstring const & fmt, char * arg1)
+docstring bformat(docstring const & fmt, char const * arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        docstring const str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
diff --git a/src/support/lstrings.h b/src/support/lstrings.h
index 5f6f57a323..6e20f79ad3 100644
--- a/src/support/lstrings.h
+++ b/src/support/lstrings.h
@@ -385,7 +385,7 @@ docstring bformat(docstring const & fmt, long long arg1);
 #endif
 docstring bformat(docstring const & fmt, unsigned int arg1);
 docstring bformat(docstring const & fmt, docstring const & arg1);
-docstring bformat(docstring const & fmt, char * arg1);
+docstring bformat(docstring const & fmt, char const * arg1);
 docstring bformat(docstring const & fmt, docstring const & arg1, docstring 
const & arg2);
 docstring bformat(docstring const & fmt, docstring const & arg1, int arg2);
 docstring bformat(docstring const & fmt, char const * arg1, docstring const & 
arg2);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to