diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 40db4aa6d3..6d25d51908 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -664,7 +664,6 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList_ptr clones) const buffer_clone->setChild(dit, child_clone); } 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 { - if (!insetLabel(label, true)) - return false; - - return true; + return insetLabel(label, true) != nullptr; } diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index b5ae2d4cad..58a02c8683 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1373,9 +1373,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const if (!lineno_opts.empty()) os << "\\lineno_options " << lineno_opts << '\n'; - if (isbackgroundcolor == true) + if (isbackgroundcolor) os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; - if (isfontcolor == true) + if (isfontcolor) os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n'; if (notefontcolor != lyx::rgbFromHexName("#cccccc")) 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 - if (isbackgroundcolor == true) { + if (isbackgroundcolor) { // only require color here, the background color will be defined // in LaTeXFeatures.cpp to avoid interferences with the LaTeX // package pdfpages @@ -1988,7 +1988,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, } // only output when the font color is not default - if (isfontcolor == true) { + if (isfontcolor) { // only require color here, the font color will be defined // in LaTeXFeatures.cpp to avoid interferences with the LaTeX // package pdfpages diff --git a/src/DepTable.cpp b/src/DepTable.cpp index 47daf39113..853edf22c8 100644 --- a/src/DepTable.cpp +++ b/src/DepTable.cpp @@ -228,7 +228,7 @@ bool DepTable::read(FileName const & f) deplist[FileName(nome)] = di; } - return deplist.size(); + return !deplist.empty(); } diff --git a/src/ErrorList.cpp b/src/ErrorList.cpp index 1613ce7e61..7022c7bcf5 100644 --- a/src/ErrorList.cpp +++ b/src/ErrorList.cpp @@ -32,7 +32,7 @@ ErrorItem::ErrorItem(docstring const & error_, docstring const & description_, ErrorItem::ErrorItem() - : start(TexRow::text_none), end(TexRow::text_none), buffer(0) + : start(TexRow::text_none), end(TexRow::text_none), buffer(nullptr) {} diff --git a/src/Font.cpp b/src/Font.cpp index 327bc1821b..fda0854fe1 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -864,7 +864,7 @@ ostream & operator<<(ostream & os, FontInfo const & f) ostream & operator<<(ostream & os, Font const & font) { return os << font.bits_ - << " lang: " << (font.lang_ ? font.lang_->lang() : nullptr); + << " lang: " << (font.lang_ ? font.lang_->lang() : ""); } diff --git a/src/HunspellChecker.cpp b/src/HunspellChecker.cpp index dcdc1bbbd7..015973e1f4 100644 --- a/src/HunspellChecker.cpp +++ b/src/HunspellChecker.cpp @@ -234,11 +234,11 @@ 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)) { - spellers_[lang->lang()] = 0; - return 0; + spellers_[lang->lang()] = nullptr; + return nullptr; } FileName const affix(path + ".aff"); diff --git a/src/Language.cpp b/src/Language.cpp index 4f625b55b9..84e03b1e9e 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -37,10 +37,10 @@ using namespace lyx::support; namespace lyx { Languages languages; -Language const * ignore_language = 0; -Language const * default_language = 0; -Language const * latex_language = 0; -Language const * reset_language = 0; +Language const * ignore_language = nullptr; +Language const * default_language = nullptr; +Language const * latex_language = nullptr; +Language const * reset_language = nullptr; bool Language::isPolyglossiaExclusive() const @@ -344,12 +344,12 @@ void Languages::read(FileName const & filename) break; if (l.lang() == "latex") { // Check if latex language was not already defined. - LASSERT(latex_language == 0, continue); + LASSERT(latex_language == nullptr, continue); static const Language latex_lang = l; latex_language = &latex_lang; } else if (l.lang() == "ignore") { // Check if ignore language was not already defined. - LASSERT(ignore_language == 0, continue); + LASSERT(ignore_language == nullptr, continue); static const Language ignore_lang = l; ignore_language = &ignore_lang; } else @@ -436,7 +436,7 @@ Language const * Languages::getFromCode(string const & code) const if (match(code, l.second) == ApproximateMatch) return &l.second; } - return 0; + return nullptr; } @@ -460,7 +460,7 @@ Language const * Languages::getFromCode(string const & code, return getFromCode(code); LYXERR0("Unknown language `" << code << "'"); - return 0; + return nullptr; } diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 806d5e8143..7e36a1ce9c 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -348,9 +348,7 @@ string LyXVC::toggleReadOnly() bool LyXVC::inUse() const { - if (vcs) - return true; - return false; + return vcs != nullptr; } diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 242f644ce6..bdda5d012b 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -4810,7 +4810,7 @@ void Paragraph::spellCheck() const // start the spell checker on the unit of meaning docstring word = asString(first, last, AS_STR_INSETS + AS_STR_SKIPDELETE); WordLangTuple wl = WordLangTuple(word, lang); - SpellChecker::Result result = word.size() ? + SpellChecker::Result result = !word.empty() ? speller->check(wl) : SpellChecker::WORD_OK; d->markMisspelledWords(first, last, result, word, skips); first = ++last; diff --git a/src/PersonalWordList.cpp b/src/PersonalWordList.cpp index 665eb331b5..4d3292e3f5 100644 --- a/src/PersonalWordList.cpp +++ b/src/PersonalWordList.cpp @@ -54,7 +54,7 @@ void PersonalWordList::load() LYXERR(Debug::FILES, "load personal dictionary from: " << fn); ifstream ifs(fn.toFilesystemEncoding().c_str()); - dirty(words_.size() > 0); + dirty(!words_.empty()); words_.clear(); string line; getline(ifs, line); diff --git a/src/Session.cpp b/src/Session.cpp index 3bb9c03a33..8fc8fa23d8 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -494,10 +494,7 @@ void AuthFilesSection::write(ostream & os) const bool AuthFilesSection::find(string const & name) const { - if (auth_files_.find(name) != auth_files_.end()) - return true; - - return false; + return auth_files_.find(name) != auth_files_.end(); } @@ -547,10 +544,7 @@ bool ShellEscapeSection::find(string const & name) const bool ShellEscapeSection::findAuth(string const & name) const { - if (shellescape_files_.find(name + ",1") != shellescape_files_.end()) - return true; - - return false; + return shellescape_files_.find(name + ",1") != shellescape_files_.end(); } diff --git a/src/Text.cpp b/src/Text.cpp index 0e058641d6..e4eb4abf10 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1778,7 +1778,7 @@ bool Text::backspace(Cursor & cur) Cursor prev_cur = cur; --prev_cur.pit(); - if (cur.paragraph().size() > 0 + if (!cur.paragraph().empty() && !prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) { cur.recordUndo(prev_cur.pit(), prev_cur.pit()); prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED)); diff --git a/src/Text3.cpp b/src/Text3.cpp index 6631d49012..af904041c2 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1276,7 +1276,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Paragraph const & nextpar = lastpar ? par : pars_[pit + 1]; pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit; if (prev < pit && cur.pos() == par.beginOfBody() - && !par.size() && !par.isEnvSeparator(cur.pos()) + && par.empty() && !par.isEnvSeparator(cur.pos()) && !par.layout().keepempty && !par.layout().isCommand() && pars_[prev].layout() != par.layout() diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 8e9a157a7a..07c2b27990 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1486,7 +1486,7 @@ InsetList::Element * TextMetrics::checkInsetHit(pit_type pit, int x, int y) } LYXERR(Debug::DEBUG, "No inset hit. "); - return 0; + return nullptr; } diff --git a/src/Trans.cpp b/src/Trans.cpp index 679866da84..2f0f317355 100644 --- a/src/Trans.cpp +++ b/src/Trans.cpp @@ -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 end = deadkey_info_.exception_list.end(); for (; cit != end; ++cit) { - if (cit->combined == true && cit->accent == d.accent) { + if (cit->combined && cit->accent == d.accent) { deadkey2_ = c; deadkey2_info_ = d; 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 // or a accent command was typed in the minibuffer KmodInfo i; - if (active_->isAccentDefined(accent, i) == true) { + if (active_->isAccentDefined(accent, i)) { docstring const res = trans_fsm_ .currentState->deadkey(c, i); insert(res, t, cur); diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 3ea4624399..309d705372 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -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 // about to be registered master_ = m; - locked_mode_ = 0; + locked_mode_ = false; scanMaster(); } diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h index 718718f979..e2796d97d9 100644 --- a/src/frontends/Painter.h +++ b/src/frontends/Painter.h @@ -154,7 +154,7 @@ public: 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 virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0; diff --git a/src/frontends/qt/CategorizedCombo.cpp b/src/frontends/qt/CategorizedCombo.cpp index d86bd382f8..4aebcf6a91 100644 --- a/src/frontends/qt/CategorizedCombo.cpp +++ b/src/frontends/qt/CategorizedCombo.cpp @@ -71,7 +71,7 @@ private: class CCFilterModel : public QSortFilterProxyModel { public: /// - CCFilterModel(QObject * parent = 0) + CCFilterModel(QObject * parent = nullptr) : QSortFilterProxyModel(parent) {} }; diff --git a/src/frontends/qt/FancyLineEdit.cpp b/src/frontends/qt/FancyLineEdit.cpp index c7035ac7c9..dae7444899 100644 --- a/src/frontends/qt/FancyLineEdit.cpp +++ b/src/frontends/qt/FancyLineEdit.cpp @@ -60,7 +60,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) : m_lineEdit(parent) { for (int i = 0; i < 2; ++i) { - m_menu[i] = 0; + m_menu[i] = nullptr; m_menuTabFocusTrigger[i] = false; m_iconbutton[i] = new IconButton(parent); m_iconbutton[i]->installEventFilter(this); diff --git a/src/frontends/qt/FindAndReplace.cpp b/src/frontends/qt/FindAndReplace.cpp index 271ce9be90..af2bbbbea3 100644 --- a/src/frontends/qt/FindAndReplace.cpp +++ b/src/frontends/qt/FindAndReplace.cpp @@ -599,7 +599,7 @@ FindAndReplace::FindAndReplace(GuiView & parent, FindAndReplace::~FindAndReplace() { - setFocusProxy(0); + setFocusProxy(nullptr); delete widget_; } @@ -620,7 +620,7 @@ void FindAndReplaceWidget::updateGUI() old_buffer_ = &bv->buffer(); } } else - old_buffer_ = 0; + old_buffer_ = nullptr; bool const replace_enabled = bv && !bv->buffer().isReadonly(); replace_work_area_->setEnabled(replace_enabled); diff --git a/src/frontends/qt/FloatPlacement.cpp b/src/frontends/qt/FloatPlacement.cpp index dbbaa5961b..d11458716f 100644 --- a/src/frontends/qt/FloatPlacement.cpp +++ b/src/frontends/qt/FloatPlacement.cpp @@ -35,7 +35,7 @@ namespace frontend { FloatPlacement::FloatPlacement(bool show_options, QWidget * parent) : InsetParamsWidget(parent), standardfloat_(true), - allows_wide_(true), allows_sideways_(true), float_list_(0) + allows_wide_(true), allows_sideways_(true), float_list_(nullptr) { setupUi(this); diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index bf91789178..1763abdfc0 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -895,8 +895,8 @@ public: struct GuiApplication::Private { - Private(): language_model_(0), meta_fake_bit(NoModifier), - global_menubar_(0) + Private(): language_model_(nullptr), meta_fake_bit(NoModifier), + global_menubar_(nullptr) { #if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) @@ -993,7 +993,7 @@ GuiApplication::~GuiApplication() GuiApplication::GuiApplication(int & argc, char ** argv) - : QApplication(argc, argv), current_view_(0), + : QApplication(argc, argv), current_view_(nullptr), d(new GuiApplication::Private) { QString app_name = "LyX"; @@ -1123,8 +1123,8 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const { FuncStatus status; - BufferView * bv = 0; - BufferView * doc_bv = 0; + BufferView * bv = nullptr; + BufferView * doc_bv = nullptr; if (cmd.action() == LFUN_NOACTION) { status.message(from_utf8(N_("Nothing to do"))); @@ -1289,7 +1289,7 @@ bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const break; case LFUN_WINDOW_CLOSE: - enable = d->views_.size() > 0; + enable = !d->views_.empty(); break; case LFUN_BUFFER_NEW: diff --git a/src/frontends/qt/GuiErrorList.cpp b/src/frontends/qt/GuiErrorList.cpp index 0b625ccd51..9fbdedafaf 100644 --- a/src/frontends/qt/GuiErrorList.cpp +++ b/src/frontends/qt/GuiErrorList.cpp @@ -58,7 +58,7 @@ namespace lyx { namespace frontend { 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); diff --git a/src/frontends/qt/GuiImage.cpp b/src/frontends/qt/GuiImage.cpp index c73fe7cede..0c3df0b65d 100644 --- a/src/frontends/qt/GuiImage.cpp +++ b/src/frontends/qt/GuiImage.cpp @@ -173,7 +173,7 @@ bool GuiImage::clip(Params const & params) bool GuiImage::rotate(Params const & params) { - if (!params.angle) + if (params.angle == 0) return false; QImage const & image = is_transformed_ ? transformed_ : original_; diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index a727700005..8583d0cd26 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -187,7 +187,6 @@ void GuiRef::selectionChanged() return; QTreeWidgetItem * sel = selections.first(); refHighlighted(sel); - return; } diff --git a/src/frontends/qt/GuiSendto.cpp b/src/frontends/qt/GuiSendto.cpp index a42bbb472c..b14db45304 100644 --- a/src/frontends/qt/GuiSendto.cpp +++ b/src/frontends/qt/GuiSendto.cpp @@ -38,7 +38,7 @@ namespace frontend { 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); @@ -77,7 +77,7 @@ void GuiSendTo::updateContents() Format const * current_format = nullptr; int const line = formatLW->currentRow(); if (line >= 0 && static_cast(line) < all_formats.size() - && formatLW->selectedItems().size() > 0) + && !formatLW->selectedItems().empty()) current_format = all_formats[line]; // Reset the list widget formatLW->clear(); @@ -115,14 +115,14 @@ bool GuiSendTo::isValid() if (line < 0 || (line > int(formatLW->count()))) return false; - return (formatLW->selectedItems().size() > 0 + return (!formatLW->selectedItems().empty() && formatLW->count() != 0); } bool GuiSendTo::initialiseParams(string const &) { - format_ = 0; + format_ = nullptr; paramsToDialog(format_, command_); return true; } diff --git a/src/frontends/qt/GuiSymbols.cpp b/src/frontends/qt/GuiSymbols.cpp index a4fd4af650..4a6b0d6178 100644 --- a/src/frontends/qt/GuiSymbols.cpp +++ b/src/frontends/qt/GuiSymbols.cpp @@ -207,7 +207,7 @@ class GuiSymbols::Model : public QAbstractListModel { public: Model(GuiSymbols * parent) - : QAbstractListModel(parent), encoding_(0) + : QAbstractListModel(parent), encoding_(nullptr) {} QModelIndex index(int row, int column, QModelIndex const &) const override diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp index 65f81c9b21..5c8c603daf 100644 --- a/src/frontends/qt/GuiToolbar.cpp +++ b/src/frontends/qt/GuiToolbar.cpp @@ -64,7 +64,7 @@ namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) : 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) { setIconSize(owner.iconSize()); @@ -297,7 +297,7 @@ class DynamicMenuButton::Private Private(Private const &); void operator=(Private const &); public: - Private() : inset_(0) {} + Private() : inset_(nullptr) {} /// DocumentClassConstPtr text_class_; /// diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index cb351d1177..00f3b96ea4 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -1187,7 +1187,7 @@ void GuiView::dropEvent(QDropEvent * event) found_formats.push_back(*it); FuncRequest cmd; - if (found_formats.size() >= 1) { + if (!found_formats.empty()) { if (found_formats.size() > 1) { //FIXME: show a dialog to choose the correct importable format LYXERR(Debug::FILES, diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp index 7c21088643..0104c8dd83 100644 --- a/src/frontends/qt/GuiWorkArea.cpp +++ b/src/frontends/qt/GuiWorkArea.cpp @@ -1061,7 +1061,6 @@ void GuiWorkArea::generateSyntheticMouseEvent() cur.boundary(bound); d->buffer_view_->buffer().changed(false); - return; } diff --git a/src/frontends/qt/LayoutBox.cpp b/src/frontends/qt/LayoutBox.cpp index 95814c942f..719a2d324d 100644 --- a/src/frontends/qt/LayoutBox.cpp +++ b/src/frontends/qt/LayoutBox.cpp @@ -85,7 +85,7 @@ private: class GuiLayoutFilterModel : public QSortFilterProxyModel { public: /// - GuiLayoutFilterModel(QObject * parent = 0) + GuiLayoutFilterModel(QObject * parent = nullptr) : QSortFilterProxyModel(parent) {} @@ -111,7 +111,7 @@ class LayoutBox::Private void operator=(Private const &); public: Private(LayoutBox * parent, GuiView & gv) : p(parent), owner_(gv), - inset_(0), + inset_(nullptr), // set the layout model with two columns // 1st: translated layout names // 2nd: raw layout names @@ -567,7 +567,7 @@ void LayoutBox::updateContents(bool reset) setEnabled(false); setMinimumWidth(sizeHint().width()); d->text_class_.reset(); - d->inset_ = 0; + d->inset_ = nullptr; return; } // we'll only update the layout list if the text class has changed diff --git a/src/frontends/qt/PanelStack.cpp b/src/frontends/qt/PanelStack.cpp index 4b6b875c8b..ef9c599a34 100644 --- a/src/frontends/qt/PanelStack.cpp +++ b/src/frontends/qt/PanelStack.cpp @@ -97,7 +97,7 @@ PanelStack::PanelStack(QWidget * parent) void PanelStack::addCategory(QString const & name, QString const & parent) { - QTreeWidgetItem * item = 0; + QTreeWidgetItem * item = nullptr; LYXERR(Debug::GUI, "addCategory n= " << name << " parent= "); diff --git a/src/frontends/qt/Toolbars.cpp b/src/frontends/qt/Toolbars.cpp index d7a28b8025..7d29344732 100644 --- a/src/frontends/qt/Toolbars.cpp +++ b/src/frontends/qt/Toolbars.cpp @@ -418,7 +418,7 @@ ToolbarInfo const * Toolbars::info(std::string const & name) const for (Infos::const_iterator it = toolbar_info_.begin(); it != end; ++it) if (it->name == name) return &(*it); - return 0; + return nullptr; } diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index 4e8afcfa7e..82f6c48e84 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -393,7 +393,7 @@ bool InsetIPADeco::insetAllowed(InsetCode code) const InsetIPAChar::InsetIPAChar(Kind k) - : Inset(0), kind_(k) + : Inset(nullptr), kind_(k) {} diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 4c6f17e1d1..0e07af13f7 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -36,7 +36,7 @@ using namespace std; namespace lyx { -InsetNewline::InsetNewline() : Inset(0) +InsetNewline::InsetNewline() : Inset(nullptr) {} diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index 6e9f34211f..6f89eac03b 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -37,12 +37,12 @@ using namespace std; namespace lyx { - InsetNewpage::InsetNewpage() : Inset(0) + InsetNewpage::InsetNewpage() : Inset(nullptr) {} InsetNewpage::InsetNewpage(InsetNewpageParams const & params) - : Inset(0), params_(params) + : Inset(nullptr), params_(params) {} diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index c762e33d67..5e3c637a60 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -171,7 +171,7 @@ docstring InsetPrintNomencl::screenLabel() const struct NomenclEntry { - NomenclEntry() : par(0) {} + NomenclEntry() : par(nullptr) {} NomenclEntry(docstring s, docstring d, Paragraph const * p) : symbol(s), desc(d), par(p) {} @@ -381,7 +381,7 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams) int w = 0; docstring symb; - InsetNomencl const * nomencl = 0; + InsetNomencl const * nomencl = nullptr; ParagraphList::const_iterator it = buffer.paragraphs().begin(); ParagraphList::const_iterator end = buffer.paragraphs().end(); diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index b90f1c27dd..c93de5a063 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -1057,10 +1057,10 @@ void InsetQuotes::validate(LaTeXFeatures & features) const switch (type) { case 0x0027: { if (features.runparams().isFullUnicode() && fontspec_) - features.require("textquotesinglep"); - else - features.require("textcomp"); - break; + features.require("textquotesinglep"); + else + features.require("textcomp"); + break; } case 0x0022: { if (features.runparams().isFullUnicode() && fontspec_) diff --git a/src/insets/InsetSeparator.cpp b/src/insets/InsetSeparator.cpp index efe6a483b0..16f7cdcbdf 100644 --- a/src/insets/InsetSeparator.cpp +++ b/src/insets/InsetSeparator.cpp @@ -36,12 +36,12 @@ using namespace lyx::frontend; namespace lyx { -InsetSeparator::InsetSeparator() : Inset(0) +InsetSeparator::InsetSeparator() : Inset(nullptr) {} InsetSeparator::InsetSeparator(InsetSeparatorParams const & params) - : Inset(0), params_(params) + : Inset(nullptr), params_(params) {} diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 7656a14e10..d4cb7361b4 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -45,7 +45,7 @@ namespace lyx { InsetSpace::InsetSpace(InsetSpaceParams const & params) - : Inset(0), params_(params) + : Inset(nullptr), params_(params) {} diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp index 56925c4f32..3ecdaf12e9 100644 --- a/src/insets/InsetSpecialChar.cpp +++ b/src/insets/InsetSpecialChar.cpp @@ -38,7 +38,7 @@ namespace lyx { InsetSpecialChar::InsetSpecialChar(Kind k) - : Inset(0), kind_(k) + : Inset(nullptr), kind_(k) {} diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8458ce4728..d24d174cbc 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2189,9 +2189,7 @@ bool Tabular::needRotating() const bool Tabular::isLastCell(idx_type cell) const { - if (cell + 1 < numberofcells) - return false; - return true; + return cell + 1 >= numberofcells; } diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index a6092cb8a3..03a272e650 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -50,7 +50,7 @@ int const ADD_TO_VSPACE_WIDTH = 5; InsetVSpace::InsetVSpace(VSpace const & space) - : Inset(0), space_(space) + : Inset(nullptr), space_(space) {} diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 5f9e2d3093..f36e02bf77 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -360,7 +360,7 @@ pair replaceOne(BufferView * bv, docstring searchstr, if (!cur.selection()) { // no selection, non-empty search string: find it 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); } // empty search string @@ -389,7 +389,7 @@ pair replaceOne(BufferView * bv, docstring searchstr, // no selection or current selection is not search word: // just find the search word 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); } @@ -3592,7 +3592,7 @@ static bool firstUppercase(Cursor const & cur) static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) { ParagraphList::iterator pit = buffer.paragraphs().begin(); - LASSERT(pit->size() >= 1, /**/); + LASSERT(!pit->empty(), /**/); pos_type right = pos_type(1); pit->changeCase(buffer.params(), pos_type(0), right, first_case); 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) { 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.find_buf_name)), true) == 0) return 0; diff --git a/src/mathed/InsetMathColor.cpp b/src/mathed/InsetMathColor.cpp index 94a6c42e64..31ba778faf 100644 --- a/src/mathed/InsetMathColor.cpp +++ b/src/mathed/InsetMathColor.cpp @@ -99,10 +99,10 @@ void InsetMathColor::write(WriteStream & os) const // We have to ensure correct spacing when the front and/or back // atoms are not ordinary ones (bug 11827). 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"); 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"); bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_); bool adjust_front = frontclass != "mathord" && adjchk; diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp index f199ee5bcf..1de00464a7 100644 --- a/src/mathed/InsetMathFont.cpp +++ b/src/mathed/InsetMathFont.cpp @@ -58,9 +58,7 @@ InsetMath::mode_type InsetMathFont::currentMode() const bool InsetMathFont::lockedMode() const { - if (key_->extra == "forcetext") - return true; - return false; + return key_->extra == "forcetext"; } diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index 90d507cfbe..03125e99ca 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -80,13 +80,13 @@ Inset * InsetMathFrac::clone() const InsetMathFrac * InsetMathFrac::asFracInset() { - return kind_ == ATOP ? 0 : this; + return kind_ == ATOP ? nullptr : this; } InsetMathFrac const * InsetMathFrac::asFracInset() const { - return kind_ == ATOP ? 0 : this; + return kind_ == ATOP ? nullptr : this; } diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index e7326b64e5..156cbec2fd 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1579,7 +1579,7 @@ void InsetMathHull::mutate(HullType newtype) numbered(0, false); } else { setType(hullEquation); - numbered(0, label_[0] ? true : false); + numbered(0, label_[0] != nullptr); mutate(newtype); } break; diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp index 15b5d29d9c..862ee8a4d7 100644 --- a/src/mathed/InsetMathMacro.cpp +++ b/src/mathed/InsetMathMacro.cpp @@ -205,7 +205,7 @@ public: : name_(name), displayMode_(DISPLAY_INIT), expanded_(buf), definition_(buf), attachedArgsNum_(0), 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) { } @@ -649,7 +649,7 @@ void InsetMathMacro::updateMacro(MacroContext const & mc) d->needsUpdate_ = true; } } else { - d->macro_ = 0; + d->macro_ = nullptr; } } @@ -684,7 +684,7 @@ void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc, UpdateLocker locker(*this); // known macro? - if (d->macro_ == 0) + if (d->macro_ == nullptr) return; // remember nesting level of this macro @@ -837,7 +837,7 @@ void InsetMathMacro::setDisplayMode(InsetMathMacro::DisplayMode mode, int appeti 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; else return DISPLAY_UNFOLDED; @@ -1172,10 +1172,10 @@ void InsetMathMacro::write(WriteStream & os) const // contains macros with optionals. bool braced = false; 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()); 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(); } else { for (size_type j = 0; j < cell(i).size(); ++j) { diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index be6fecc526..9d88b1337b 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -2027,7 +2027,7 @@ CompletionList const * InsetMathNest::createCompletionList(Cursor const & cur) const { if (!cur.inMacroMode()) - return 0; + return nullptr; return new MathCompletionList(cur); } diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index cbef2fafb1..e40db4f164 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -388,7 +388,7 @@ void InsetMathScript::removeScript(bool up) if (up == cell_1_is_up_) cells_.pop_back(); } else if (nargs() == 3) { - if (up == true) { + if (up) { swap(cells_[1], cells_[2]); cell_1_is_up_ = false; } else { diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index 18340e11c8..092de56ee5 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -75,7 +75,7 @@ static char const * function_names[] = { "det", "dim", "exp", "gcd", "hom", "inf", "ker", "lg", "lim", "liminf", "limsup", "ln", "log", "max", "min", "sec", "sin", "sinh", "sup", - "tan", "tanh", "Pr", 0 + "tan", "tanh", "Pr", nullptr }; static size_t const npos = lyx::docstring::npos; diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index afee57ef1c..54fe012857 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -444,9 +444,9 @@ latexkeys const * in_word_set(docstring const & str) { MathWordList::iterator it = theMathWordList.find(str); if (it == theMathWordList.end()) - return 0; + return nullptr; if (it->second.inset == "macro") - return 0; + return nullptr; return &(it->second); } diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index c3bea0d540..32d7ef6424 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -1497,7 +1497,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, if (ar[i].size() == 1) 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]))); if (hasscript[0]) { if (script[0]->hasDown()) diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp index d78815acf3..be61c8a39c 100644 --- a/src/mathed/MathRow.cpp +++ b/src/mathed/MathRow.cpp @@ -39,7 +39,7 @@ namespace lyx { MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc) : 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) {} diff --git a/src/output_latex.cpp b/src/output_latex.cpp index fefa62fa10..b2d51488cd 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -109,7 +109,7 @@ bool atSameLastLangSwitchDepth(OutputState const * state) // commands. Instead, return always true when using babel with // only a begin command. - return state->lang_switch_depth_.size() == 0 + return state->lang_switch_depth_.empty() ? true : 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 state->lang_switch_depth_.size() + return !state->lang_switch_depth_.empty() && 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 state->lang_switch_depth_.size() + return !state->lang_switch_depth_.empty() && 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 // language is the document language. string const & cur_lang = using_begin_end - && state->lang_switch_depth_.size() + && !state->lang_switch_depth_.empty() ? openLanguageName(state) : doc_lang; @@ -442,7 +442,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text, if ((par->layout() != nextpar->layout() || par->params().depth() == nextpar->params().depth() || 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) { if (!buf.params().output_changes && !cpar.parEndChange().deleted()) os << '\n' << '\n'; @@ -761,7 +761,7 @@ void TeXOnePar(Buffer const & buf, // Do not output empty commands if the whole paragraph has // been deleted with ct and changes are not output. 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; LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '" @@ -1312,7 +1312,7 @@ void TeXOnePar(Buffer const & buf, && nextpar && style != nextpar->layout()))) || (atSameLastLangSwitchDepth(state) - && state->lang_switch_depth_.size() + && !state->lang_switch_depth_.empty() && cur_lang != par_lang) || in_polyglossia_rtl_env) { @@ -1355,7 +1355,7 @@ void TeXOnePar(Buffer const & buf, } 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 if (nextpar && !os.afterParbreak() && !last_was_separator @@ -1666,7 +1666,7 @@ void latexParagraphs(Buffer const & buf, if ((par->layout() != nextpar->layout() || par->params().depth() == nextpar->params().depth() || 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) { if (!cpar.parEndChange().deleted()) os << '\n' << '\n'; diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index a6b849407a..9714965bdf 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -89,7 +89,7 @@ struct FileName::Private : fi(toqstr(handleTildeName(abs_filename))) { name = fromqstr(fi.absoluteFilePath()); - fi.setCaching(fi.exists() ? true : false); + fi.setCaching(fi.exists()); } /// inline void refresh() diff --git a/src/support/Package.cpp b/src/support/Package.cpp index f931ddf705..a349a5e755 100644 --- a/src/support/Package.cpp +++ b/src/support/Package.cpp @@ -366,10 +366,7 @@ bool inBuildDir(FileName const & abs_binary, bool doesFileExist(FileName & result, string const & search_dir, string const & name) { result = fileSearch(search_dir, name); - if (!result.empty()) { - return true; - } - return false; + return !result.empty(); } @@ -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)){ } - return !lyx_binary.empty() ? true : false; + return !lyx_binary.empty(); } diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index e73c3f09c0..cbee18a20a 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -625,7 +625,7 @@ protected: } if (ok) { err = ios_base::goodbit; - v = truename == s ? true : false; + v = (truename == s); } else err = ios_base::failbit; if (iit == eit) diff --git a/src/tests/check_layout.cpp b/src/tests/check_layout.cpp index 7100c712d8..2fa0fe11e9 100644 --- a/src/tests/check_layout.cpp +++ b/src/tests/check_layout.cpp @@ -57,7 +57,7 @@ bool test_Layout(string const & input, string const & output) return false; } LayoutFile const & f = l[i]; - ostream * os = NULL; + ostream * os = nullptr; if (output == "-") os = &cout; else if (!output.empty()) diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index cc8dd5aa58..e44aa3e69a 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -154,7 +154,7 @@ iparserdocstream & iparserdocstream::get(char_type &c) 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), theCatcodesType_(NORMAL_CATCODES), curr_cat_(UNDECIDED_CATCODES), fixed_enc_(!fixedenc.empty())