Remove warnings reported with gcc 4.3:

- Modifier on return type ignored
	- Ambigous else
	- Ambigous logical operators
	- Semi-colon instead of empty block
	- Missing header files
	- Missing using std::XX
	- Initialization out of order


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20304 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2007-09-16 10:36:57 +00:00
parent 150b11e953
commit 26f336769a
39 changed files with 109 additions and 89 deletions

View File

@ -365,9 +365,10 @@ bool Converters::convert(Buffer const * buffer,
cit != edgepath.end(); ++cit) {
Converter const & conv = converterlist_[*cit];
bool dummy = conv.To->dummy() && conv.to != "program";
if (!dummy)
if (!dummy) {
LYXERR(Debug::FILES) << "Converting from "
<< conv.from << " to " << conv.to << endl;
}
infile = outfile;
outfile = FileName(conv.result_dir.empty()
? changeExtension(from_file.absFilename(), conv.To->extension())

View File

@ -296,11 +296,12 @@ void ConverterCache::add(FileName const & orig_from, string const & to_format,
item->checksum = checksum;
}
if (!mover.copy(converted_file, item->cache_name,
support::onlyFilename(item->cache_name.absFilename()), 0600))
support::onlyFilename(item->cache_name.absFilename()), 0600)) {
LYXERR(Debug::FILES) << "ConverterCache::add("
<< orig_from << "):\n"
"Could not copy file."
<< std::endl;
}
} else {
CacheItem new_item(orig_from, to_format, timestamp,
support::sum(orig_from));

View File

@ -45,7 +45,7 @@ public:
data_.clear();
}
bool const empty() const
bool empty() const
{
return data_.empty();
}

View File

@ -78,7 +78,7 @@ Inset * DocIterator::prevInset() const
BOOST_ASSERT(!empty());
if (pos() == 0)
return 0;
if (inMathed())
if (inMathed()) {
if (cell().empty())
// FIXME: this should not happen but it does.
// See bug 3189
@ -86,6 +86,7 @@ Inset * DocIterator::prevInset() const
return 0;
else
return prevAtom().nucleus();
}
return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
}

View File

@ -28,6 +28,7 @@
#include <boost/filesystem/operations.hpp>
using std::find_if;
using std::string;
using std::distance;

View File

@ -274,9 +274,10 @@ bool Lexer::Pimpl::setFile(FileName const & filename)
// The check only outputs a debug message, because it triggers
// a bug in compaq cxx 6.2, where is_open() returns 'true' for
// a fresh new filebuf. (JMarc)
if (fb_.is_open() || istream::off_type(is.tellg()) > 0)
if (fb_.is_open() || istream::off_type(is.tellg()) > 0) {
LYXERR(Debug::LYXLEX) << "Error in Lexer::setFile: "
"file or stream already set." << endl;
}
fb_.open(filename.toFilesystemEncoding().c_str(), ios::in);
is.rdbuf(&fb_);
name = filename.absFilename();
@ -288,9 +289,10 @@ bool Lexer::Pimpl::setFile(FileName const & filename)
void Lexer::Pimpl::setStream(istream & i)
{
if (fb_.is_open() || istream::off_type(is.tellg()) > 0)
if (fb_.is_open() || istream::off_type(is.tellg()) > 0) {
LYXERR(Debug::LYXLEX) << "Error in Lexer::setStream: "
"file or stream already set." << endl;
}
is.rdbuf(i.rdbuf());
lineno = 0;
}

View File

@ -366,7 +366,7 @@ void LyX::setGuiLanguage(std::string const & language)
}
Buffer const * const LyX::updateInset(Inset const * inset) const
Buffer const * LyX::updateInset(Inset const * inset) const
{
if (quitting || !inset)
return 0;

View File

@ -103,7 +103,7 @@ public:
/** redraw \c inset in all the BufferViews in which it is currently
* visible. If successful return a pointer to the owning Buffer.
*/
Buffer const * const updateInset(Inset const *) const;
Buffer const * updateInset(Inset const *) const;
void hideDialogs(std::string const & name, Inset * inset) const;

View File

@ -71,7 +71,7 @@ using std::ostream;
using std::ostringstream;
ParagraphMetrics::ParagraphMetrics(Paragraph const & par): par_(&par), position_(-1)
ParagraphMetrics::ParagraphMetrics(Paragraph const & par): position_(-1), par_(&par)
{
}

View File

@ -24,14 +24,14 @@ namespace lyx {
Row::Row()
: changed_(false), crc_(0), pos_(0), end_(0), separator(0), hfill(0),
label_hfill(0), x(0), sel_beg(-1), sel_end(-1)
: separator(0), hfill(0), label_hfill(0), x(0),
sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(0), end_(0)
{}
Row::Row(pos_type pos)
: changed_(false), crc_(0), pos_(pos), end_(0), separator(0), hfill(0),
label_hfill(0), x(0), sel_beg(-1), sel_end(-1)
: separator(0), hfill(0), label_hfill(0), x(0),
sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(pos), end_(0)
{}
@ -89,7 +89,7 @@ void Row::setSelection(pos_type beg, pos_type end)
}
void Row::dump(const char * s) const
void Row::dump(char const * s) const
{
lyxerr << s << " pos: " << pos_ << " end: " << end_
<< " width: " << dim_.wid

View File

@ -64,7 +64,7 @@ public:
int descent() const { return dim_.des; }
/// current debugging only
void dump(const char * = "") const;
void dump(char const * = "") const;
/// width of a separator (i.e. space)
double separator;
@ -78,8 +78,6 @@ public:
pos_type sel_beg;
///
pos_type sel_end;
private:
/// has the Row appearance changed since last drawing?
bool changed_;

View File

@ -40,13 +40,13 @@ TocItem::TocItem(ParConstIterator const & par_it, int d,
}
int const TocItem::id() const
int TocItem::id() const
{
return par_it_->id();
}
int const TocItem::depth() const
int TocItem::depth() const
{
return depth_;
}

View File

@ -48,9 +48,9 @@ public:
///
~TocItem() {}
///
int const id() const;
int id() const;
///
int const depth() const;
int depth() const;
///
docstring const & str() const;
///

View File

@ -421,7 +421,7 @@ void LyXView::dispatch(FuncRequest const & cmd)
}
Buffer const * const LyXView::updateInset(Inset const * inset)
Buffer const * LyXView::updateInset(Inset const * inset)
{
WorkArea * work_area = currentWorkArea();
if (!work_area)

View File

@ -62,7 +62,7 @@ public:
virtual ~LyXView();
int const id() const { return id_; }
int id() const { return id_; }
virtual void close() = 0;
@ -174,7 +174,7 @@ public:
/** redraw \c inset in all the BufferViews in which it is currently
* visible. If successful return a pointer to the owning Buffer.
*/
Buffer const * const updateInset(Inset const *);
Buffer const * updateInset(Inset const *);
/// returns true if this view has the focus.
virtual bool hasFocus() const = 0;

View File

@ -124,7 +124,7 @@ bool ButtonPolicy::isReadOnly() const
}
static char const * const printState(ButtonPolicy::State const & state)
static char const * printState(ButtonPolicy::State const & state)
{
switch (state) {
case ButtonPolicy::INITIAL:
@ -151,7 +151,7 @@ static char const * const printState(ButtonPolicy::State const & state)
}
static char const * const printInput(ButtonPolicy::SMInput const & input)
static char const * printInput(ButtonPolicy::SMInput const & input)
{
switch (input) {
case ButtonPolicy::SMI_VALID:

View File

@ -109,7 +109,7 @@ void ControlCitation::filterByEntryType(
}
biblio::CiteEngine const ControlCitation::getEngine() const
biblio::CiteEngine ControlCitation::getEngine() const
{
return buffer().params().getEngine();
}

View File

@ -46,7 +46,7 @@ public:
void filterByEntryType(
std::vector<docstring> & keyVector, docstring entryType);
///
biblio::CiteEngine const getEngine() const;
biblio::CiteEngine getEngine() const;
/// \return information for this key.
docstring const getInfo(docstring const & key) const;

View File

@ -35,6 +35,7 @@
#include <sstream>
using std::ostringstream;
using std::sort;
using std::string;
using std::vector;
@ -60,7 +61,7 @@ ControlDocument::~ControlDocument()
{}
bool ControlDocument::initialiseParams(std::string const &)
bool ControlDocument::initialiseParams(string const &)
{
bp_.reset(new BufferParams);
*bp_ = buffer().params();
@ -100,7 +101,7 @@ vector<string> const & ControlDocument::getSelectedModules()
}
string ControlDocument::getModuleDescription(string modName) const
string ControlDocument::getModuleDescription(string const & modName) const
{
LyXModule const * const mod = moduleList[modName];
if (!mod)
@ -109,11 +110,12 @@ string ControlDocument::getModuleDescription(string modName) const
}
std::vector<std::string>
ControlDocument::getPackageList(std::string modName) const {
vector<string>
ControlDocument::getPackageList(string const & modName) const
{
LyXModule const * const mod = moduleList[modName];
if (!mod)
return std::vector<std::string>(); //empty such thing
return vector<string>(); //empty such thing
return mod->packageList;
}
@ -177,7 +179,7 @@ void ControlDocument::setLanguage() const
if (buffer().params().language == newL)
return;
string const lang_name = newL->lang();
string const & lang_name = newL->lang();
dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
}
@ -188,7 +190,7 @@ void ControlDocument::saveAsDefault() const
}
bool const ControlDocument::isFontAvailable(std::string const & font) const
bool ControlDocument::isFontAvailable(string const & font) const
{
if (font == "default" || font == "cmr"
|| font == "cmss" || font == "cmtt")
@ -212,7 +214,7 @@ bool const ControlDocument::isFontAvailable(std::string const & font) const
}
bool const ControlDocument::providesOSF(std::string const & font) const
bool ControlDocument::providesOSF(string const & font) const
{
if (font == "cmr")
return isFontAvailable("eco");
@ -223,7 +225,7 @@ bool const ControlDocument::providesOSF(std::string const & font) const
}
bool const ControlDocument::providesSC(std::string const & font) const
bool ControlDocument::providesSC(string const & font) const
{
if (font == "palatino")
return isFontAvailable("mathpazo");
@ -234,7 +236,7 @@ bool const ControlDocument::providesSC(std::string const & font) const
}
bool const ControlDocument::providesScale(std::string const & font) const
bool ControlDocument::providesScale(string const & font) const
{
return (font == "helvet" || font == "luximono"
|| font == "berasans" || font == "beramono");

View File

@ -66,21 +66,21 @@ public:
/// Modules in use in current buffer
std::vector<std::string> const & getSelectedModules();
///
std::string getModuleDescription(std::string modName) const;
std::string getModuleDescription(std::string const & modName) const;
///
std::vector<std::string> getPackageList(std::string modName) const;
std::vector<std::string> getPackageList(std::string const & modName) const;
///
void setLanguage() const;
///
void saveAsDefault() const;
///
bool const isFontAvailable(std::string const & font) const;
bool isFontAvailable(std::string const & font) const;
/// does this font provide Old Style figures?
bool const providesOSF(std::string const & font) const;
bool providesOSF(std::string const & font) const;
/// does this font provide true Small Caps?
bool const providesSC(std::string const & font) const;
bool providesSC(std::string const & font) const;
/// does this font provide size adjustment?
bool const providesScale(std::string const & font) const;
bool providesScale(std::string const & font) const;
private:
///
void loadModuleNames();

View File

@ -151,7 +151,7 @@ ParagraphParameters const & ControlParagraph::params() const
}
bool const ControlParagraph::haveMulitParSelection()
bool ControlParagraph::haveMulitParSelection()
{
Cursor cur = bufferview()->cursor();
return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit();

View File

@ -39,7 +39,7 @@ public:
///
ParagraphParameters const & params() const;
///
bool const haveMulitParSelection();
bool haveMulitParSelection();
///
bool inInset() const;
///

View File

@ -155,7 +155,7 @@ docstring const ControlPrefs::browsedir(docstring const & path,
// We support less paper sizes than the document dialog
// Therefore this adjustment is needed.
PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
PAPER_SIZE ControlPrefs::toPaperSize(int i) const
{
switch (i) {
case 0:
@ -181,7 +181,7 @@ PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
}
int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
int ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
{
switch (papersize) {
case PAPER_DEFAULT:

View File

@ -72,9 +72,9 @@ public:
void updateScreenFonts();
/// adjust the prefs paper sizes
PAPER_SIZE const toPaperSize(int i) const;
PAPER_SIZE toPaperSize(int i) const;
/// adjust the prefs paper sizes
int const fromPaperSize(PAPER_SIZE papersize) const;
int fromPaperSize(PAPER_SIZE papersize) const;
private:
/// temporary lyxrc

View File

@ -21,6 +21,7 @@
using lyx::docstring;
using std::find;
using std::vector;
using std::string;

View File

@ -48,13 +48,15 @@ using lyx::support::token;
using lyx::support::os::internal_path;
using std::find;
#ifndef CXX_GLOBAL_CSTD
using std::floor;
#endif
using std::vector;
using std::string;
using std::transform;
namespace lyx {
namespace frontend {
@ -89,22 +91,22 @@ void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
template<class Pair>
std::vector<typename Pair::first_type> const
getFirst(std::vector<Pair> const & pr)
vector<typename Pair::first_type> const
getFirst(vector<Pair> const & pr)
{
std::vector<typename Pair::first_type> tmp(pr.size());
std::transform(pr.begin(), pr.end(), tmp.begin(),
vector<typename Pair::first_type> tmp(pr.size());
transform(pr.begin(), pr.end(), tmp.begin(),
boost::bind(&Pair::first, _1));
return tmp;
}
///
template<class Pair>
std::vector<typename Pair::second_type> const
getSecond(std::vector<Pair> const & pr)
vector<typename Pair::second_type> const
getSecond(vector<Pair> const & pr)
{
std::vector<typename Pair::second_type> tmp(pr.size());
std::transform(pr.begin(), pr.end(), tmp.begin(),
vector<typename Pair::second_type> tmp(pr.size());
transform(pr.begin(), pr.end(), tmp.begin(),
boost::bind(&Pair::second, _1));
return tmp;
}
@ -725,4 +727,3 @@ bool GuiGraphicsDialog::isValid()
#include "GuiGraphics_moc.cpp"

View File

@ -77,9 +77,10 @@ Image::FormatList GuiImage::loadableFormats()
LYXERR(Debug::GRAPHICS)
<< "\nThe image loader can load the following directly:\n";
if (qt_formats.empty())
if (qt_formats.empty()) {
LYXERR(Debug::GRAPHICS)
<< "\nQt4 Problem: No Format available!" << endl;
}
for (QList<QByteArray>::const_iterator it =qt_formats.begin(); it != qt_formats.end(); ++it) {
@ -107,8 +108,9 @@ Image::FormatList GuiImage::loadableFormats()
FormatList::const_iterator fbegin = fmts.begin();
FormatList::const_iterator fend = fmts.end();
for (FormatList::const_iterator fit = fbegin; fit != fend; ++fit) {
if (fit != fbegin)
if (fit != fbegin) {
LYXERR(Debug::GRAPHICS) << ", ";
}
LYXERR(Debug::GRAPHICS) << *fit;
}
LYXERR(Debug::GRAPHICS) << '\n' << endl;

View File

@ -15,6 +15,8 @@
#include "debug.h"
#include <climits>
#include <vector>
#include <string>

View File

@ -327,11 +327,12 @@ void updateExternal(InsetExternalParams const & params,
params.filename, from_format, to_format, el,
Converters::try_default | Converters::try_cache);
if (!success)
if (!success) {
LYXERR(Debug::EXTERNAL)
<< "external::updateExternal. "
<< "Unable to convert from "
<< from_format << " to " << to_format << endl;
}
// return success
}

View File

@ -667,13 +667,14 @@ int InsetCollapsable::latex(Buffer const & buf, odocstream & os,
}
}
int i = InsetText::latex(buf, os, runparams);
if (!layout_.latexname.empty())
if (!layout_.latexname.empty()) {
if (layout_.latextype == "command") {
os << "}";
} else if (layout_.latextype == "environment") {
os << "\n\\end{" << from_utf8(layout_.latexname) << "}\n";
i += 4;
}
}
return i;
}

View File

@ -80,6 +80,7 @@ using support::subst;
using support::sum;
using std::endl;
using std::find;
using std::string;
using std::istringstream;
using std::ostream;

View File

@ -759,7 +759,7 @@ void InsetListingsParams::addParam(string const & key, string const & value)
if (params_.find(key) != params_.end())
// key=value,key=value1 is allowed in listings
// use key_, key__, key___ etc to avoid name conflict
while (params_.find(keyname += '_') != params_.end());
while (params_.find(keyname += '_') != params_.end()) { }
// check onoff flag
// onoff parameter with value false
if (!par_validator)

View File

@ -875,7 +875,7 @@ bool Tabular::leftAlreadyDrawn(idx_type cell) const
row_type row = cellRow(cell);
while (--column &&
(cell_info[row][column].multicolumn ==
Tabular::CELL_PART_OF_MULTICOLUMN));
Tabular::CELL_PART_OF_MULTICOLUMN)) { }
if (getAdditionalWidth(cell_info[row][column].cellno))
return false;
return rightLine(cell_info[row][column].cellno);

View File

@ -1402,12 +1402,12 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
}
status.setOnOff(s == "align-left" && halign(cur.col()) == 'l'
|| s == "align-right" && halign(cur.col()) == 'r'
|| s == "align-center" && halign(cur.col()) == 'c'
|| s == "valign-top" && valign() == 't'
|| s == "valign-bottom" && valign() == 'b'
|| s == "valign-middle" && valign() == 'm');
status.setOnOff((s == "align-left" && halign(cur.col()) == 'l')
|| (s == "align-right" && halign(cur.col()) == 'r')
|| (s == "align-center" && halign(cur.col()) == 'c')
|| (s == "valign-top" && valign() == 't')
|| (s == "valign-bottom" && valign() == 'b')
|| (s == "valign-middle" && valign() == 'm'));
#if 0
// FIXME: What did this code do?

View File

@ -207,8 +207,9 @@ TeXEnvironment(Buffer const & buf,
texrow.newline();
}
if (par != paragraphs.end())
if (par != paragraphs.end()) {
LYXERR(Debug::LATEX) << "TeXEnvironment...done " << &*par << endl;
}
return par;
}
@ -585,8 +586,9 @@ TeXOnePar(Buffer const & buf,
texrow.newline();
}
if (boost::next(pit) != paragraphs.end())
if (boost::next(pit) != paragraphs.end()) {
LYXERR(Debug::LATEX) << "TeXOnePar...done " << &*boost::next(pit) << endl;
}
return ++pit;
}

View File

@ -18,6 +18,7 @@
#include "support/docstring.h"
#include <cstring>
#include <vector>

View File

@ -60,7 +60,7 @@ inline bool is_utf16(char_type c)
* This does only exist because of performance reasons (a real conversion
* using iconv is too slow on windows).
*/
inline char_type const qchar_to_ucs4(QChar const & qchar)
inline char_type qchar_to_ucs4(QChar const & qchar)
{
BOOST_ASSERT(is_utf16(static_cast<char_type>(qchar.unicode())));
return static_cast<char_type>(qchar.unicode());

View File

@ -25,12 +25,13 @@ using std::string;
bool rename(FileName const & from, FileName const & to)
{
if (::rename(from.toFilesystemEncoding().c_str(), to.toFilesystemEncoding().c_str()) == -1)
if (::rename(from.toFilesystemEncoding().c_str(), to.toFilesystemEncoding().c_str()) == -1) {
if (copy(from, to)) {
unlink(from);
return true;
} else
return false;
}
return true;
}

View File

@ -37,6 +37,7 @@ using std::string;
using std::vector;
using std::cerr;
using std::endl;
using std::find;
using support::FileName;
using support::libFileSearch;