[LyX/master] Constify

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Oct 12 13:05:14 UTC 2020


commit 919a06718a1cc9612f54644444e7b91955460295
Author: Yuriy Skalko <yuriy.skalko at gmail.com>
Date:   Fri Oct 9 18:50:24 2020 +0300

    Constify
---
 src/Counters.cpp                |    2 +-
 src/Counters.h                  |    2 +-
 src/Text.h                      |    4 ++--
 src/Text2.cpp                   |    4 ++--
 src/Text3.cpp                   |    2 +-
 src/frontends/qt/Menus.cpp      |    3 +--
 src/insets/InsetFloat.cpp       |    2 +-
 src/lyxfind.cpp                 |   18 +++++++++---------
 src/mathed/InsetMathSideset.cpp |    4 ++--
 src/tex2lyx/table.cpp           |    2 +-
 src/tex2lyx/tex2lyx.h           |    2 +-
 11 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/Counters.cpp b/src/Counters.cpp
index 144f5ab..32968fc 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -412,7 +412,7 @@ bool Counters::remove(docstring const & cnt)
 }
 
 
-void Counters::copy(Counters & from, Counters & to, docstring const & match)
+void Counters::copy(Counters const & from, Counters & to, docstring const & match)
 {
 	for (auto const & ctr : counterList_) {
 		if (ctr.first.find(match) != string::npos || match == "") {
diff --git a/src/Counters.h b/src/Counters.h
index ffc091b..959a2f4 100644
--- a/src/Counters.h
+++ b/src/Counters.h
@@ -162,7 +162,7 @@ public:
 	bool remove(docstring const & cnt);
 	/// Copy counters whose name matches match from the &from to
 	/// the &to array of counters. Empty string matches all.
-	void copy(Counters & from, Counters & to,
+	void copy(Counters const & from, Counters & to,
 		  docstring const & match = docstring());
 	/** returns the expanded string representation of counter \c
 	 *  c. The \c lang code is used to translate the string.
diff --git a/src/Text.h b/src/Text.h
index 8209b09..723e66b 100644
--- a/src/Text.h
+++ b/src/Text.h
@@ -258,9 +258,9 @@ public:
 	 settings are given to the new one.
 	 This function will handle a multi-paragraph selection.
 	 */
-	void setParagraphs(Cursor & cur, docstring const & arg, bool modify = false);
+	void setParagraphs(Cursor const & cur, docstring const & arg, bool modify = false);
 	/// Sets parameters for current or selected paragraphs
-	void setParagraphs(Cursor & cur, ParagraphParameters const & p);
+	void setParagraphs(Cursor const & cur, ParagraphParameters const & p);
 
 	/* these things are for search and replace */
 
diff --git a/src/Text2.cpp b/src/Text2.cpp
index a78700c..ad5b8aa 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -487,7 +487,7 @@ void Text::setLabelWidthStringToSequence(Cursor const & cur,
 }
 
 
-void Text::setParagraphs(Cursor & cur, docstring const & arg, bool merge)
+void Text::setParagraphs(Cursor const & cur, docstring const & arg, bool merge)
 {
 	LBUFERR(cur.text());
 
@@ -515,7 +515,7 @@ void Text::setParagraphs(Cursor & cur, docstring const & arg, bool merge)
 }
 
 
-void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
+void Text::setParagraphs(Cursor const & cur, ParagraphParameters const & p)
 {
 	LBUFERR(cur.text());
 
diff --git a/src/Text3.cpp b/src/Text3.cpp
index af90404..10400f9 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -369,7 +369,7 @@ enum OutlineOp {
 };
 
 
-static void insertSeparator(Cursor & cur, depth_type const depth)
+static void insertSeparator(Cursor const & cur, depth_type const depth)
 {
 	Buffer & buf = *cur.buffer();
 	lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK));
diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp
index 5098994..5bf058f 100644
--- a/src/frontends/qt/Menus.cpp
+++ b/src/frontends/qt/Menus.cpp
@@ -1929,12 +1929,11 @@ void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv,
 	docstring prevlayout;
 	depth_type current_depth = par.params().depth();
 	// check if we have an environment in our scope
-	Paragraph cpar = par;
 	while (true) {
 		if (pit == 0)
 			break;
 		--pit;
-		cpar = text->getPar(pit);
+		Paragraph cpar = text->getPar(pit);
 		if (cpar.layout().isEnvironment() && prevlayout.empty()
 		    && cpar.params().depth() <= current_depth)
 				prevlayout = cpar.layout().name();
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 4e7db11..92397dd 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -627,7 +627,7 @@ std::tuple<InsetCode, const Inset *, const InsetCaption *, const InsetLabel *> d
 
 
 void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
-					   const InsetLabel * label, std::vector<const InsetCollapsible *> & subfigures)
+					   const InsetLabel * label, std::vector<const InsetCollapsible *> const & subfigures)
 {
 	// Ensure there is no label output, it is supposed to be handled as xml:id.
 	OutputParams rpNoLabel = runparams;
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 5d336b0..5b4bd3a 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1134,7 +1134,7 @@ public:
   void addIntervall(int upper);
   void addIntervall(int low, int upper); /* if explicit */
   void removeAccents();
-  void setForDefaultLang(KeyInfo &defLang);
+  void setForDefaultLang(KeyInfo const & defLang);
   int findclosing(int start, int end, char up, char down, int repeat);
   void handleParentheses(int lastpos, bool closingAllowed);
   bool hasTitle;
@@ -1162,7 +1162,7 @@ int Intervall::isOpeningPar(int pos)
   return 1;
 }
 
-void Intervall::setForDefaultLang(KeyInfo &defLang)
+void Intervall::setForDefaultLang(KeyInfo const & defLang)
 {
   // Enable the use of first token again
   if (ignoreidx >= 0) {
@@ -1475,7 +1475,7 @@ class LatexInfo {
   void buildEntries(bool);
   void makeKey(const string &, KeyInfo, bool isPatternString);
   void processRegion(int start, int region_end); /*  remove {} parts */
-  void removeHead(KeyInfo&, int count=0);
+  void removeHead(KeyInfo const &, int count=0);
 
  public:
  LatexInfo(string const & par, bool isPatternString)
@@ -1535,8 +1535,8 @@ class LatexInfo {
     }
     return -1;
   };
-  int process(ostringstream &os, KeyInfo &actual);
-  int dispatch(ostringstream &os, int previousStart, KeyInfo &actual);
+  int process(ostringstream & os, KeyInfo const & actual);
+  int dispatch(ostringstream & os, int previousStart, KeyInfo & actual);
   // string show(int lastpos) { return interval.show(lastpos);};
   int nextNotIgnored(int start) { return interval_.nextNotIgnored(start);};
   KeyInfo &getKeyInfo(int keyinfo) {
@@ -2220,7 +2220,7 @@ void LatexInfo::processRegion(int start, int region_end)
   }
 }
 
-void LatexInfo::removeHead(KeyInfo &actual, int count)
+void LatexInfo::removeHead(KeyInfo const & actual, int count)
 {
   if (actual.parenthesiscount == 0) {
     // "{\tiny{} ...}" ==> "{{} ...}"
@@ -2504,7 +2504,7 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
   return nextKeyIdx;
 }
 
-int LatexInfo::process(ostringstream &os, KeyInfo &actual )
+int LatexInfo::process(ostringstream & os, KeyInfo const & actual )
 {
   int end = interval_.nextNotIgnored(actual._dataEnd);
   int oldStart = actual._dataStart;
@@ -3349,7 +3349,7 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
 
 
 /// Finds forward
-int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
+int findForwardAdv(DocIterator & cur, MatchStringAdv const & match)
 {
 	if (!cur)
 		return 0;
@@ -3627,7 +3627,7 @@ static int findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, Ma
 		return 0;
 
 	// Build a copy of the replace buffer, adapted to the KeepCase option
-	Buffer & repl_buffer_orig = *theBufferList().getBuffer(FileName(to_utf8(opt.repl_buf_name)), true);
+	Buffer const & repl_buffer_orig = *theBufferList().getBuffer(FileName(to_utf8(opt.repl_buf_name)), true);
 	ostringstream oss;
 	repl_buffer_orig.write(oss);
 	string lyx = oss.str();
diff --git a/src/mathed/InsetMathSideset.cpp b/src/mathed/InsetMathSideset.cpp
index 642e07c..7dccfc1 100644
--- a/src/mathed/InsetMathSideset.cpp
+++ b/src/mathed/InsetMathSideset.cpp
@@ -194,7 +194,7 @@ void InsetMathSideset::metrics(MetricsInfo & mi, Dimension & dim) const
 		tr().metrics(mi, dimtr);
 	}
 
-	BufferView & bv = *mi.base.bv;
+	BufferView const & bv = *mi.base.bv;
 	// FIXME: data copying... not very efficient.
 
 	dim.wid = nwid(bv) + nker(mi.base.bv) + 2 * dx;
@@ -212,7 +212,7 @@ void InsetMathSideset::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetMathSideset::draw(PainterInfo & pi, int x, int y) const
 {
 	Changer dummy2 = pi.base.changeEnsureMath();
-	BufferView & bv = *pi.base.bv;
+	BufferView const & bv = *pi.base.bv;
 	nuc().draw(pi, x + dxn(bv), y);
 	if (!scriptl_)
 		bl().draw(pi, x          , y);
diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp
index c9f910f..8196267 100644
--- a/src/tex2lyx/table.cpp
+++ b/src/tex2lyx/table.cpp
@@ -939,7 +939,7 @@ void handle_hline_below(RowInfo & ri, vector<CellInfo> & ci)
 
 void handle_tabular(Parser & p, ostream & os, string const & name,
 		    string const & tabularwidth, string const & halign,
-		    Context & context)
+		    Context const & context)
 {
 	bool const is_long_tabular(name == "longtable" || name == "xltabular");
 	bool booktabs = false;
diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h
index 8ce7295..c73785e 100644
--- a/src/tex2lyx/tex2lyx.h
+++ b/src/tex2lyx/tex2lyx.h
@@ -82,7 +82,7 @@ void parse_math(Parser & p, std::ostream & os, unsigned flags, mode_type mode);
 /// in table.cpp
 void handle_tabular(Parser & p, std::ostream & os, std::string const & name,
 		    std::string const & width, std::string const & halign,
-		    Context & context);
+		    Context const & context);
 
 
 /// in tex2lyx.cpp


More information about the lyx-cvs mailing list