commit fe30c9e968a339592d0245d7be1bdf7fc4e8ebbb
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Sep 22 16:03:10 2026 +0200
Remove useless variables declarations or affectations
Spotted by cppcheck. The error message is
Variable 'XXXXX' is assigned a value that is never used. [unreadVariable]
---
src/Buffer.cpp | 2 --
src/BufferView.cpp | 1 -
src/CutAndPaste.cpp | 1 -
src/LaTeXFeatures.cpp | 1 -
src/Layout.cpp | 1 -
src/frontends/qt/GuiApplication.cpp | 2 +-
src/frontends/qt/GuiDocument.cpp | 6 ------
src/frontends/qt/GuiPrefs.cpp | 2 --
src/insets/InsetCounter.cpp | 1 -
src/insets/InsetInclude.cpp | 5 ++---
src/insets/InsetIndex.cpp | 4 ++--
src/insets/InsetLayout.cpp | 4 +---
src/insets/InsetRef.cpp | 1 -
src/lyxfind.cpp | 3 ---
src/mathed/MathFactory.cpp | 1 -
src/mathed/MathParser.cpp | 8 ++------
src/output_docbook.cpp | 1 -
src/support/ForkedCalls.cpp | 3 +--
src/tex2lyx/Parser.cpp | 2 +-
src/tex2lyx/math.cpp | 4 +---
src/tex2lyx/text.cpp | 4 +---
21 files changed, 12 insertions(+), 45 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index a580014118..15c4ba3e77 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3882,7 +3882,6 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring
const & name,
= it->second.buffer->getMacro(name, false);
macro_lock = false;
if (data) {
- bestPos = it->first;
bestData = data;
break;
}
@@ -5170,7 +5169,6 @@ void
Buffer::Impl::traverseErrors(TeXErrors::Errors::const_iterator err, TeXErro
buf = this->cloned_buffer_
?
child->d->cloned_buffer_->d->owner_
: child->d->owner_;
- p = child->d;
break;
}
}
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index f6698f65ae..ac79eec53c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1982,7 +1982,6 @@ void BufferView::dispatch(FuncRequest const & cmd,
DispatchResult & dr)
} else {
if (check_wrap) {
check_wrap = false;
- DocIterator cur_orig(cursor());
if (opt.forward) {
docstring q = _("End of file
reached while searching forward.\n"
"Continue searching
from the beginning?");
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 7b7df91c86..72ba42cb3b 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -551,7 +551,6 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList
const & parlist,
mergeParagraph(buffer.params(), pars, last_paste);
} else {
pars[last_paste +
1].stripLeadingSpaces(buffer.params().track_changes);
- ++last_paste;
}
}
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 952fd61c5c..0f4ad8c9f8 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -2437,7 +2437,6 @@ docstring const LaTeXFeatures::getThmI18nDefs(Layout
const & lay, bool const for
} else if (params_.xref_package == "prettyref-l7n" && lay.thmCounter() !=
"none"
&& !lay.thmXRefName().empty() && isRequired("prettyref")) {
odocstringstream ods;
- docstring const thmname = from_utf8(lay.thmName());
ods << "\\newrefformat{" << lay.refprefix << "}{_(" <<
from_utf8(lay.thmXRefName()) << ") \\ref{#1}}\n";
return ods.str();
}
diff --git a/src/Layout.cpp b/src/Layout.cpp
index 08230a5280..80556fe641 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -1718,7 +1718,6 @@ void Layout::write(ostream & os) const
if (!first)
os << ',';
os << " Right";
- first = false;
}
os << '\n';
}
diff --git a/src/frontends/qt/GuiApplication.cpp
b/src/frontends/qt/GuiApplication.cpp
index c4dc059074..0057c63100 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -569,7 +569,7 @@ IconInfo iconInfo(FuncRequest const & f, bool unknown, bool
rtl)
case LFUN_COMMAND_ALTERNATIVES: {
// use the first of the alternative commands
docstring firstcom;
- docstring dummy = split(f.argument(), firstcom, ';');
+ split(f.argument(), firstcom, ';');
QString name1 = toqstr(firstcom);
name1.replace(' ', '_');
name1.replace(';', '_');
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 0fc0c16cf9..a2183d19b4 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -3453,8 +3453,6 @@ void GuiDocument::updateMathFonts(QString const & rm)
{
if (fontModule->osFontsCB->isChecked())
return;
- QString const math =
-
fontModule->fontsMathCO->itemData(fontModule->fontsMathCO->currentIndex()).toString();
int const i = fontModule->fontsMathCO->findData("default");
if (providesNoMath(rm) && i == -1)
fontModule->fontsMathCO->insertItem(1, qt_("Class Default"),
QString("default"));
@@ -3596,7 +3594,6 @@ void GuiDocument::browseLayout()
void GuiDocument::browseMaster()
{
QString const title = qt_("Select master document");
- QString const dir1 = toqstr(lyxrc.document_path);
QString const old = latexModule->childDocLE->text();
QString const docpath =
toqstr(support::onlyPath(buffer().absFileName()));
QStringList const filter(qt_("LyX Files (*.lyx)"));
@@ -6315,8 +6312,6 @@ void GuiDocument::updateCustomColors()
colorModule->customColorsTW->clear();
- std::map<std::string, std::string> ccs;
-
map<QString, QString>::const_iterator it = custom_colors_.begin();
map<QString, QString>::const_iterator const end = custom_colors_.end();
for (; it != end; ++it) {
@@ -6337,7 +6332,6 @@ void GuiDocument::updateCustomColors()
colorModule->customColorsTW->setCurrentItem(newItem);
newItem->setSelected(true);
}
- ccs[fromqstr(cname)] = fromqstr(it->second);
}
colorModule->customColorsTW->resizeColumnToContents(0);
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 868cfc120e..d2510bf6e3 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -987,8 +987,6 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
void PrefScreenFonts::applyRC(LyXRC & rc) const
{
- LyXRC const oldrc = rc;
-
parseFontName(screenRomanCO->currentText(),
rc.roman_font_name, rc.roman_font_foundry);
parseFontName(screenSansCO->currentText(),
diff --git a/src/insets/InsetCounter.cpp b/src/insets/InsetCounter.cpp
index 3ea886e037..ed7cab1da7 100644
--- a/src/insets/InsetCounter.cpp
+++ b/src/insets/InsetCounter.cpp
@@ -199,7 +199,6 @@ void InsetCounter::updateBuffer(ParIterator const &,
UpdateType, bool const)
label = i.second;
}
LASSERT(!label.empty(), return);
- docstring const tlabel = translateIfPossible(from_ascii(label));
docstring guiname = translateIfPossible(cnts.guiName(cntr));
if (cmd == "set") {
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index ed57134cd6..ae9b936f22 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1168,7 +1168,6 @@ void InsetInclude::validate(LaTeXFeatures & features)
const
{
LATTEST(&buffer() == &features.buffer());
- string incfile = ltrim(to_utf8(params()["filename"]));
string const included_file =
includedFileName(buffer(), params()).absFileName();
@@ -1179,7 +1178,7 @@ void InsetInclude::validate(LaTeXFeatures & features)
const
writefile = included_file;
if (!features.runparams().nice && !isVerbatim(params()) &&
!isListings(params())) {
- incfile = DocFileName(writefile).mangledFileName();
+ string incfile = DocFileName(writefile).mangledFileName();
writefile = makeAbsPath(incfile,
buffer().masterBuffer()->temppath()).absFileName();
}
@@ -1204,7 +1203,7 @@ void InsetInclude::validate(LaTeXFeatures & features)
const
// Load the file in the include if it needs
// to be loaded:
Buffer * const tmp = loadIfNeeded();
- if (!tmp)
+ if (!tmp)
return;
// the file is loaded
diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index d8997c310e..0a38aa0993 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1243,9 +1243,9 @@ void InsetIndexParams::read(Lexer & lex)
else
index = from_ascii("idx");
if (lex.checkFor("range")) {
- string st = lex.getString();
+ lex.getString();
if (lex.eatLine()) {
- st = lex.getString();
+ lex.getString();
range =
insetindexpagerangetranslator().find(lex.getString());
}
}
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index 3fd06824a5..5e6f1ad5aa 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -554,16 +554,14 @@ bool InsetLayout::read(Lexer & lex, TextClass const &
tclass,
nlyxname = to_utf8(name_) + convert<string>(i);
}
ColorCode lcc = lcolor.getFromLyXName(lmcolor, false);
- string lyxname = lmcolor;
string lchexname;
if (lcc == Color_none &&
theLaTeXColors().isLaTeXColor(lmcolor)) {
LaTeXColor const lc =
theLaTeXColors().getLaTeXColor(lmcolor);
- lyxname = lc.name();
+ string lyxname = lc.name();
lchexname = lc.hexname();
lcolor.setColor(lyxname, lchexname);
lcolor.setLaTeXName(lyxname, lc.latex());
lcolor.setGUIName(lyxname,
to_ascii(lc.guiname()));
- lcc = lcolor.getFromLyXName(lyxname);
} else if (lcc != Color_none)
lchexname = lcolor.getX11HexName(lcc);
ColorCode dcc = lcolor.getFromLyXName(dmcolor, false);
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index c2a63565fa..3184312130 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -328,7 +328,6 @@ docstring InsetRef::getFormattedCmd(docstring const & ref,
if (use_caps) {
prefix = support::capitalize(prefix);
}
- defcmd = from_ascii("\\") + prefix + from_ascii("ref");
return (use_range) ? from_ascii("\\") + prefix + from_ascii("rangeref")
: from_ascii("\\") + prefix + from_ascii("ref");
}
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index a7481f4570..973af08418 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -3992,7 +3992,6 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf,
FindAndReplaceOptions & opts)
LYXERR(Debug::FINDVERBOSE, "par_as_string after correctRegex is
'" << par_as_string << "'");
if ((lng > 0) && (par_as_string[0] == '^')) {
par_as_string = par_as_string.substr(1);
- --lng;
opts.matchAtStart = true;
}
// LYXERR(Debug::FINDVERBOSE, "par_as_string now is '" <<
par_as_string << "'");
@@ -4789,7 +4788,6 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv &
match)
else
cur.pos() = cur_orig.pos();
LYXERR(Debug::FINDVERBOSE, "findBackAdv2: cur: " <<
showPos(cur));
- DocIterator cur_prev_iter;
do {
found_match = match(cur, -1,
MatchStringAdv::MatchFromStart);
LYXERR(Debug::FINDVERBOSE, "findBackAdv3:
found_match="
@@ -4805,7 +4803,6 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv &
match)
// Stop if begin of document reached
if (cur == cur_begin)
break;
- cur_prev_iter = cur;
cur.backwardPos();
} while (true);
}
diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp
index 5c24158f38..8e3d6117e6 100644
--- a/src/mathed/MathFactory.cpp
+++ b/src/mathed/MathFactory.cpp
@@ -855,7 +855,6 @@ bool createInsetMath_fromDialogStr(docstring const & str,
MathData & md)
// An example str:
// "ref LatexCommand ref\nreference \"sec:Title\"\n\\end_inset\n\n";
docstring name;
- docstring body = split(str, name, ' ');
if (name == "ref") {
InsetCommandParams icp(REF_CODE);
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index 383615cb93..0adfb81150 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -1085,11 +1085,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// read parameters
int nargs = 0;
- docstring pars;
- while (good() && nextToken().cat() != catBegin) {
- pars += getToken().cs();
+ while (good() && nextToken().cat() != catBegin)
++nargs;
- }
nargs /= 2;
// read definition
@@ -1225,9 +1222,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// parameter
// get option name
- docstring opt;
while (nextToken().cat() ==
catLetter)
- opt += getChar();
+ getChar();
// value?
skipSpaces();
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 4b420d43ef..b4bcc6ad20 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -858,7 +858,6 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const
¶graphs,
if (par.getDepth() == abstractDepth) {
// This is not an abstract paragraph and it
should not either be considered as part
// of it. It breaks the rule that abstract
paragraphs must follow each other.
- abstractDepth = INVALID_DEPTH;
break;
}
}
diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp
index c81c8af868..862d78325c 100644
--- a/src/support/ForkedCalls.cpp
+++ b/src/support/ForkedCalls.cpp
@@ -308,8 +308,6 @@ int ForkedCall::generateChild()
if (command_.empty())
return 1;
- string const prefixed_command = cmd_prefix_ + command_;
-
#if !defined (_WIN32)
// POSIX
@@ -317,6 +315,7 @@ int ForkedCall::generateChild()
// in a contiguous block of memory. The array contains pointers
// to each word.
// Don't forget the terminating `\0' character.
+ string const prefixed_command = cmd_prefix_ + command_;
char const * const c_str = prefixed_command.c_str();
vector<char> vec(c_str, c_str + prefixed_command.size() + 1);
diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index 11349aac41..4a01e1558c 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -869,7 +869,7 @@ void Parser::tokenize_one()
s += c;
// handle possible DOS line ending
if (catcode(c) == catNewline)
- c = getNewline(is_, c);
+ getNewline(is_, c);
// Note: The '%' at the beginning and the '\n' at the end
// of the comment are not stored.
++lineno_;
diff --git a/src/tex2lyx/math.cpp b/src/tex2lyx/math.cpp
index adda26dc74..832529c4ec 100644
--- a/src/tex2lyx/math.cpp
+++ b/src/tex2lyx/math.cpp
@@ -252,10 +252,8 @@ void parse_math(Parser & p, ostream & os, unsigned flags,
const mode_type mode)
else
os << t.asInput();
- if (flags & FLAG_LEAVE) {
- flags &= ~FLAG_LEAVE;
+ if (flags & FLAG_LEAVE)
break;
- }
}
}
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 7cb59232ae..a29df06fb9 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3357,10 +3357,8 @@ void parse_text(Parser & p, ostream & os, unsigned
flags, bool outer,
bool have_cycled = false;
while (p.good()) {
// Leave here only after at least one cycle
- if (have_cycled && flags & FLAG_LEAVE) {
- flags &= ~FLAG_LEAVE;
+ if (have_cycled && flags & FLAG_LEAVE)
break;
- }
Token const & t = p.get_token();
#ifdef FILEDEBUG
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs