commit 1602b9f0f0da09828651db5ec30aa836ab70f770
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Sep 22 17:22:12 2026 +0200
Constify some parameters passed by reference
Spotted by cppcheck.
---
src/CutAndPaste.cpp | 2 +-
src/CutAndPaste.h | 2 +-
src/PDFOptions.cpp | 2 +-
src/PDFOptions.h | 2 +-
src/Paragraph.cpp | 6 +++---
src/Paragraph.h | 2 +-
src/frontends/qt/GuiApplication.cpp | 2 +-
src/frontends/qt/GuiApplication.h | 2 +-
src/frontends/qt/GuiCompleter.cpp | 2 +-
src/frontends/qt/GuiCompleter.h | 2 +-
src/frontends/qt/GuiWorkArea.cpp | 2 +-
src/frontends/qt/GuiWorkArea.h | 2 +-
src/insets/Inset.cpp | 2 +-
src/insets/Inset.h | 2 +-
src/insets/InsetTabular.cpp | 14 +++++++-------
src/insets/InsetTabular.h | 10 +++++-----
src/insets/RenderPreview.cpp | 2 +-
src/insets/RenderPreview.h | 2 +-
src/lyxfind.cpp | 10 +++++-----
src/mathed/InsetMathHull.cpp | 2 +-
src/mathed/InsetMathHull.h | 2 +-
src/mathed/InsetMathMacro.cpp | 6 +++---
src/mathed/InsetMathMacro.h | 4 ++--
src/mathed/MathSupport.cpp | 4 ++--
src/mathed/MathSupport.h | 4 ++--
src/tex2lyx/text.cpp | 2 +-
26 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 01581d1cb2..d3a2cd4905 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -1225,7 +1225,7 @@ void clearCutStack()
}
-docstring selection(size_t sel_index, BufferParams & bp, bool for_math)
+docstring selection(size_t sel_index, BufferParams const & bp, bool for_math)
{
if (sel_index >= theCuts.size())
return docstring();
diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h
index 68eac50198..3d2cd51ff0 100644
--- a/src/CutAndPaste.h
+++ b/src/CutAndPaste.h
@@ -45,7 +45,7 @@ size_type numberOfSelections();
* Get the sel_index-th element of the cut buffer in plain text format
* or, if \param for_math is true, in a format suitable for mathed.
*/
-docstring selection(size_t sel_index, BufferParams & bp, bool for_math =
false);
+docstring selection(size_t sel_index, BufferParams const & bp, bool for_math =
false);
/**
* Replace using the font of the first selected character and select
diff --git a/src/PDFOptions.cpp b/src/PDFOptions.cpp
index 64394db4a7..f55d4120f8 100644
--- a/src/PDFOptions.cpp
+++ b/src/PDFOptions.cpp
@@ -94,7 +94,7 @@ void PDFOptions::writeFile(ostream & os) const
}
-void PDFOptions::writeLaTeX(OutputParams & runparams, otexstream & os,
+void PDFOptions::writeLaTeX(OutputParams const & runparams, otexstream & os,
bool hyperref_already_provided) const
{
// FIXME Unicode
diff --git a/src/PDFOptions.h b/src/PDFOptions.h
index c0532ecded..b7d70ef652 100644
--- a/src/PDFOptions.h
+++ b/src/PDFOptions.h
@@ -36,7 +36,7 @@ public:
/// output to lyx header
void writeFile(std::ostream &) const;
/// output to tex header
- void writeLaTeX(OutputParams &, otexstream &,
+ void writeLaTeX(OutputParams const &, otexstream &,
bool hyperref_already_provided) const;
/// validate colors
void validate(LaTeXFeatures &) const;
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 8398b4b968..9d47831b62 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -340,7 +340,7 @@ public:
bool & open_font,
Change & running_change,
Layout const & style,
- pos_type & i,
+ pos_type i,
unsigned int & column,
bool const fontswitch_inset,
bool const closeLanguage,
@@ -1038,7 +1038,7 @@ void Paragraph::Private::latexInset(BufferParams const &
bparams,
bool & open_font,
Change & running_change,
Layout const & style,
- pos_type & i,
+ pos_type const i,
unsigned int & column,
bool const fontswitch_inset,
bool const closeLanguage,
@@ -4822,7 +4822,7 @@ bool Paragraph::brokenBiblio() const
}
-void Paragraph::fixBiblio(DocIterator & dit)
+void Paragraph::fixBiblio(DocIterator const & dit)
{
bool const track_changes = dit.buffer()->params().track_changes;
pos_type bibitem_pos = getInsetPos(BIBITEM_CODE, 0, true);
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 4f3b2d23ab..afd853ff9d 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -474,7 +474,7 @@ public:
/// Check if we are in a Biblio environment and insert or
/// delete InsetBibitems as necessary.
/// \param cur : the cursor that needs to be updated accordingly
- void fixBiblio(DocIterator & dit);
+ void fixBiblio(DocIterator const & dit);
/// For each author, set 'used' to true if there is a change
/// by this author in the paragraph.
diff --git a/src/frontends/qt/GuiApplication.cpp
b/src/frontends/qt/GuiApplication.cpp
index 0057c63100..5fef08dc53 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1629,7 +1629,7 @@ DispatchResult const &
GuiApplication::dispatch(FuncRequest const & cmd)
}
-void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult
& dr)
+void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult
const & dr)
{
if (!current_view_)
return;
diff --git a/src/frontends/qt/GuiApplication.h
b/src/frontends/qt/GuiApplication.h
index eff522eb3c..e5b13625af 100644
--- a/src/frontends/qt/GuiApplication.h
+++ b/src/frontends/qt/GuiApplication.h
@@ -264,7 +264,7 @@ private:
///
void validateCurrentView();
///
- void updateCurrentView(FuncRequest const & cmd, DispatchResult & dr);
+ void updateCurrentView(FuncRequest const & cmd, DispatchResult const &
dr);
///
bool closeAllViews();
/// Things that need to be done when the OSes session manager
diff --git a/src/frontends/qt/GuiCompleter.cpp
b/src/frontends/qt/GuiCompleter.cpp
index 9f29a265e8..7cc2f6b3e6 100644
--- a/src/frontends/qt/GuiCompleter.cpp
+++ b/src/frontends/qt/GuiCompleter.cpp
@@ -293,7 +293,7 @@ bool GuiCompleter::inlineVisible() const
}
-void GuiCompleter::updateVisibility(Cursor & cur, bool start, bool keep)
+void GuiCompleter::updateVisibility(Cursor const & cur, bool start, bool keep)
{
// parameters which affect the completion
bool moved = cur != old_cursor_;
diff --git a/src/frontends/qt/GuiCompleter.h b/src/frontends/qt/GuiCompleter.h
index 9cf5ad96d6..3b3713ae4a 100644
--- a/src/frontends/qt/GuiCompleter.h
+++ b/src/frontends/qt/GuiCompleter.h
@@ -54,7 +54,7 @@ public:
/// Update the visibility of the popup and the inline completion.
/// This method might set the update flags of the cursor to request
/// a redraw.
- void updateVisibility(Cursor & cur, bool start, bool keep);
+ void updateVisibility(Cursor const & cur, bool start, bool keep);
/// Update the visibility of the popup and the inline completion.
/// This method handles the redraw if needed.
void updateVisibility(bool start, bool keep);
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 1eb3fcdcbc..1a04ea313c 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -1746,7 +1746,7 @@ GuiWorkArea * TabWorkArea::currentWorkArea() const
}
-GuiWorkArea * TabWorkArea::workArea(Buffer & buffer) const
+GuiWorkArea * TabWorkArea::workArea(Buffer const & buffer) const
{
// FIXME: this method doesn't work if we have more than one work area
// showing the same buffer.
diff --git a/src/frontends/qt/GuiWorkArea.h b/src/frontends/qt/GuiWorkArea.h
index 15cdc03ad0..aab25ccff6 100644
--- a/src/frontends/qt/GuiWorkArea.h
+++ b/src/frontends/qt/GuiWorkArea.h
@@ -243,7 +243,7 @@ public:
GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
bool removeWorkArea(GuiWorkArea *);
GuiWorkArea * currentWorkArea() const;
- GuiWorkArea * workArea(Buffer & buffer) const;
+ GuiWorkArea * workArea(Buffer const & buffer) const;
GuiWorkArea * workArea(int index) const;
void paintEvent(QPaintEvent *) override;
diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 758ab4d904..022800715d 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -303,7 +303,7 @@ FontInfo Inset::getLabelfont() const
}
-Color Inset::getModeDependentColor(PainterInfo & pi) const
+Color Inset::getModeDependentColor(PainterInfo const & pi) const
{
FontInfo font = pi.base.font;
bool invert = false;
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 206b2c1b6c..25cf79a405 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -635,7 +635,7 @@ public:
///
virtual ColorCode labelColor() const;
///
- Color getModeDependentColor(PainterInfo & pi) const;
+ Color getModeDependentColor(PainterInfo const & pi) const;
///
Color getModeDependentColor(ColorCode const fgc, ColorCode const bgc)
const;
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 7c14731937..03e3d81b1f 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -1354,7 +1354,7 @@ int Tabular::cellHeight(idx_type cell) const
}
-bool Tabular::updateColumnWidths(MetricsInfo & mi)
+bool Tabular::updateColumnWidths(MetricsInfo const & mi)
{
vector<int> max_dwidth(ncols(), 0);
// collect max. fixed width of column
@@ -5150,7 +5150,7 @@ void InsetTabular::read(Lexer & lex)
}
-int InsetTabular::rowFromY(Cursor & cur, int const y) const
+int InsetTabular::rowFromY(Cursor const & cur, int const y) const
{
// top y coordinate of tabular
int h = yo(cur.bv()) - tabular.rowAscent(0) +
tabular.offsetVAlignment();
@@ -5165,7 +5165,7 @@ int InsetTabular::rowFromY(Cursor & cur, int const y)
const
}
-int InsetTabular::columnFromX(Cursor & cur, int x) const
+int InsetTabular::columnFromX(Cursor const & cur, int x) const
{
// left x coordinate of tabular
int w = xo(cur.bv()) + ADD_TO_TABULAR_WIDTH;
@@ -5324,7 +5324,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y)
const
bool const original_selection_state = pi.selected;
idx_type idx = 0;
-
+
// Save tabular change status
Change tab_change = pi.change;
@@ -5454,7 +5454,7 @@ void tabline(PainterInfo const & pi, int x1, int y1, int
x2, int y2, int lt, int
}
-void InsetTabular::drawCellLines(PainterInfo & pi, int x, int y,
+void InsetTabular::drawCellLines(PainterInfo const & pi, int x, int y,
row_type row, idx_type cell) const
{
y -= tabular.rowAscent(row);
@@ -7278,7 +7278,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, string
const & argument)
static void checkLongtableSpecial(Tabular::ltType & ltt,
- string const & special, bool & flag)
+ string const & special, bool const flag)
{
if (special == "dl_above") {
ltt.topDL = flag;
@@ -8353,7 +8353,7 @@ ParagraphList InsetTabular::asParList(idx_type stidx,
idx_type enidx)
}
-void InsetTabular::getSelection(Cursor & cur,
+void InsetTabular::getSelection(Cursor const & cur,
row_type & rs, row_type & re, col_type & cs, col_type & ce) const
{
CursorSlice const & beg = cur.selBegin();
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index f1cdea7a7d..72b13c002a 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -1011,7 +1011,7 @@ public:
///
bool setFixedWidth(row_type r, col_type c);
/// return true of update is needed
- bool updateColumnWidths(MetricsInfo & mi);
+ bool updateColumnWidths(MetricsInfo const & mi);
///
idx_type columnSpan(idx_type cell) const;
///
@@ -1212,9 +1212,9 @@ public:
/// lock cell with given index
void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
/// get table row from x coordinate
- int rowFromY(Cursor & cur, int y) const;
+ int rowFromY(Cursor const & cur, int y) const;
/// get table column from y coordinate
- int columnFromX(Cursor & cur, int x) const;
+ int columnFromX(Cursor const & cur, int x) const;
///
Inset * editXY(Cursor & cur, int x, int y) override;
/// can we go further down on mouse click?
@@ -1295,7 +1295,7 @@ private:
bool clickable(BufferView const &, int x, int y) const override;
///
- void drawCellLines(PainterInfo &, int x, int y, row_type row,
+ void drawCellLines(PainterInfo const &, int x, int y, row_type row,
idx_type cell) const;
///
void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
@@ -1317,7 +1317,7 @@ private:
///
void cutSelection(Cursor & cur);
///
- void getSelection(Cursor & cur, row_type & rs, row_type & re,
+ void getSelection(Cursor const & cur, row_type & rs, row_type & re,
col_type & cs, col_type & ce) const;
///
bool insertPlaintextString(BufferView &, docstring const & buf, bool
usePaste);
diff --git a/src/insets/RenderPreview.cpp b/src/insets/RenderPreview.cpp
index dea9aaae09..318f0e711b 100644
--- a/src/insets/RenderPreview.cpp
+++ b/src/insets/RenderPreview.cpp
@@ -213,7 +213,7 @@ void RenderPreview::addPreview(docstring const &
latex_snippet,
void RenderPreview::addPreview(docstring const & latex_snippet,
- graphics::PreviewLoader & ploader,
+ graphics::PreviewLoader const & ploader,
bool ignore_lyxrc)
{
if (lyxrc.preview == LyXRC::PREVIEW_OFF && !ignore_lyxrc)
diff --git a/src/insets/RenderPreview.h b/src/insets/RenderPreview.h
index f76d50b4f9..e58c0fc1f8 100644
--- a/src/insets/RenderPreview.h
+++ b/src/insets/RenderPreview.h
@@ -66,7 +66,7 @@ public:
* \param ignore_lyxrc: generate the preview no matter what LyXRC says
*/
void addPreview(docstring const & latex_snippet,
- graphics::PreviewLoader & ploader,
+ graphics::PreviewLoader const & ploader,
bool ignore_lyxrc = false);
/// Begin the loading process.
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 973af08418..ed9e262f7e 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1071,7 +1071,7 @@ public:
MatchResult(int len = 0): match_len(len),match_prefix(0),match2end(0),
pos(0),leadsize(0),pos_len(-1),searched_size(0) {}
};
-static MatchResult::range interpretMatch(MatchResult &oldres, MatchResult
&newres)
+static MatchResult::range interpretMatch(MatchResult const & oldres,
MatchResult const & newres)
{
if (newres.match2end < oldres.match2end)
return MatchResult::newIsTooFar;
@@ -1167,13 +1167,13 @@ public:
bool use_regexp = false;
static int valid_matches;
static vector <string> matches;
- void FillResults(MatchResult &found_mr);
+ void FillResults(MatchResult const &found_mr);
};
int MatchStringAdv::valid_matches = 0;
vector <string> MatchStringAdv::matches = vector <string>(10);
-void MatchStringAdv::FillResults(MatchResult &found_mr)
+void MatchStringAdv::FillResults(MatchResult const &found_mr)
{
if (found_mr.match_len > 0) {
valid_matches = found_mr.result.size();
@@ -4436,7 +4436,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int
len)
#if defined(ResultsDebug)
// Debugging output
-static void displayMResult(MatchResult &mres, string const & from, DocIterator
& cur)
+static void displayMResult(MatchResult const &mres, string const & from,
DocIterator const & cur)
{
LYXERR0( "from:\t\t\t" << from);
string status;
@@ -4742,7 +4742,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv &
match)
/// Find the most backward consecutive match within same paragraph while
searching backwards.
-MatchResult findMostBackwards(DocIterator & cur, MatchStringAdv const & match,
MatchResult &expected)
+MatchResult findMostBackwards(DocIterator & cur, MatchStringAdv const & match,
MatchResult const &expected)
{
DocIterator cur_begin = cur;
cur_begin.pos() = 0;
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 25fdcd8682..35ce0458ce 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -1874,7 +1874,7 @@ void InsetMathHull::check() const
}
-void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
+void InsetMathHull::doExtern(Cursor & cur, FuncRequest const & func)
{
//FIXME: sort out whether we want std::string or docstring for those
string const lang = func.getArg(0);
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index 64c2253298..12c0f46276 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -230,7 +230,7 @@ private:
///
docstring nicelabel(row_type row) const;
///
- void doExtern(Cursor & cur, FuncRequest & func);
+ void doExtern(Cursor & cur, FuncRequest const & func);
///
void glueall(HullType type);
/*!
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index c8b92b984f..244a09d744 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1122,7 +1122,7 @@ bool InsetMathMacro::notifyCursorLeaves(Cursor const &
old, Cursor & cur)
}
-void InsetMathMacro::fold(Cursor & cur)
+void InsetMathMacro::fold(Cursor const & cur)
{
if (!d->nextFoldMode_) {
d->nextFoldMode_ = true;
@@ -1131,7 +1131,7 @@ void InsetMathMacro::fold(Cursor & cur)
}
-void InsetMathMacro::unfold(Cursor & cur)
+void InsetMathMacro::unfold(Cursor const & cur)
{
if (d->nextFoldMode_) {
d->nextFoldMode_ = false;
@@ -1187,7 +1187,7 @@ void InsetMathMacro::writeMath(TeXMathStream & os) const
}
}
}
-
+
if (!uncodable.empty()) {
frontend::Alert::warning(
_("Uncodable characters in math macro"),
diff --git a/src/mathed/InsetMathMacro.h b/src/mathed/InsetMathMacro.h
index b712b30530..a4a1197df3 100644
--- a/src/mathed/InsetMathMacro.h
+++ b/src/mathed/InsetMathMacro.h
@@ -114,9 +114,9 @@ public:
void infoize2(odocstream &) const override;
/// fold the macro in the next metrics call
- void fold(Cursor & cur);
+ void fold(Cursor const & cur);
/// unfold the macro in the next metrics call
- void unfold(Cursor & cur);
+ void unfold(Cursor const & cur);
/// will it be folded or unfolded in the next metric call?
bool folded() const;
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 8a0475c56d..3e1b67f544 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -761,7 +761,7 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int
w, int h,
}
-docstring const & mathedSymbol(MetricsBase & mb, latexkeys const * sym)
+docstring const & mathedSymbol(MetricsBase const & mb, latexkeys const * sym)
{
return (mb.font.style() == DISPLAY_STYLE && !sym->dsp_draw.empty()) ?
sym->dsp_draw : sym->draw;
@@ -820,7 +820,7 @@ void mathedSymbolDraw(PainterInfo & pi, int x, int y,
latexkeys const * sym)
}
-void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const &
str)
+void metricsStrRedBlack(MetricsInfo const & mi, Dimension & dim, docstring
const & str)
{
FontInfo font = mi.base.font;
augmentFont(font, "mathnormal");
diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h
index 34ef8722c1..33d4cb865f 100644
--- a/src/mathed/MathSupport.h
+++ b/src/mathed/MathSupport.h
@@ -57,13 +57,13 @@ void mathed_string_dim(FontInfo const & font,
int mathed_string_width(FontInfo const &, docstring const & s);
-docstring const & mathedSymbol(MetricsBase & mb, latexkeys const * sym);
+docstring const & mathedSymbol(MetricsBase const & mb, latexkeys const * sym);
int mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym);
void mathedSymbolDraw(PainterInfo & pi, int x, int y, latexkeys const * sym);
-void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const &
s);
+void metricsStrRedBlack(MetricsInfo const & mi, Dimension & dim, docstring
const & s);
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s);
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & s);
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index a29df06fb9..04fc0cf3e3 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -133,7 +133,7 @@ void parse_text_snippet(Parser & p, ostream & os, unsigned
flags, bool outer,
* This is intended to parse text that does not create any layout changes.
*/
string parse_text_snippet(Parser & p, unsigned flags, const bool outer,
- Context & context)
+ Context const & context)
{
Context newcontext(context);
newcontext.need_layout = false;
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs