commit 065db6806771190d12d37d64c4c86f9c5ebaf225
Author: Richard Heck <[email protected]>
Date: Fri Apr 4 15:54:32 2014 -0400
Fix a bunch of minor issues discovered by the cppcheck script.
diff --git a/src/Author.h b/src/Author.h
index 7d9f3dd..d62fcb0 100644
--- a/src/Author.h
+++ b/src/Author.h
@@ -67,10 +67,10 @@ public:
///
Author const & get(int id) const;
///
- typedef std::vector<Author> Authors;
- ///
void sort();
///
+ typedef std::vector<Author> Authors;
+ ///
Authors::const_iterator begin() const;
///
Authors::const_iterator end() const;
diff --git a/src/Compare.cpp b/src/Compare.cpp
index 1d72ebf..c2a01a6 100644
--- a/src/Compare.cpp
+++ b/src/Compare.cpp
@@ -384,7 +384,7 @@ void Compare::run()
AuthorList const & extra_authors = options_.settings_from_new ?
old_buffer->params().authors() : new_buffer->params().authors();
AuthorList::Authors::const_iterator it = extra_authors.begin();
- for (; it != extra_authors.end(); it++)
+ for (; it != extra_authors.end(); ++it)
dest_buffer->params().authors().record(*it);
doStatusMessage();
diff --git a/src/ConverterCache.cpp b/src/ConverterCache.cpp
index e384cdc..1451f6e 100644
--- a/src/ConverterCache.cpp
+++ b/src/ConverterCache.cpp
@@ -56,8 +56,7 @@ static FileName cache_dir;
class CacheItem {
public:
- CacheItem()
- {}
+ CacheItem() {}
CacheItem(FileName const & orig_from, string const & to_format,
time_t t, unsigned long c)
: timestamp(t), checksum(c)
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index d431965..964b593 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -635,7 +635,6 @@ bool Cursor::posVisRight(bool skip_inset)
Cursor new_cur = *this; // where we will move to
pos_type left_pos; // position visually left of current cursor
pos_type right_pos; // position visually right of current cursor
- bool new_pos_is_RTL; // is new position we're moving to RTL?
getSurroundingPos(left_pos, right_pos);
@@ -679,7 +678,7 @@ bool Cursor::posVisRight(bool skip_inset)
// we're currently to the left of 'right_pos'). In
// order to move to the right, it depends whether or
// not the character at 'right_pos' is RTL.
- new_pos_is_RTL = paragraph().getFontSettings(
+ bool const new_pos_is_RTL = paragraph().getFontSettings(
buffer()->params(), right_pos).isVisibleRightToLeft();
// If the character at 'right_pos' *is* LTR, then in
// order to move to the right of it, we need to be
@@ -735,7 +734,6 @@ bool Cursor::posVisLeft(bool skip_inset)
Cursor new_cur = *this; // where we will move to
pos_type left_pos; // position visually left of current cursor
pos_type right_pos; // position visually right of current cursor
- bool new_pos_is_RTL; // is new position we're moving to RTL?
getSurroundingPos(left_pos, right_pos);
@@ -779,7 +777,7 @@ bool Cursor::posVisLeft(bool skip_inset)
// currently to the right of 'left_pos'). In order to
// move to the left, it depends whether or not the
// character at 'left_pos' is RTL.
- new_pos_is_RTL = paragraph().getFontSettings(
+ bool const new_pos_is_RTL = paragraph().getFontSettings(
buffer()->params(), left_pos).isVisibleRightToLeft();
// If the character at 'left_pos' *is* RTL, then in
// order to move to the left of it, we need to be
diff --git a/src/Floating.cpp b/src/Floating.cpp
index 513c4fa..61b3b15 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -24,10 +24,6 @@ using namespace std;
namespace lyx {
-Floating::Floating()
-{}
-
-
Floating::Floating(string const & type, string const & placement,
string const & ext, string const & within,
string const & style, string const & name,
diff --git a/src/Floating.h b/src/Floating.h
index d1bf74c..b677f0c 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -26,7 +26,7 @@ namespace lyx {
class Floating {
public:
///
- Floating();
+ Floating() {}
///
Floating(std::string const & type, std::string const & placement,
std::string const & ext, std::string const & within,
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp
index e74eaa3..cf81253 100644
--- a/src/OutputParams.cpp
+++ b/src/OutputParams.cpp
@@ -20,7 +20,7 @@ namespace lyx {
OutputParams::OutputParams(Encoding const * enc)
: flavor(LATEX), math_flavor(NotApplicable), nice(false),
is_child(false),
- moving_arg(false), inulemcmd(0), local_font(0), master_language(0),
+ moving_arg(false), intitle(false), inulemcmd(0), local_font(0),
master_language(0),
encoding(enc), free_spacing(false), use_babel(false),
use_polyglossia(false),
use_indices(false), use_japanese(false), linelen(0), depth(0),
exportdata(new ExportData),
diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h
index a100651..e6ca9db 100644
--- a/src/ParagraphMetrics.h
+++ b/src/ParagraphMetrics.h
@@ -45,7 +45,7 @@ class PainterInfo;
class ParagraphMetrics {
public:
/// Default constructor (only here for STL containers).
- ParagraphMetrics() : par_(0) {}
+ ParagraphMetrics() : position_(0), par_(0) {}
/// The only useful constructor.
explicit ParagraphMetrics(Paragraph const & par);
diff --git a/src/PersonalWordList.h b/src/PersonalWordList.h
index 90777d8..d37b7d3 100644
--- a/src/PersonalWordList.h
+++ b/src/PersonalWordList.h
@@ -24,7 +24,7 @@ namespace lyx {
class PersonalWordList {
public:
/// the word list has an associated language
- PersonalWordList(std::string lang) { lang_ = lang; }
+ PersonalWordList(std::string lang) : lang_(lang), dirty_(false) {}
/// the location of the file to hold to word list
lyx::support::FileName dictfile() const;
/// (re)load the word list from file
@@ -44,11 +44,17 @@ public:
/// end of word list
docstring_list::const_iterator end() const;
private:
+ ///
docstring_list words_;
+ ///
std::string lang_;
+ ///
bool dirty_;
+ ///
bool equalwords(docstring const & w1, docstring const & w2) const;
+ ///
std::string header() const { return "# personal word list"; }
+ ///
void dirty(bool flag) { dirty_ = flag; }
};
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 31f27d9..5b9632d 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -219,7 +219,7 @@ enum TextClassTags {
TC_CITEENGINETYPE,
TC_CITEFORMAT,
TC_DEFAULTBIBLIO,
- TC_FULLAUTHORLIST,
+ TC_FULLAUTHORLIST
};
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index e122d6a..52e815a 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1152,11 +1152,10 @@ Dimension TextMetrics::rowHeight(pit_type const pit,
pos_type const first,
pit_type nextpit = pit + 1;
if (nextpit != pit_type(pars.size())) {
pit_type cpit = pit;
- double usual = 0;
- double unusual = 0;
if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
- usual = pars[cpit].layout().bottomsep * dh;
+ double usual = pars[cpit].layout().bottomsep *
dh;
+ double unusual = 0;
cpit = text_->depthHook(cpit,
pars[nextpit].getDepth());
if (pars[cpit].layout() !=
pars[nextpit].layout()
|| pars[nextpit].getLabelWidthString()
!= pars[cpit].getLabelWidthString())
diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h
index e7f01af..7267839 100644
--- a/src/frontends/Painter.h
+++ b/src/frontends/Painter.h
@@ -54,7 +54,6 @@ class Painter {
public:
Painter() : drawing_enabled_(true) {}
- float line_width;
static const float thin_line;
/// possible line styles
diff --git a/src/frontends/qt4/FindAndReplace.cpp
b/src/frontends/qt4/FindAndReplace.cpp
index e13f25d..3309803 100644
--- a/src/frontends/qt4/FindAndReplace.cpp
+++ b/src/frontends/qt4/FindAndReplace.cpp
@@ -110,8 +110,8 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj,
QEvent * event)
// back to how it was
searchbackCB->setChecked(searchback);
return true;
- break;
- }
+ }
+
case Qt::Key_Tab:
if (e->modifiers() == Qt::NoModifier) {
if (obj == find_work_area_){
diff --git a/src/frontends/qt4/GuiPainter.h b/src/frontends/qt4/GuiPainter.h
index a295078..2d2cf3f 100644
--- a/src/frontends/qt4/GuiPainter.h
+++ b/src/frontends/qt4/GuiPainter.h
@@ -41,8 +41,8 @@ public:
int x1, int y1,
int x2, int y2,
Color,
- line_style = line_solid,
- float line_width = thin_line);
+ line_style ls = line_solid,
+ float lw = thin_line);
/**
* lines - draw a set of lines
@@ -55,8 +55,8 @@ public:
int const * yp,
int np,
Color,
- line_style = line_solid,
- float line_width = thin_line);
+ line_style ls = line_solid,
+ float lw = thin_line);
/// draw a rectangle
virtual void rectangle(
@@ -64,7 +64,7 @@ public:
int w, int h,
Color,
line_style = line_solid,
- float line_width = thin_line);
+ float lw = thin_line);
/// draw a filled rectangle
virtual void fillRectangle(
diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp
index c816021..2b62371 100644
--- a/src/frontends/qt4/qt_helpers.cpp
+++ b/src/frontends/qt4/qt_helpers.cpp
@@ -77,7 +77,7 @@ FileName imageLibFileSearch(QString & dir, QString const &
name,
namespace {
-double locstringToDouble(QString const str)
+double locstringToDouble(QString const & str)
{
QLocale loc;
bool ok;
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 0ed8ff4..6d9bdca 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -108,8 +108,6 @@ public:
/// change associated Buffer
virtual void setBuffer(Buffer & buffer);
- /// remove the buffer reference
- void resetBuffer() { setBuffer( *static_cast<Buffer *>(0)); }
/// retrieve associated Buffer
virtual Buffer & buffer();
virtual Buffer const & buffer() const;
diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index 3da71d5..4f263e9 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -78,12 +78,10 @@ void InsetBibitem::initView()
void InsetBibitem::updateCommand(docstring const & new_key, bool)
{
docstring key = new_key;
-
vector<docstring> bibkeys = buffer().masterBibInfo().getKeys();
- int i = 1;
-
if (find(bibkeys.begin(), bibkeys.end(), key) != bibkeys.end()) {
+ int i = 1;
// generate unique label
key = new_key + '-' + convert<docstring>(i);
while (find(bibkeys.begin(), bibkeys.end(), key) !=
bibkeys.end()) {
@@ -131,7 +129,6 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest &
cmd)
docstring label = p["label"];
// definitions for escaping
- int previous;
static docstring const backslash = from_ascii("\\");
static docstring const lbrace = from_ascii("{");
static docstring const rbrace = from_ascii("}");
@@ -140,6 +137,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest &
cmd)
static char_type const brackets_escape[2] = {'[', ']'};
if (!label.empty()) {
+ int previous;
// The characters in chars_name[] need to be changed to
a command when
// they are in the name field.
for (int k = 0; k < 6; k++)
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 687561f..74e1af9 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -174,8 +174,6 @@ private:
///
std::string defaultCSSClass() const;
///
- std::string defaultCSSLabelClass() const { return defaultCSSClass() +
"_label"; }
- ///
void readArgument(Lexer &);
///
docstring name_;
diff --git a/src/insets/RenderBase.h b/src/insets/RenderBase.h
index 7cb10a8..cc1973e 100644
--- a/src/insets/RenderBase.h
+++ b/src/insets/RenderBase.h
@@ -53,7 +53,7 @@ public:
protected:
RenderBase() : state_(false) {}
- RenderBase(RenderBase const &x) : state_(x.state_){}
+ RenderBase(RenderBase const & x) : state_(x.state_) {}
RenderBase & operator=(RenderBase const &) { return *this; }
/// render state. currently, render_button uses this to store
mouse_hover_
diff --git a/src/lyxfind.h b/src/lyxfind.h
index 6b53da5..31f81e8 100644
--- a/src/lyxfind.h
+++ b/src/lyxfind.h
@@ -96,7 +96,7 @@ public:
SearchScope scope = S_BUFFER,
SearchRestriction restr = R_EVERYTHING
);
- FindAndReplaceOptions() { }
+ FindAndReplaceOptions() {}
docstring find_buf_name;
bool casesensitive;
bool matchword;
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 4a27d75..f7215e9 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -151,7 +151,7 @@ static InsetLabel * dummy_pointer = 0;
InsetMathHull::InsetMathHull(Buffer * buf)
: InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, true),
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
- preview_(new RenderPreview(this))
+ preview_(new RenderPreview(this)), use_preview_(false)
{
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
@@ -166,7 +166,7 @@ InsetMathHull::InsetMathHull(Buffer * buf)
InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
: InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, true),
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
- preview_(new RenderPreview(this))
+ preview_(new RenderPreview(this)), use_preview_(false)
{
buffer_ = buf;
initMath();
diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp
index 1999846..98fc589 100644
--- a/src/mathed/InsetMathSymbol.cpp
+++ b/src/mathed/InsetMathSymbol.cpp
@@ -29,17 +29,18 @@
namespace lyx {
InsetMathSymbol::InsetMathSymbol(latexkeys const * l)
- : sym_(l), h_(0), scriptable_(false)
+ : sym_(l), h_(0), kerning_(0), scriptable_(false)
{}
InsetMathSymbol::InsetMathSymbol(char const * name)
- : sym_(in_word_set(from_ascii(name))), h_(0), scriptable_(false)
+ : sym_(in_word_set(from_ascii(name))), h_(0),
+ kerning_(0), scriptable_(false)
{}
InsetMathSymbol::InsetMathSymbol(docstring const & name)
- : sym_(in_word_set(name)), h_(0), scriptable_(false)
+ : sym_(in_word_set(name)), h_(0), kerning_(0), scriptable_(false)
{}
diff --git a/src/support/debug.h b/src/support/debug.h
index a4887db..3425807 100644
--- a/src/support/debug.h
+++ b/src/support/debug.h
@@ -142,7 +142,7 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2)
class LyXErr
{
public:
- LyXErr(): enabled_(true), second_enabled_(false) {}
+ LyXErr(): dt_(Debug::NONE), enabled_(true), second_enabled_(false) {}
/// Disable the stream completely
void disable();