mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Refactoring based on cppcheck suggestions
This commit is contained in:
parent
a43d8501a2
commit
715b8cda54
@ -53,8 +53,7 @@ docstring Author::nameAndEmail() const
|
||||
{
|
||||
if (email().empty())
|
||||
return name();
|
||||
else
|
||||
return bformat(_("%1$s[[name]] (%2$s[[email]])"), name(), email());
|
||||
return bformat(_("%1$s[[name]] (%2$s[[email]])"), name(), email());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1549,9 +1549,8 @@ bool Buffer::save() const
|
||||
// time stamp is invalidated by copying/moving
|
||||
saveCheckSum();
|
||||
markClean();
|
||||
if (d->file_format != LYX_FORMAT)
|
||||
// the file associated with this buffer is now in the current format
|
||||
d->file_format = LYX_FORMAT;
|
||||
// the file associated with this buffer is now in the current format
|
||||
d->file_format = LYX_FORMAT;
|
||||
return true;
|
||||
}
|
||||
// else we saved the file, but failed to move it to the right location.
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
///
|
||||
Impl(Compare const & compare)
|
||||
: abort_(false), n_(0), m_(0), offset_reverse_diagonal_(0),
|
||||
odd_offset_(0), compare_(compare),
|
||||
odd_offset_(false), compare_(compare),
|
||||
old_buf_(nullptr), new_buf_(nullptr), dest_buf_(nullptr),
|
||||
dest_pars_(nullptr), recursion_level_(0), nested_inset_level_(0), D_(0)
|
||||
{}
|
||||
@ -413,7 +413,6 @@ void Compare::run()
|
||||
static_cast<InsetText &>(dest_buffer->inset()), el);
|
||||
|
||||
finished(pimpl_->abort_);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -737,7 +737,7 @@ void region(CursorSlice const & i1, CursorSlice const & i2,
|
||||
Inset::row_type & r1, Inset::row_type & r2,
|
||||
Inset::col_type & c1, Inset::col_type & c2)
|
||||
{
|
||||
Inset & p = i1.inset();
|
||||
Inset const & p = i1.inset();
|
||||
c1 = p.col(i1.idx());
|
||||
c2 = p.col(i2.idx());
|
||||
if (c1 > c2)
|
||||
@ -1079,7 +1079,7 @@ void copySelectionToStack()
|
||||
}
|
||||
|
||||
|
||||
void copySelectionToTemp(Cursor & cur)
|
||||
void copySelectionToTemp(Cursor const & cur)
|
||||
{
|
||||
copySelectionToStack(cur, tempCut);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void cutSelectionToTemp(Cursor & cur, bool realcut = true);
|
||||
/// Push the current selection to the cut buffer and the system clipboard.
|
||||
void copySelection(Cursor const & cur);
|
||||
/// Like copySelection, but only put to temporary cut buffer
|
||||
void copySelectionToTemp(Cursor & cur);
|
||||
void copySelectionToTemp(Cursor const & cur);
|
||||
///
|
||||
void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext);
|
||||
/**
|
||||
|
@ -1648,7 +1648,6 @@ int LaTeX::scanIlgFile(TeXErrors & terr)
|
||||
string prevtoken;
|
||||
while (getline(ifs, token)) {
|
||||
token = rtrim(token, "\r");
|
||||
smatch sub;
|
||||
if (prefixIs(token, "!! "))
|
||||
prevtoken = token;
|
||||
else if (!prevtoken.empty()) {
|
||||
|
@ -522,10 +522,10 @@ bool LaTeXFont::readFont(Lexer & lex)
|
||||
|
||||
bool LaTeXFont::read(Lexer & lex)
|
||||
{
|
||||
switchdefault_ = 0;
|
||||
osfdefault_ = 0;
|
||||
moreopts_ = 0;
|
||||
osffontonly_ = 0;
|
||||
switchdefault_ = false;
|
||||
osfdefault_ = false;
|
||||
moreopts_ = false;
|
||||
osffontonly_ = false;
|
||||
|
||||
if (!lex.next()) {
|
||||
lex.printError("No name given for LaTeX font: `$$Token'.");
|
||||
|
@ -278,9 +278,9 @@ bool Language::readLanguage(Lexer & lex)
|
||||
|
||||
bool Language::read(Lexer & lex)
|
||||
{
|
||||
encoding_ = 0;
|
||||
internal_enc_ = 0;
|
||||
rightToLeft_ = 0;
|
||||
encoding_ = nullptr;
|
||||
internal_enc_ = false;
|
||||
rightToLeft_ = false;
|
||||
|
||||
if (!lex.next()) {
|
||||
lex.printError("No name given for language: `$$Token'.");
|
||||
|
@ -1087,7 +1087,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
runparams.local_font = &basefont;
|
||||
}
|
||||
|
||||
if (fontswitch_inset && !closeLanguage && fontswitch_inset) {
|
||||
if (fontswitch_inset && !closeLanguage) {
|
||||
// The directionality has been switched at inset.
|
||||
// Force markup inside.
|
||||
runparams.local_font = &basefont;
|
||||
|
@ -94,11 +94,11 @@ public:
|
||||
};
|
||||
/// Increase or decrease the nesting depth of the selected paragraph(s)
|
||||
/// FIXME: replace Cursor with DocIterator.
|
||||
void changeDepth(Cursor & cur, DEPTH_CHANGE type);
|
||||
void changeDepth(Cursor const & cur, DEPTH_CHANGE type);
|
||||
|
||||
/// Returns whether something would be changed by changeDepth
|
||||
/// FIXME: replace Cursor with DocIterator.
|
||||
bool changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const;
|
||||
bool changeDepthAllowed(Cursor const & cur, DEPTH_CHANGE type) const;
|
||||
|
||||
/// Set font over selection paragraphs and rebreak.
|
||||
/// FIXME: replace Cursor with DocIterator.
|
||||
@ -356,7 +356,7 @@ private:
|
||||
/// handle the case where bibitems were deleted
|
||||
bool handleBibitems(Cursor & cur);
|
||||
/// are we in a list item (description etc.)?
|
||||
bool inDescriptionItem(Cursor & cur) const;
|
||||
bool inDescriptionItem(Cursor const & cur) const;
|
||||
///
|
||||
void charInserted(Cursor & cur);
|
||||
/// set 'number' font property
|
||||
|
@ -222,7 +222,7 @@ static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
|
||||
}
|
||||
|
||||
|
||||
bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
|
||||
bool Text::changeDepthAllowed(Cursor const & cur, DEPTH_CHANGE type) const
|
||||
{
|
||||
LBUFERR(this == cur.text());
|
||||
// this happens when selecting several cells in tabular (bug 2630)
|
||||
@ -242,7 +242,7 @@ bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
|
||||
}
|
||||
|
||||
|
||||
void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
|
||||
void Text::changeDepth(Cursor const & cur, DEPTH_CHANGE type)
|
||||
{
|
||||
LBUFERR(this == cur.text());
|
||||
pit_type const beg = cur.selBegin().pit();
|
||||
|
@ -3683,9 +3683,9 @@ void Text::pasteString(Cursor & cur, docstring const & clip,
|
||||
|
||||
|
||||
// FIXME: an item inset would make things much easier.
|
||||
bool Text::inDescriptionItem(Cursor & cur) const
|
||||
bool Text::inDescriptionItem(Cursor const & cur) const
|
||||
{
|
||||
Paragraph & par = cur.paragraph();
|
||||
Paragraph const & par = cur.paragraph();
|
||||
pos_type const pos = cur.pos();
|
||||
pos_type const body_pos = par.beginOfBody();
|
||||
|
||||
|
@ -221,7 +221,7 @@ void TextMetrics::newParMetricsUp()
|
||||
}
|
||||
|
||||
|
||||
bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width,
|
||||
bool TextMetrics::metrics(MetricsInfo const & mi, Dimension & dim, int min_width,
|
||||
bool const expand_on_multipars)
|
||||
{
|
||||
LBUFERR(mi.base.textwidth > 0);
|
||||
@ -676,7 +676,7 @@ void TextMetrics::setRowAlignment(Row & row, int width) const
|
||||
}
|
||||
|
||||
// are there any hfills in the row?
|
||||
ParagraphMetrics & pm = par_metrics_[row.pit()];
|
||||
ParagraphMetrics const & pm = par_metrics_[row.pit()];
|
||||
int nh = numberOfHfills(row, pm, par.beginOfBody());
|
||||
int hfill = 0;
|
||||
int hfill_rem = 0;
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
void newParMetricsUp();
|
||||
|
||||
/// compute text metrics.
|
||||
bool metrics(MetricsInfo & mi, Dimension & dim, int min_width = 0,
|
||||
bool metrics(MetricsInfo const & mi, Dimension & dim, int min_width = 0,
|
||||
bool const expand_on_multipars = true);
|
||||
|
||||
/// The "nodraw" drawing stage for one single paragraph: set the
|
||||
|
@ -180,7 +180,7 @@ bool TocBackend::updateItem(DocIterator const & dit_in)
|
||||
//
|
||||
// FIXME: This is supposed to accomplish the same as the body of
|
||||
// InsetText::iterateForToc(), probably
|
||||
Paragraph & par = toc_item->dit().paragraph();
|
||||
Paragraph const & par = toc_item->dit().paragraph();
|
||||
for (auto const & table : par.insetList())
|
||||
if (InsetArgument const * arg = table.inset->asInsetArgument()) {
|
||||
tocstring = par.labelString();
|
||||
|
@ -200,9 +200,7 @@ void Trans::addDeadkey(tex_accent accent, docstring const & keys)
|
||||
|
||||
int Trans::load(Lexer & lex)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
while (lex.isOK() && !error) {
|
||||
while (lex.isOK()) {
|
||||
switch (lex.lex()) {
|
||||
case KMOD:
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
|
||||
// with shift we (temporarily) change search/replace direction
|
||||
bool const searchback = searchbackCB->isChecked();
|
||||
if (e->modifiers() == Qt::ShiftModifier && !searchback)
|
||||
searchbackCB->setChecked(!searchback);
|
||||
searchbackCB->setChecked(true);
|
||||
|
||||
if (obj == find_work_area_)
|
||||
on_findNextPB_clicked();
|
||||
|
@ -269,7 +269,7 @@ void GuiBibtex::clearSelection()
|
||||
}
|
||||
|
||||
|
||||
void GuiBibtex::setSelectedBibs(QStringList const sl)
|
||||
void GuiBibtex::setSelectedBibs(QStringList const & sl)
|
||||
{
|
||||
selected_model_.clear();
|
||||
QStringList headers;
|
||||
|
@ -75,7 +75,7 @@ private:
|
||||
/// Clear selected keys
|
||||
void clearSelection();
|
||||
/// Set selected keys
|
||||
void setSelectedBibs(QStringList const);
|
||||
void setSelectedBibs(QStringList const &);
|
||||
/// prepares a call to GuiCitation::searchKeys when we
|
||||
/// are ready to search the Bib entries
|
||||
void findText(QString const & text);
|
||||
|
@ -286,8 +286,8 @@ void GuiBox::on_pagebreakCB_stateChanged()
|
||||
{
|
||||
bool pbreak = (pagebreakCB->checkState() == Qt::Checked);
|
||||
if (pbreak)
|
||||
widthCB->setChecked(!pbreak);
|
||||
if (!pbreak) {
|
||||
widthCB->setChecked(false);
|
||||
else {
|
||||
on_typeCO_activated(typeCO->currentIndex());
|
||||
return;
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ void GuiCitation::clearSelection()
|
||||
}
|
||||
|
||||
|
||||
void GuiCitation::setSelectedKeys(QStringList const sl)
|
||||
void GuiCitation::setSelectedKeys(QStringList const & sl)
|
||||
{
|
||||
selected_model_.clear();
|
||||
selected_model_.setColumnCount(3);
|
||||
|
@ -117,7 +117,7 @@ private:
|
||||
void clearSelection();
|
||||
|
||||
/// Set selected keys
|
||||
void setSelectedKeys(QStringList const);
|
||||
void setSelectedKeys(QStringList const &);
|
||||
/// Get selected keys
|
||||
QStringList selectedKeys();
|
||||
/// Set pre texts of qualified lists
|
||||
|
@ -569,7 +569,7 @@ void GuiLyXFiles::passParams(string const & data)
|
||||
}
|
||||
|
||||
|
||||
void GuiLyXFiles::selectItem(QString const item)
|
||||
void GuiLyXFiles::selectItem(QString const & item)
|
||||
{
|
||||
/* Using an intermediary variable flags is needed up to at least
|
||||
* Qt 5.5 because of a subtle namespace issue. See:
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
/// A way to pass params to the dialog directly
|
||||
void passParams(std::string const & data);
|
||||
/// A way to pass params to the dialog directly
|
||||
void selectItem(QString const item);
|
||||
void selectItem(QString const & item);
|
||||
Q_SIGNALS:
|
||||
void fileSelected(QString const file);
|
||||
|
||||
|
@ -357,11 +357,10 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
||||
bool whole, bool forward, bool findnext)
|
||||
{
|
||||
Cursor & cur = bv->cursor();
|
||||
bool found = false;
|
||||
if (!cur.selection()) {
|
||||
// no selection, non-empty search string: find it
|
||||
if (!searchstr.empty()) {
|
||||
found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
|
||||
bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
|
||||
return make_pair(found, 0);
|
||||
}
|
||||
// empty search string
|
||||
@ -390,7 +389,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
||||
// no selection or current selection is not search word:
|
||||
// just find the search word
|
||||
if (!have_selection || !match) {
|
||||
found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
|
||||
bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
|
||||
return make_pair(found, 0);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
|
||||
OutputType output, Encoding const * encoding)
|
||||
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
|
||||
output_(output), pendingspace_(false), pendingbrace_(false),
|
||||
textmode_(false), locked_(0), ascii_(0), canbreakline_(true),
|
||||
textmode_(false), locked_(false), ascii_(false), canbreakline_(true),
|
||||
mathsout_(false), ulemcmd_(NONE), line_(0), encoding_(encoding),
|
||||
row_entry_(TexRow::row_none), mathclass_(false)
|
||||
{}
|
||||
|
@ -1668,7 +1668,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
|| par->params().leftIndent() == nextpar->params().leftIndent())
|
||||
&& !runparams.for_search && cpar.size() > 0
|
||||
&& cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
|
||||
if (!bparams.output_changes && !cpar.parEndChange().deleted())
|
||||
if (!cpar.parEndChange().deleted())
|
||||
os << '\n' << '\n';
|
||||
continue;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ ForkedCall::sigPtr add(string const & process);
|
||||
static queue<Process> callQueue_;
|
||||
|
||||
/// flag whether queue is running
|
||||
static bool running_ = 0;
|
||||
static bool running_ = false;
|
||||
|
||||
///
|
||||
void startCaller();
|
||||
|
@ -134,7 +134,7 @@ Debug::Type Debug::value(string const & val)
|
||||
break;
|
||||
}
|
||||
if (st == string::npos)
|
||||
break;
|
||||
break;
|
||||
v.erase(0, st + 1);
|
||||
}
|
||||
return l;
|
||||
|
@ -344,8 +344,7 @@ protected:
|
||||
const int c = wctob(i);
|
||||
if (c == EOF)
|
||||
break;
|
||||
else
|
||||
M_narrow[i] = static_cast<char>(c);
|
||||
M_narrow[i] = static_cast<char>(c);
|
||||
}
|
||||
if (i == 128)
|
||||
M_narrow_ok = true;
|
||||
|
@ -497,8 +497,7 @@ void removeTempFile(FileName const & fn)
|
||||
return;
|
||||
|
||||
string const abs = fn.absFileName();
|
||||
if (tmp_names_.find(abs) != tmp_names_.end())
|
||||
tmp_names_.erase(abs);
|
||||
tmp_names_.erase(abs);
|
||||
fn.removeFile();
|
||||
}
|
||||
|
||||
|
@ -252,8 +252,8 @@ IconvProcessor & getProc(map<string, IconvProcessor> & processors,
|
||||
if (it == processors.end()) {
|
||||
IconvProcessor p(fromcode, tocode);
|
||||
return processors.insert(make_pair(encoding, move(p))).first->second;
|
||||
} else
|
||||
return it->second;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -2764,7 +2764,6 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
// paper sizes
|
||||
// some size options are known by the document class, other sizes
|
||||
// are handled by the \geometry command of the geometry package
|
||||
string paper;
|
||||
vector<string> class_psizes = getVectorFromString(tc.opt_pagesize(), "|");
|
||||
string const psize_format = tc.pagesizeformat();
|
||||
for (auto const & psize : class_psizes) {
|
||||
|
@ -48,7 +48,7 @@ extern std::string rgbcolor2code(std::string const & name);
|
||||
std::string translate_len(std::string const &);
|
||||
|
||||
void parse_text(Parser & p, std::ostream & os, unsigned flags, bool outer,
|
||||
Context & context, std::string const & rdelim = std::string());
|
||||
Context & context, std::string const & rdelim = "");
|
||||
void check_comment_bib(std::ostream & os, Context & context);
|
||||
|
||||
void fix_child_filename(std::string & name);
|
||||
@ -67,8 +67,8 @@ std::string find_file(std::string const & name, std::string const & path,
|
||||
*/
|
||||
void parse_text_in_inset(Parser & p, std::ostream & os, unsigned flags,
|
||||
bool outer, Context const & context,
|
||||
InsetLayout const * layout = 0,
|
||||
std::string const & rdelim = std::string());
|
||||
InsetLayout const * layout = nullptr,
|
||||
std::string const & rdelim = "");
|
||||
|
||||
/// Guess document language from \p p if CJK is used.
|
||||
/// \p lang is used for all non-CJK contents.
|
||||
|
Loading…
Reference in New Issue
Block a user