Refactoring

This commit is contained in:
Yuriy Skalko 2020-10-05 13:38:09 +03:00 committed by Jean-Marc Lasgouttes
parent d82adc625b
commit fe85162a29
61 changed files with 111 additions and 132 deletions

View File

@ -664,7 +664,6 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList_ptr clones) const
buffer_clone->setChild(dit, child_clone); buffer_clone->setChild(dit, child_clone);
} }
buffer_clone->d->macro_lock = false; buffer_clone->d->macro_lock = false;
return;
} }
@ -4010,10 +4009,7 @@ InsetLabel const * Buffer::insetLabel(docstring const & label,
bool Buffer::activeLabel(docstring const & label) const bool Buffer::activeLabel(docstring const & label) const
{ {
if (!insetLabel(label, true)) return insetLabel(label, true) != nullptr;
return false;
return true;
} }

View File

@ -1373,9 +1373,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
if (!lineno_opts.empty()) if (!lineno_opts.empty())
os << "\\lineno_options " << lineno_opts << '\n'; os << "\\lineno_options " << lineno_opts << '\n';
if (isbackgroundcolor == true) if (isbackgroundcolor)
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
if (isfontcolor == true) if (isfontcolor)
os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n'; os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
if (notefontcolor != lyx::rgbFromHexName("#cccccc")) if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n'; os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
@ -1979,7 +1979,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
} }
// only output when the background color is not default // only output when the background color is not default
if (isbackgroundcolor == true) { if (isbackgroundcolor) {
// only require color here, the background color will be defined // only require color here, the background color will be defined
// in LaTeXFeatures.cpp to avoid interferences with the LaTeX // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
// package pdfpages // package pdfpages
@ -1988,7 +1988,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
} }
// only output when the font color is not default // only output when the font color is not default
if (isfontcolor == true) { if (isfontcolor) {
// only require color here, the font color will be defined // only require color here, the font color will be defined
// in LaTeXFeatures.cpp to avoid interferences with the LaTeX // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
// package pdfpages // package pdfpages

View File

@ -228,7 +228,7 @@ bool DepTable::read(FileName const & f)
deplist[FileName(nome)] = di; deplist[FileName(nome)] = di;
} }
return deplist.size(); return !deplist.empty();
} }

View File

@ -32,7 +32,7 @@ ErrorItem::ErrorItem(docstring const & error_, docstring const & description_,
ErrorItem::ErrorItem() ErrorItem::ErrorItem()
: start(TexRow::text_none), end(TexRow::text_none), buffer(0) : start(TexRow::text_none), end(TexRow::text_none), buffer(nullptr)
{} {}

View File

@ -864,7 +864,7 @@ ostream & operator<<(ostream & os, FontInfo const & f)
ostream & operator<<(ostream & os, Font const & font) ostream & operator<<(ostream & os, Font const & font)
{ {
return os << font.bits_ return os << font.bits_
<< " lang: " << (font.lang_ ? font.lang_->lang() : nullptr); << " lang: " << (font.lang_ ? font.lang_->lang() : "");
} }

View File

@ -237,8 +237,8 @@ Hunspell * HunspellChecker::Private::lookup(Language const * lang)
Hunspell * HunspellChecker::Private::addSpeller(Language const * lang, string & path) Hunspell * HunspellChecker::Private::addSpeller(Language const * lang, string & path)
{ {
if (!haveDictionary(lang, path)) { if (!haveDictionary(lang, path)) {
spellers_[lang->lang()] = 0; spellers_[lang->lang()] = nullptr;
return 0; return nullptr;
} }
FileName const affix(path + ".aff"); FileName const affix(path + ".aff");

View File

@ -37,10 +37,10 @@ using namespace lyx::support;
namespace lyx { namespace lyx {
Languages languages; Languages languages;
Language const * ignore_language = 0; Language const * ignore_language = nullptr;
Language const * default_language = 0; Language const * default_language = nullptr;
Language const * latex_language = 0; Language const * latex_language = nullptr;
Language const * reset_language = 0; Language const * reset_language = nullptr;
bool Language::isPolyglossiaExclusive() const bool Language::isPolyglossiaExclusive() const
@ -344,12 +344,12 @@ void Languages::read(FileName const & filename)
break; break;
if (l.lang() == "latex") { if (l.lang() == "latex") {
// Check if latex language was not already defined. // Check if latex language was not already defined.
LASSERT(latex_language == 0, continue); LASSERT(latex_language == nullptr, continue);
static const Language latex_lang = l; static const Language latex_lang = l;
latex_language = &latex_lang; latex_language = &latex_lang;
} else if (l.lang() == "ignore") { } else if (l.lang() == "ignore") {
// Check if ignore language was not already defined. // Check if ignore language was not already defined.
LASSERT(ignore_language == 0, continue); LASSERT(ignore_language == nullptr, continue);
static const Language ignore_lang = l; static const Language ignore_lang = l;
ignore_language = &ignore_lang; ignore_language = &ignore_lang;
} else } else
@ -436,7 +436,7 @@ Language const * Languages::getFromCode(string const & code) const
if (match(code, l.second) == ApproximateMatch) if (match(code, l.second) == ApproximateMatch)
return &l.second; return &l.second;
} }
return 0; return nullptr;
} }
@ -460,7 +460,7 @@ Language const * Languages::getFromCode(string const & code,
return getFromCode(code); return getFromCode(code);
LYXERR0("Unknown language `" << code << "'"); LYXERR0("Unknown language `" << code << "'");
return 0; return nullptr;
} }

View File

@ -348,9 +348,7 @@ string LyXVC::toggleReadOnly()
bool LyXVC::inUse() const bool LyXVC::inUse() const
{ {
if (vcs) return vcs != nullptr;
return true;
return false;
} }

View File

@ -4810,7 +4810,7 @@ void Paragraph::spellCheck() const
// start the spell checker on the unit of meaning // start the spell checker on the unit of meaning
docstring word = asString(first, last, AS_STR_INSETS + AS_STR_SKIPDELETE); docstring word = asString(first, last, AS_STR_INSETS + AS_STR_SKIPDELETE);
WordLangTuple wl = WordLangTuple(word, lang); WordLangTuple wl = WordLangTuple(word, lang);
SpellChecker::Result result = word.size() ? SpellChecker::Result result = !word.empty() ?
speller->check(wl) : SpellChecker::WORD_OK; speller->check(wl) : SpellChecker::WORD_OK;
d->markMisspelledWords(first, last, result, word, skips); d->markMisspelledWords(first, last, result, word, skips);
first = ++last; first = ++last;

View File

@ -54,7 +54,7 @@ void PersonalWordList::load()
LYXERR(Debug::FILES, "load personal dictionary from: " << fn); LYXERR(Debug::FILES, "load personal dictionary from: " << fn);
ifstream ifs(fn.toFilesystemEncoding().c_str()); ifstream ifs(fn.toFilesystemEncoding().c_str());
dirty(words_.size() > 0); dirty(!words_.empty());
words_.clear(); words_.clear();
string line; string line;
getline(ifs, line); getline(ifs, line);

View File

@ -494,10 +494,7 @@ void AuthFilesSection::write(ostream & os) const
bool AuthFilesSection::find(string const & name) const bool AuthFilesSection::find(string const & name) const
{ {
if (auth_files_.find(name) != auth_files_.end()) return auth_files_.find(name) != auth_files_.end();
return true;
return false;
} }
@ -547,10 +544,7 @@ bool ShellEscapeSection::find(string const & name) const
bool ShellEscapeSection::findAuth(string const & name) const bool ShellEscapeSection::findAuth(string const & name) const
{ {
if (shellescape_files_.find(name + ",1") != shellescape_files_.end()) return shellescape_files_.find(name + ",1") != shellescape_files_.end();
return true;
return false;
} }

View File

@ -1778,7 +1778,7 @@ bool Text::backspace(Cursor & cur)
Cursor prev_cur = cur; Cursor prev_cur = cur;
--prev_cur.pit(); --prev_cur.pit();
if (cur.paragraph().size() > 0 if (!cur.paragraph().empty()
&& !prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) { && !prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
cur.recordUndo(prev_cur.pit(), prev_cur.pit()); cur.recordUndo(prev_cur.pit(), prev_cur.pit());
prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED)); prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));

View File

@ -1276,7 +1276,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
Paragraph const & nextpar = lastpar ? par : pars_[pit + 1]; Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit; pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
if (prev < pit && cur.pos() == par.beginOfBody() if (prev < pit && cur.pos() == par.beginOfBody()
&& !par.size() && !par.isEnvSeparator(cur.pos()) && par.empty() && !par.isEnvSeparator(cur.pos())
&& !par.layout().keepempty && !par.layout().keepempty
&& !par.layout().isCommand() && !par.layout().isCommand()
&& pars_[prev].layout() != par.layout() && pars_[prev].layout() != par.layout()

View File

@ -1486,7 +1486,7 @@ InsetList::Element * TextMetrics::checkInsetHit(pit_type pit, int x, int y)
} }
LYXERR(Debug::DEBUG, "No inset hit. "); LYXERR(Debug::DEBUG, "No inset hit. ");
return 0; return nullptr;
} }

View File

@ -510,7 +510,7 @@ docstring const TransDeadkeyState::deadkey(char_type c, KmodInfo d)
KmodException::const_iterator cit = deadkey_info_.exception_list.begin(); KmodException::const_iterator cit = deadkey_info_.exception_list.begin();
KmodException::const_iterator end = deadkey_info_.exception_list.end(); KmodException::const_iterator end = deadkey_info_.exception_list.end();
for (; cit != end; ++cit) { for (; cit != end; ++cit) {
if (cit->combined == true && cit->accent == d.accent) { if (cit->combined && cit->accent == d.accent) {
deadkey2_ = c; deadkey2_ = c;
deadkey2_info_ = d; deadkey2_info_ = d;
comb_info_ = (*cit); comb_info_ = (*cit);
@ -656,7 +656,7 @@ void TransManager::deadkey(char_type c, tex_accent accent, Text * t, Cursor & cu
// A deadkey was pressed that cannot be printed // A deadkey was pressed that cannot be printed
// or a accent command was typed in the minibuffer // or a accent command was typed in the minibuffer
KmodInfo i; KmodInfo i;
if (active_->isAccentDefined(accent, i) == true) { if (active_->isAccentDefined(accent, i)) {
docstring const res = trans_fsm_ docstring const res = trans_fsm_
.currentState->deadkey(c, i); .currentState->deadkey(c, i);
insert(res, t, cur); insert(res, t, cur);

View File

@ -1156,7 +1156,7 @@ SVN::SVN(FileName const & m, Buffer * b) : VCS(b)
// Here we know that the buffer file is either already in SVN or // Here we know that the buffer file is either already in SVN or
// about to be registered // about to be registered
master_ = m; master_ = m;
locked_mode_ = 0; locked_mode_ = false;
scanMaster(); scanMaster();
} }

View File

@ -154,7 +154,7 @@ public:
double pixelRatio() const { return pixel_ratio_; } double pixelRatio() const { return pixel_ratio_; }
double develMode() const { return devel_mode_; } bool develMode() const { return devel_mode_; }
/// draw the underbar, strikeout, xout, uuline and uwave font attributes /// draw the underbar, strikeout, xout, uuline and uwave font attributes
virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0; virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0;

View File

@ -71,7 +71,7 @@ private:
class CCFilterModel : public QSortFilterProxyModel { class CCFilterModel : public QSortFilterProxyModel {
public: public:
/// ///
CCFilterModel(QObject * parent = 0) CCFilterModel(QObject * parent = nullptr)
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
{} {}
}; };

View File

@ -60,7 +60,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
m_lineEdit(parent) m_lineEdit(parent)
{ {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
m_menu[i] = 0; m_menu[i] = nullptr;
m_menuTabFocusTrigger[i] = false; m_menuTabFocusTrigger[i] = false;
m_iconbutton[i] = new IconButton(parent); m_iconbutton[i] = new IconButton(parent);
m_iconbutton[i]->installEventFilter(this); m_iconbutton[i]->installEventFilter(this);

View File

@ -599,7 +599,7 @@ FindAndReplace::FindAndReplace(GuiView & parent,
FindAndReplace::~FindAndReplace() FindAndReplace::~FindAndReplace()
{ {
setFocusProxy(0); setFocusProxy(nullptr);
delete widget_; delete widget_;
} }
@ -620,7 +620,7 @@ void FindAndReplaceWidget::updateGUI()
old_buffer_ = &bv->buffer(); old_buffer_ = &bv->buffer();
} }
} else } else
old_buffer_ = 0; old_buffer_ = nullptr;
bool const replace_enabled = bv && !bv->buffer().isReadonly(); bool const replace_enabled = bv && !bv->buffer().isReadonly();
replace_work_area_->setEnabled(replace_enabled); replace_work_area_->setEnabled(replace_enabled);

View File

@ -35,7 +35,7 @@ namespace frontend {
FloatPlacement::FloatPlacement(bool show_options, QWidget * parent) FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
: InsetParamsWidget(parent), standardfloat_(true), : InsetParamsWidget(parent), standardfloat_(true),
allows_wide_(true), allows_sideways_(true), float_list_(0) allows_wide_(true), allows_sideways_(true), float_list_(nullptr)
{ {
setupUi(this); setupUi(this);

View File

@ -895,8 +895,8 @@ public:
struct GuiApplication::Private struct GuiApplication::Private
{ {
Private(): language_model_(0), meta_fake_bit(NoModifier), Private(): language_model_(nullptr), meta_fake_bit(NoModifier),
global_menubar_(0) global_menubar_(nullptr)
{ {
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) #if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
@ -993,7 +993,7 @@ GuiApplication::~GuiApplication()
GuiApplication::GuiApplication(int & argc, char ** argv) GuiApplication::GuiApplication(int & argc, char ** argv)
: QApplication(argc, argv), current_view_(0), : QApplication(argc, argv), current_view_(nullptr),
d(new GuiApplication::Private) d(new GuiApplication::Private)
{ {
QString app_name = "LyX"; QString app_name = "LyX";
@ -1123,8 +1123,8 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const
{ {
FuncStatus status; FuncStatus status;
BufferView * bv = 0; BufferView * bv = nullptr;
BufferView * doc_bv = 0; BufferView * doc_bv = nullptr;
if (cmd.action() == LFUN_NOACTION) { if (cmd.action() == LFUN_NOACTION) {
status.message(from_utf8(N_("Nothing to do"))); status.message(from_utf8(N_("Nothing to do")));
@ -1289,7 +1289,7 @@ bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const
break; break;
case LFUN_WINDOW_CLOSE: case LFUN_WINDOW_CLOSE:
enable = d->views_.size() > 0; enable = !d->views_.empty();
break; break;
case LFUN_BUFFER_NEW: case LFUN_BUFFER_NEW:

View File

@ -58,7 +58,7 @@ namespace lyx {
namespace frontend { namespace frontend {
GuiErrorList::GuiErrorList(GuiView & lv) GuiErrorList::GuiErrorList(GuiView & lv)
: GuiDialog(lv, "errorlist", qt_("Error List")), buf_(0), from_master_(false) : GuiDialog(lv, "errorlist", qt_("Error List")), buf_(nullptr), from_master_(false)
{ {
setupUi(this); setupUi(this);

View File

@ -173,7 +173,7 @@ bool GuiImage::clip(Params const & params)
bool GuiImage::rotate(Params const & params) bool GuiImage::rotate(Params const & params)
{ {
if (!params.angle) if (params.angle == 0)
return false; return false;
QImage const & image = is_transformed_ ? transformed_ : original_; QImage const & image = is_transformed_ ? transformed_ : original_;

View File

@ -187,7 +187,6 @@ void GuiRef::selectionChanged()
return; return;
QTreeWidgetItem * sel = selections.first(); QTreeWidgetItem * sel = selections.first();
refHighlighted(sel); refHighlighted(sel);
return;
} }

View File

@ -38,7 +38,7 @@ namespace frontend {
GuiSendTo::GuiSendTo(GuiView & lv) GuiSendTo::GuiSendTo(GuiView & lv)
: GuiDialog(lv, "sendto", qt_("Export or Send Document")), format_(0) : GuiDialog(lv, "sendto", qt_("Export or Send Document")), format_(nullptr)
{ {
setupUi(this); setupUi(this);
@ -77,7 +77,7 @@ void GuiSendTo::updateContents()
Format const * current_format = nullptr; Format const * current_format = nullptr;
int const line = formatLW->currentRow(); int const line = formatLW->currentRow();
if (line >= 0 && static_cast<unsigned int>(line) < all_formats.size() if (line >= 0 && static_cast<unsigned int>(line) < all_formats.size()
&& formatLW->selectedItems().size() > 0) && !formatLW->selectedItems().empty())
current_format = all_formats[line]; current_format = all_formats[line];
// Reset the list widget // Reset the list widget
formatLW->clear(); formatLW->clear();
@ -115,14 +115,14 @@ bool GuiSendTo::isValid()
if (line < 0 || (line > int(formatLW->count()))) if (line < 0 || (line > int(formatLW->count())))
return false; return false;
return (formatLW->selectedItems().size() > 0 return (!formatLW->selectedItems().empty()
&& formatLW->count() != 0); && formatLW->count() != 0);
} }
bool GuiSendTo::initialiseParams(string const &) bool GuiSendTo::initialiseParams(string const &)
{ {
format_ = 0; format_ = nullptr;
paramsToDialog(format_, command_); paramsToDialog(format_, command_);
return true; return true;
} }

View File

@ -207,7 +207,7 @@ class GuiSymbols::Model : public QAbstractListModel
{ {
public: public:
Model(GuiSymbols * parent) Model(GuiSymbols * parent)
: QAbstractListModel(parent), encoding_(0) : QAbstractListModel(parent), encoding_(nullptr)
{} {}
QModelIndex index(int row, int column, QModelIndex const &) const override QModelIndex index(int row, int column, QModelIndex const &) const override

View File

@ -64,7 +64,7 @@ namespace frontend {
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false), owner_(owner), command_buffer_(nullptr), tbinfo_(tbinfo), filled_(false),
restored_(false) restored_(false)
{ {
setIconSize(owner.iconSize()); setIconSize(owner.iconSize());
@ -297,7 +297,7 @@ class DynamicMenuButton::Private
Private(Private const &); Private(Private const &);
void operator=(Private const &); void operator=(Private const &);
public: public:
Private() : inset_(0) {} Private() : inset_(nullptr) {}
/// ///
DocumentClassConstPtr text_class_; DocumentClassConstPtr text_class_;
/// ///

View File

@ -1187,7 +1187,7 @@ void GuiView::dropEvent(QDropEvent * event)
found_formats.push_back(*it); found_formats.push_back(*it);
FuncRequest cmd; FuncRequest cmd;
if (found_formats.size() >= 1) { if (!found_formats.empty()) {
if (found_formats.size() > 1) { if (found_formats.size() > 1) {
//FIXME: show a dialog to choose the correct importable format //FIXME: show a dialog to choose the correct importable format
LYXERR(Debug::FILES, LYXERR(Debug::FILES,

View File

@ -1061,7 +1061,6 @@ void GuiWorkArea::generateSyntheticMouseEvent()
cur.boundary(bound); cur.boundary(bound);
d->buffer_view_->buffer().changed(false); d->buffer_view_->buffer().changed(false);
return;
} }

View File

@ -85,7 +85,7 @@ private:
class GuiLayoutFilterModel : public QSortFilterProxyModel { class GuiLayoutFilterModel : public QSortFilterProxyModel {
public: public:
/// ///
GuiLayoutFilterModel(QObject * parent = 0) GuiLayoutFilterModel(QObject * parent = nullptr)
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
{} {}
@ -111,7 +111,7 @@ class LayoutBox::Private
void operator=(Private const &); void operator=(Private const &);
public: public:
Private(LayoutBox * parent, GuiView & gv) : p(parent), owner_(gv), Private(LayoutBox * parent, GuiView & gv) : p(parent), owner_(gv),
inset_(0), inset_(nullptr),
// set the layout model with two columns // set the layout model with two columns
// 1st: translated layout names // 1st: translated layout names
// 2nd: raw layout names // 2nd: raw layout names
@ -567,7 +567,7 @@ void LayoutBox::updateContents(bool reset)
setEnabled(false); setEnabled(false);
setMinimumWidth(sizeHint().width()); setMinimumWidth(sizeHint().width());
d->text_class_.reset(); d->text_class_.reset();
d->inset_ = 0; d->inset_ = nullptr;
return; return;
} }
// we'll only update the layout list if the text class has changed // we'll only update the layout list if the text class has changed

View File

@ -97,7 +97,7 @@ PanelStack::PanelStack(QWidget * parent)
void PanelStack::addCategory(QString const & name, QString const & parent) void PanelStack::addCategory(QString const & name, QString const & parent)
{ {
QTreeWidgetItem * item = 0; QTreeWidgetItem * item = nullptr;
LYXERR(Debug::GUI, "addCategory n= " << name << " parent= "); LYXERR(Debug::GUI, "addCategory n= " << name << " parent= ");

View File

@ -418,7 +418,7 @@ ToolbarInfo const * Toolbars::info(std::string const & name) const
for (Infos::const_iterator it = toolbar_info_.begin(); it != end; ++it) for (Infos::const_iterator it = toolbar_info_.begin(); it != end; ++it)
if (it->name == name) if (it->name == name)
return &(*it); return &(*it);
return 0; return nullptr;
} }

View File

@ -393,7 +393,7 @@ bool InsetIPADeco::insetAllowed(InsetCode code) const
InsetIPAChar::InsetIPAChar(Kind k) InsetIPAChar::InsetIPAChar(Kind k)
: Inset(0), kind_(k) : Inset(nullptr), kind_(k)
{} {}

View File

@ -36,7 +36,7 @@ using namespace std;
namespace lyx { namespace lyx {
InsetNewline::InsetNewline() : Inset(0) InsetNewline::InsetNewline() : Inset(nullptr)
{} {}

View File

@ -37,12 +37,12 @@ using namespace std;
namespace lyx { namespace lyx {
InsetNewpage::InsetNewpage() : Inset(0) InsetNewpage::InsetNewpage() : Inset(nullptr)
{} {}
InsetNewpage::InsetNewpage(InsetNewpageParams const & params) InsetNewpage::InsetNewpage(InsetNewpageParams const & params)
: Inset(0), params_(params) : Inset(nullptr), params_(params)
{} {}

View File

@ -171,7 +171,7 @@ docstring InsetPrintNomencl::screenLabel() const
struct NomenclEntry { struct NomenclEntry {
NomenclEntry() : par(0) {} NomenclEntry() : par(nullptr) {}
NomenclEntry(docstring s, docstring d, Paragraph const * p) NomenclEntry(docstring s, docstring d, Paragraph const * p)
: symbol(s), desc(d), par(p) : symbol(s), desc(d), par(p)
{} {}
@ -381,7 +381,7 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
int w = 0; int w = 0;
docstring symb; docstring symb;
InsetNomencl const * nomencl = 0; InsetNomencl const * nomencl = nullptr;
ParagraphList::const_iterator it = buffer.paragraphs().begin(); ParagraphList::const_iterator it = buffer.paragraphs().begin();
ParagraphList::const_iterator end = buffer.paragraphs().end(); ParagraphList::const_iterator end = buffer.paragraphs().end();

View File

@ -36,12 +36,12 @@ using namespace lyx::frontend;
namespace lyx { namespace lyx {
InsetSeparator::InsetSeparator() : Inset(0) InsetSeparator::InsetSeparator() : Inset(nullptr)
{} {}
InsetSeparator::InsetSeparator(InsetSeparatorParams const & params) InsetSeparator::InsetSeparator(InsetSeparatorParams const & params)
: Inset(0), params_(params) : Inset(nullptr), params_(params)
{} {}

View File

@ -45,7 +45,7 @@ namespace lyx {
InsetSpace::InsetSpace(InsetSpaceParams const & params) InsetSpace::InsetSpace(InsetSpaceParams const & params)
: Inset(0), params_(params) : Inset(nullptr), params_(params)
{} {}

View File

@ -38,7 +38,7 @@ namespace lyx {
InsetSpecialChar::InsetSpecialChar(Kind k) InsetSpecialChar::InsetSpecialChar(Kind k)
: Inset(0), kind_(k) : Inset(nullptr), kind_(k)
{} {}

View File

@ -2189,9 +2189,7 @@ bool Tabular::needRotating() const
bool Tabular::isLastCell(idx_type cell) const bool Tabular::isLastCell(idx_type cell) const
{ {
if (cell + 1 < numberofcells) return cell + 1 >= numberofcells;
return false;
return true;
} }

View File

@ -50,7 +50,7 @@ int const ADD_TO_VSPACE_WIDTH = 5;
InsetVSpace::InsetVSpace(VSpace const & space) InsetVSpace::InsetVSpace(VSpace const & space)
: Inset(0), space_(space) : Inset(nullptr), space_(space)
{} {}

View File

@ -360,7 +360,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
if (!cur.selection()) { if (!cur.selection()) {
// no selection, non-empty search string: find it // no selection, non-empty search string: find it
if (!searchstr.empty()) { if (!searchstr.empty()) {
bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext); bool const found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
return make_pair(found, 0); return make_pair(found, 0);
} }
// empty search string // empty search string
@ -389,7 +389,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
// no selection or current selection is not search word: // no selection or current selection is not search word:
// just find the search word // just find the search word
if (!have_selection || !match) { if (!have_selection || !match) {
bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext); bool const found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
return make_pair(found, 0); return make_pair(found, 0);
} }
@ -3592,7 +3592,7 @@ static bool firstUppercase(Cursor const & cur)
static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case)
{ {
ParagraphList::iterator pit = buffer.paragraphs().begin(); ParagraphList::iterator pit = buffer.paragraphs().begin();
LASSERT(pit->size() >= 1, /**/); LASSERT(!pit->empty(), /**/);
pos_type right = pos_type(1); pos_type right = pos_type(1);
pit->changeCase(buffer.params(), pos_type(0), right, first_case); pit->changeCase(buffer.params(), pos_type(0), right, first_case);
right = pit->size(); right = pit->size();
@ -3605,7 +3605,7 @@ static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase other
static int findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, MatchStringAdv & matchAdv) static int findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, MatchStringAdv & matchAdv)
{ {
Cursor & cur = bv->cursor(); Cursor & cur = bv->cursor();
if (opt.repl_buf_name == docstring() if (opt.repl_buf_name.empty()
|| theBufferList().getBuffer(FileName(to_utf8(opt.repl_buf_name)), true) == 0 || theBufferList().getBuffer(FileName(to_utf8(opt.repl_buf_name)), true) == 0
|| theBufferList().getBuffer(FileName(to_utf8(opt.find_buf_name)), true) == 0) || theBufferList().getBuffer(FileName(to_utf8(opt.find_buf_name)), true) == 0)
return 0; return 0;

View File

@ -99,10 +99,10 @@ void InsetMathColor::write(WriteStream & os) const
// We have to ensure correct spacing when the front and/or back // We have to ensure correct spacing when the front and/or back
// atoms are not ordinary ones (bug 11827). // atoms are not ordinary ones (bug 11827).
docstring const frontclass = docstring const frontclass =
cell(0).size() ? class_to_string(cell(0).front()->mathClass()) !cell(0).empty() ? class_to_string(cell(0).front()->mathClass())
: from_ascii("mathord"); : from_ascii("mathord");
docstring const backclass = docstring const backclass =
cell(0).size() ? class_to_string(cell(0).back()->mathClass()) !cell(0).empty() ? class_to_string(cell(0).back()->mathClass())
: from_ascii("mathord"); : from_ascii("mathord");
bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_); bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_);
bool adjust_front = frontclass != "mathord" && adjchk; bool adjust_front = frontclass != "mathord" && adjchk;

View File

@ -58,9 +58,7 @@ InsetMath::mode_type InsetMathFont::currentMode() const
bool InsetMathFont::lockedMode() const bool InsetMathFont::lockedMode() const
{ {
if (key_->extra == "forcetext") return key_->extra == "forcetext";
return true;
return false;
} }

View File

@ -80,13 +80,13 @@ Inset * InsetMathFrac::clone() const
InsetMathFrac * InsetMathFrac::asFracInset() InsetMathFrac * InsetMathFrac::asFracInset()
{ {
return kind_ == ATOP ? 0 : this; return kind_ == ATOP ? nullptr : this;
} }
InsetMathFrac const * InsetMathFrac::asFracInset() const InsetMathFrac const * InsetMathFrac::asFracInset() const
{ {
return kind_ == ATOP ? 0 : this; return kind_ == ATOP ? nullptr : this;
} }

View File

@ -1579,7 +1579,7 @@ void InsetMathHull::mutate(HullType newtype)
numbered(0, false); numbered(0, false);
} else { } else {
setType(hullEquation); setType(hullEquation);
numbered(0, label_[0] ? true : false); numbered(0, label_[0] != nullptr);
mutate(newtype); mutate(newtype);
} }
break; break;

View File

@ -205,7 +205,7 @@ public:
: name_(name), displayMode_(DISPLAY_INIT), : name_(name), displayMode_(DISPLAY_INIT),
expanded_(buf), definition_(buf), attachedArgsNum_(0), expanded_(buf), definition_(buf), attachedArgsNum_(0),
optionals_(0), nextFoldMode_(true), macroBackup_(buf), optionals_(0), nextFoldMode_(true), macroBackup_(buf),
macro_(0), needsUpdate_(false), isUpdating_(false), macro_(nullptr), needsUpdate_(false), isUpdating_(false),
appetite_(9), nesting_(0), limits_(AUTO_LIMITS) appetite_(9), nesting_(0), limits_(AUTO_LIMITS)
{ {
} }
@ -649,7 +649,7 @@ void InsetMathMacro::updateMacro(MacroContext const & mc)
d->needsUpdate_ = true; d->needsUpdate_ = true;
} }
} else { } else {
d->macro_ = 0; d->macro_ = nullptr;
} }
} }
@ -684,7 +684,7 @@ void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
UpdateLocker locker(*this); UpdateLocker locker(*this);
// known macro? // known macro?
if (d->macro_ == 0) if (d->macro_ == nullptr)
return; return;
// remember nesting level of this macro // remember nesting level of this macro
@ -837,7 +837,7 @@ void InsetMathMacro::setDisplayMode(InsetMathMacro::DisplayMode mode, int appeti
InsetMathMacro::DisplayMode InsetMathMacro::computeDisplayMode() const InsetMathMacro::DisplayMode InsetMathMacro::computeDisplayMode() const
{ {
if (d->nextFoldMode_ == true && d->macro_ && !d->macro_->locked()) if (d->nextFoldMode_ && d->macro_ && !d->macro_->locked())
return DISPLAY_NORMAL; return DISPLAY_NORMAL;
else else
return DISPLAY_UNFOLDED; return DISPLAY_UNFOLDED;
@ -1172,10 +1172,10 @@ void InsetMathMacro::write(WriteStream & os) const
// contains macros with optionals. // contains macros with optionals.
bool braced = false; bool braced = false;
size_type last = cell(i).size() - 1; size_type last = cell(i).size() - 1;
if (cell(i).size() && cell(i)[last]->asUnknownInset()) { if (!cell(i).empty() && cell(i)[last]->asUnknownInset()) {
latexkeys const * l = in_word_set(cell(i)[last]->name()); latexkeys const * l = in_word_set(cell(i)[last]->name());
braced = (l && l->inset == "big"); braced = (l && l->inset == "big");
} else if (cell(i).size() && cell(i)[0]->asScriptInset()) { } else if (!cell(i).empty() && cell(i)[0]->asScriptInset()) {
braced = cell(i)[0]->asScriptInset()->nuc().empty(); braced = cell(i)[0]->asScriptInset()->nuc().empty();
} else { } else {
for (size_type j = 0; j < cell(i).size(); ++j) { for (size_type j = 0; j < cell(i).size(); ++j) {

View File

@ -2027,7 +2027,7 @@ CompletionList const *
InsetMathNest::createCompletionList(Cursor const & cur) const InsetMathNest::createCompletionList(Cursor const & cur) const
{ {
if (!cur.inMacroMode()) if (!cur.inMacroMode())
return 0; return nullptr;
return new MathCompletionList(cur); return new MathCompletionList(cur);
} }

View File

@ -388,7 +388,7 @@ void InsetMathScript::removeScript(bool up)
if (up == cell_1_is_up_) if (up == cell_1_is_up_)
cells_.pop_back(); cells_.pop_back();
} else if (nargs() == 3) { } else if (nargs() == 3) {
if (up == true) { if (up) {
swap(cells_[1], cells_[2]); swap(cells_[1], cells_[2]);
cell_1_is_up_ = false; cell_1_is_up_ = false;
} else { } else {

View File

@ -75,7 +75,7 @@ static char const * function_names[] = {
"det", "dim", "exp", "gcd", "hom", "inf", "ker", "det", "dim", "exp", "gcd", "hom", "inf", "ker",
"lg", "lim", "liminf", "limsup", "ln", "log", "lg", "lim", "liminf", "limsup", "ln", "log",
"max", "min", "sec", "sin", "sinh", "sup", "max", "min", "sec", "sin", "sinh", "sup",
"tan", "tanh", "Pr", 0 "tan", "tanh", "Pr", nullptr
}; };
static size_t const npos = lyx::docstring::npos; static size_t const npos = lyx::docstring::npos;

View File

@ -444,9 +444,9 @@ latexkeys const * in_word_set(docstring const & str)
{ {
MathWordList::iterator it = theMathWordList.find(str); MathWordList::iterator it = theMathWordList.find(str);
if (it == theMathWordList.end()) if (it == theMathWordList.end())
return 0; return nullptr;
if (it->second.inset == "macro") if (it->second.inset == "macro")
return 0; return nullptr;
return &(it->second); return &(it->second);
} }

View File

@ -1497,7 +1497,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
if (ar[i].size() == 1) if (ar[i].size() == 1)
script[i] = ar[i][0].nucleus()->asScriptInset(); script[i] = ar[i][0].nucleus()->asScriptInset();
} }
bool const hasscript[2] = {script[0] ? true : false, script[1] ? true : false}; bool const hasscript[2] = {script[0] != nullptr, script[1] != nullptr};
cell->push_back(MathAtom(new InsetMathSideset(buf, hasscript[0], hasscript[1]))); cell->push_back(MathAtom(new InsetMathSideset(buf, hasscript[0], hasscript[1])));
if (hasscript[0]) { if (hasscript[0]) {
if (script[0]->hasDown()) if (script[0]->hasDown())

View File

@ -39,7 +39,7 @@ namespace lyx {
MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc) MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc)
: type(t), mclass(mc), before(0), after(0), macro_nesting(mi.base.macro_nesting), : type(t), mclass(mc), before(0), after(0), macro_nesting(mi.base.macro_nesting),
marker(InsetMath::NO_MARKER), inset(0), compl_unique_to(0), ar(0), marker(InsetMath::NO_MARKER), inset(nullptr), compl_unique_to(0), ar(nullptr),
color(Color_red) color(Color_red)
{} {}

View File

@ -109,7 +109,7 @@ bool atSameLastLangSwitchDepth(OutputState const * state)
// commands. Instead, return always true when using babel with // commands. Instead, return always true when using babel with
// only a begin command. // only a begin command.
return state->lang_switch_depth_.size() == 0 return state->lang_switch_depth_.empty()
? true ? true
: abs(state->lang_switch_depth_.top()) == state->nest_level_; : abs(state->lang_switch_depth_.top()) == state->nest_level_;
} }
@ -119,7 +119,7 @@ bool isLocalSwitch(OutputState const * state)
{ {
// Return true if the language was opened by a local command switch. // Return true if the language was opened by a local command switch.
return state->lang_switch_depth_.size() return !state->lang_switch_depth_.empty()
&& state->lang_switch_depth_.top() < 0; && state->lang_switch_depth_.top() < 0;
} }
@ -128,7 +128,7 @@ bool langOpenedAtThisLevel(OutputState const * state)
{ {
// Return true if the language was opened at the current nesting level. // Return true if the language was opened at the current nesting level.
return state->lang_switch_depth_.size() return !state->lang_switch_depth_.empty()
&& abs(state->lang_switch_depth_.top()) == state->nest_level_; && abs(state->lang_switch_depth_.top()) == state->nest_level_;
} }
@ -241,7 +241,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
// polyglossia or begin/end commands, then the current // polyglossia or begin/end commands, then the current
// language is the document language. // language is the document language.
string const & cur_lang = using_begin_end string const & cur_lang = using_begin_end
&& state->lang_switch_depth_.size() && !state->lang_switch_depth_.empty()
? openLanguageName(state) ? openLanguageName(state)
: doc_lang; : doc_lang;
@ -442,7 +442,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
if ((par->layout() != nextpar->layout() if ((par->layout() != nextpar->layout()
|| par->params().depth() == nextpar->params().depth() || par->params().depth() == nextpar->params().depth()
|| par->params().leftIndent() == nextpar->params().leftIndent()) || par->params().leftIndent() == nextpar->params().leftIndent())
&& !runparams.for_search && cpar.size() > 0 && !runparams.for_search && !cpar.empty()
&& cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) { && cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) {
if (!buf.params().output_changes && !cpar.parEndChange().deleted()) if (!buf.params().output_changes && !cpar.parEndChange().deleted())
os << '\n' << '\n'; os << '\n' << '\n';
@ -761,7 +761,7 @@ void TeXOnePar(Buffer const & buf,
// Do not output empty commands if the whole paragraph has // Do not output empty commands if the whole paragraph has
// been deleted with ct and changes are not output. // been deleted with ct and changes are not output.
if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT
&& par.size() > 0 && par.isDeleted(0, par.size()) && !bparams.output_changes) && !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes)
return; return;
LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '" LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '"
@ -1312,7 +1312,7 @@ void TeXOnePar(Buffer const & buf,
&& nextpar && nextpar
&& style != nextpar->layout()))) && style != nextpar->layout())))
|| (atSameLastLangSwitchDepth(state) || (atSameLastLangSwitchDepth(state)
&& state->lang_switch_depth_.size() && !state->lang_switch_depth_.empty()
&& cur_lang != par_lang) && cur_lang != par_lang)
|| in_polyglossia_rtl_env) || in_polyglossia_rtl_env)
{ {
@ -1355,7 +1355,7 @@ void TeXOnePar(Buffer const & buf,
} }
bool const last_was_separator = bool const last_was_separator =
par.size() > 0 && par.isEnvSeparator(par.size() - 1); !par.empty() && par.isEnvSeparator(par.size() - 1);
// Signify added/deleted par break in output if show changes in output // Signify added/deleted par break in output if show changes in output
if (nextpar && !os.afterParbreak() && !last_was_separator if (nextpar && !os.afterParbreak() && !last_was_separator
@ -1666,7 +1666,7 @@ void latexParagraphs(Buffer const & buf,
if ((par->layout() != nextpar->layout() if ((par->layout() != nextpar->layout()
|| par->params().depth() == nextpar->params().depth() || par->params().depth() == nextpar->params().depth()
|| par->params().leftIndent() == nextpar->params().leftIndent()) || par->params().leftIndent() == nextpar->params().leftIndent())
&& !runparams.for_search && cpar.size() > 0 && !runparams.for_search && !cpar.empty()
&& cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) { && cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
if (!cpar.parEndChange().deleted()) if (!cpar.parEndChange().deleted())
os << '\n' << '\n'; os << '\n' << '\n';

View File

@ -89,7 +89,7 @@ struct FileName::Private
: fi(toqstr(handleTildeName(abs_filename))) : fi(toqstr(handleTildeName(abs_filename)))
{ {
name = fromqstr(fi.absoluteFilePath()); name = fromqstr(fi.absoluteFilePath());
fi.setCaching(fi.exists() ? true : false); fi.setCaching(fi.exists());
} }
/// ///
inline void refresh() inline void refresh()

View File

@ -366,10 +366,7 @@ bool inBuildDir(FileName const & abs_binary,
bool doesFileExist(FileName & result, string const & search_dir, string const & name) bool doesFileExist(FileName & result, string const & search_dir, string const & name)
{ {
result = fileSearch(search_dir, name); result = fileSearch(search_dir, name);
if (!result.empty()) { return !result.empty();
return true;
}
return false;
} }
@ -382,7 +379,7 @@ bool lyxBinaryPath(FileName & lyx_binary, string const & search_dir, string cons
} else if (doesFileExist(lyx_binary, search_dir, "lyx" + string(PROGRAM_SUFFIX) + ext)) { } else if (doesFileExist(lyx_binary, search_dir, "lyx" + string(PROGRAM_SUFFIX) + ext)) {
} else if (doesFileExist(lyx_binary, search_dir, "LyX" + string(PROGRAM_SUFFIX) + ext)){ } else if (doesFileExist(lyx_binary, search_dir, "LyX" + string(PROGRAM_SUFFIX) + ext)){
} }
return !lyx_binary.empty() ? true : false; return !lyx_binary.empty();
} }

View File

@ -625,7 +625,7 @@ protected:
} }
if (ok) { if (ok) {
err = ios_base::goodbit; err = ios_base::goodbit;
v = truename == s ? true : false; v = (truename == s);
} else } else
err = ios_base::failbit; err = ios_base::failbit;
if (iit == eit) if (iit == eit)

View File

@ -57,7 +57,7 @@ bool test_Layout(string const & input, string const & output)
return false; return false;
} }
LayoutFile const & f = l[i]; LayoutFile const & f = l[i];
ostream * os = NULL; ostream * os = nullptr;
if (output == "-") if (output == "-")
os = &cout; os = &cout;
else if (!output.empty()) else if (!output.empty())

View File

@ -154,7 +154,7 @@ iparserdocstream & iparserdocstream::get(char_type &c)
Parser::Parser(idocstream & is, std::string const & fixedenc) Parser::Parser(idocstream & is, std::string const & fixedenc)
: lineno_(0), pos_(0), iss_(0), is_(is), : lineno_(0), pos_(0), iss_(nullptr), is_(is),
encoding_iconv_(fixedenc.empty() ? "UTF-8" : fixedenc), encoding_iconv_(fixedenc.empty() ? "UTF-8" : fixedenc),
theCatcodesType_(NORMAL_CATCODES), curr_cat_(UNDECIDED_CATCODES), theCatcodesType_(NORMAL_CATCODES), curr_cat_(UNDECIDED_CATCODES),
fixed_enc_(!fixedenc.empty()) fixed_enc_(!fixedenc.empty())