Change Assert to BOOST_ASSERT.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7722 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-09-09 17:25:35 +00:00
parent f9c1cafbe6
commit fcdb71906b
104 changed files with 542 additions and 640 deletions

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* configure.ac (AH_BOTTOM): add blurb for BOOST_ASSERT
2003-09-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org> 2003-09-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* README.MacOSX: new file. * README.MacOSX: new file.

View File

@ -190,7 +190,7 @@ for frontend in $FRONTENDS ; do
dnl ;; dnl ;;
gtk) gtk)
XFORMS_DO_IT_ALL XFORMS_DO_IT_ALL
PKG_CHECK_MODULES(GTK_FRONTEND, gtkmm-2.0 libglademm-2.0) PKG_CHECK_MODULES(GTK_FRONTEND, gtkmm-2.0 libglademm-2.0)
FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-gtk\$(EXEEXT)" FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-gtk\$(EXEEXT)"
FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS xforms gtk" FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS xforms gtk"
RPM_FRONTEND="gtk" RPM_FRONTEND="gtk"
@ -371,6 +371,12 @@ int mkstemp(char*);
#define USE_BOOST_FORMAT 0 #define USE_BOOST_FORMAT 0
#endif #endif
#if defined(ENABLE_ASSERTIONS)
#define BOOST_ENABLE_ASSERT_HANDLER 1
#else
#define BOOST_DISABLE_ASSERTS 1
#endif
#define BOOST_DISABLE_THREADS 1 #define BOOST_DISABLE_THREADS 1
#define BOOST_NO_WREGEX 1 #define BOOST_NO_WREGEX 1
#define BOOST_NO_WSTRING 1 #define BOOST_NO_WSTRING 1

View File

@ -11,13 +11,13 @@
#include <config.h> #include <config.h>
#include "BranchList.h" #include "BranchList.h"
#include "support/LAssert.h"
#include <boost/assert.hpp>
#include <functional> #include <functional>
using std::bind2nd; using std::bind2nd;
using std::binary_function; using std::binary_function;
using namespace lyx::support;
string const Branch::getBranch() const string const Branch::getBranch() const
@ -71,7 +71,7 @@ string BranchList::getColor(string const & s) const
return it->getColor(); return it->getColor();
} }
} }
Assert(false); // Always BOOST_ASSERT(false); // Always
return string(); // never gets here return string(); // never gets here
} }
@ -87,7 +87,7 @@ void BranchList::setColor(string const & s, string const & val)
return; return;
} }
} }
Assert(false); BOOST_ASSERT(false);
} }

View File

@ -40,7 +40,6 @@
#include "insets/updatableinset.h" #include "insets/updatableinset.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // lyx_count #include "support/lyxalgo.h" // lyx_count
@ -260,7 +259,7 @@ bool BufferView::insertLyXFile(string const & filen)
// //
// Moved from lyx_cb.C (Lgb) // Moved from lyx_cb.C (Lgb)
{ {
Assert(!filen.empty()); BOOST_ASSERT(!filen.empty());
string const fname = MakeAbsPath(filen); string const fname = MakeAbsPath(filen);

View File

@ -17,9 +17,9 @@
#include <config.h> #include <config.h>
#include "Bullet.h" #include "Bullet.h"
#include "support/LAssert.h"
using namespace lyx::support; #include <boost/assert.hpp>
/** The four LaTeX itemize environment default bullets /** The four LaTeX itemize environment default bullets
*/ */
@ -354,25 +354,25 @@ string const Bullet::bulletEntry(int f, int c)
void Bullet::testInvariant() const void Bullet::testInvariant() const
{ {
#ifdef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS
Assert(font >= MIN); BOOST_ASSERT(font >= MIN);
Assert(font < FONTMAX); BOOST_ASSERT(font < FONTMAX);
Assert(character >= MIN); BOOST_ASSERT(character >= MIN);
Assert(character < CHARMAX); BOOST_ASSERT(character < CHARMAX);
Assert(size >= MIN); BOOST_ASSERT(size >= MIN);
Assert(size < SIZEMAX); BOOST_ASSERT(size < SIZEMAX);
Assert(user_text >= -1); BOOST_ASSERT(user_text >= -1);
Assert(user_text <= 1); BOOST_ASSERT(user_text <= 1);
// now some relational/operational tests // now some relational/operational tests
if (user_text == 1) { if (user_text == 1) {
Assert(font == -1 && (character == -1 && size == -1)); BOOST_ASSERT(font == -1 && (character == -1 && size == -1));
// Assert(!text.empty()); // this isn't necessarily an error // BOOST_ASSERT(!text.empty()); // this isn't necessarily an error
} }
// else if (user_text == -1) { // else if (user_text == -1) {
// Assert(!text.empty()); // this also isn't necessarily an error // BOOST_ASSERT(!text.empty()); // this also isn't necessarily an error
// } // }
// else { // else {
// // user_text == 0 // // user_text == 0
// Assert(text.empty()); // not usually true // BOOST_ASSERT(text.empty()); // not usually true
// } // }
#endif #endif
} }

View File

@ -1,13 +1,22 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* boost.C (emergencyCleanup): moved here from LAssert.c
(assertion_failed): new function, called by BOOST_ASSERT
* several files: change Assert to BOOST_ASSERT
2003-09-09 Angus Leeming <leeming@lyx.org> 2003-09-09 Angus Leeming <leeming@lyx.org>
* buffer.[Ch]: Add an Impl class and move Buffer's member variables into it. * buffer.[Ch]: Add an Impl class and move Buffer's member
As a result move several header files out of buffer.h. variables into it. As a result move several header files out of
buffer.h.
Add header files to lots of .C files all over the tree as a result. Add header files to lots of .C files all over the tree as a result.
2003-09-09 Angus Leeming <leeming@lyx.org> 2003-09-09 Angus Leeming <leeming@lyx.org>
* buffer.[Ch]: make Buffer's member variables private. Add accessor functions. * buffer.[Ch]: make Buffer's member variables private. Add
accessor functions.
Lots of changes all over the tree as a result. Lots of changes all over the tree as a result.

View File

@ -27,9 +27,9 @@
#include "insets/insetinclude.h" #include "insets/insetinclude.h"
#include "insets/insettabular.h" #include "insets/insettabular.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
using std::for_each; using std::for_each;
using std::make_pair; using std::make_pair;
using std::pair; using std::pair;
@ -178,9 +178,9 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit,
ParagraphList::iterator endpit, ParagraphList::iterator endpit,
int start, int end, textclass_type tc) int start, int end, textclass_type tc)
{ {
Assert(0 <= start && start <= startpit->size()); BOOST_ASSERT(0 <= start && start <= startpit->size());
Assert(0 <= end && end <= endpit->size()); BOOST_ASSERT(0 <= end && end <= endpit->size());
Assert(startpit != endpit || start <= end); BOOST_ASSERT(startpit != endpit || start <= end);
ParagraphList paragraphs; ParagraphList paragraphs;
@ -225,7 +225,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
if (!checkPastePossible()) if (!checkPastePossible())
return make_pair(PitPosPair(pit, pos), pit); return make_pair(PitPosPair(pit, pos), pit);
Assert (pos <= pit->size()); BOOST_ASSERT (pos <= pit->size());
// Make a copy of the CaP paragraphs. // Make a copy of the CaP paragraphs.
ParagraphList simple_cut_clone = cuts[cut_index].first; ParagraphList simple_cut_clone = cuts[cut_index].first;
@ -380,7 +380,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
ParagraphList & pars, ParagraphList & pars,
ErrorList & errorlist) ErrorList & errorlist)
{ {
Assert(!pars.empty()); BOOST_ASSERT(!pars.empty());
int ret = 0; int ret = 0;
if (c1 == c2) if (c1 == c2)

View File

@ -18,7 +18,6 @@
#include "debug.h" #include "debug.h"
#include "LColor.h" #include "LColor.h"
#include "support/LAssert.h"
#include "gettext.h" #include "gettext.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -284,7 +283,7 @@ void LColor::setColor(LColor::color col, string const & x11name)
return; return;
} }
lyxerr << "LyX internal error: color and such." << endl; lyxerr << "LyX internal error: color and such." << endl;
Assert(false); BOOST_ASSERT(false);
} }

View File

@ -40,7 +40,6 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h" #include "support/tostr.h"
@ -829,7 +828,7 @@ Menu const & MenuBackend::getMenu(string const & name) const
lyx::compare_memfun(&Menu::name, name)); lyx::compare_memfun(&Menu::name, name));
if (cit == end()) if (cit == end())
lyxerr << "No submenu named " << name << endl; lyxerr << "No submenu named " << name << endl;
Assert(cit != end()); BOOST_ASSERT(cit != end());
return (*cit); return (*cit);
} }
@ -839,7 +838,7 @@ Menu & MenuBackend::getMenu(string const & name)
MenuList::iterator it = MenuList::iterator it =
find_if(menulist_.begin(), menulist_.end(), find_if(menulist_.begin(), menulist_.end(),
lyx::compare_memfun(&Menu::name, name)); lyx::compare_memfun(&Menu::name, name));
Assert(it != menulist_.end()); BOOST_ASSERT(it != menulist_.end());
return (*it); return (*it);
} }

View File

@ -13,7 +13,8 @@
#include "PrinterParams.h" #include "PrinterParams.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h"
#include <boost/assert.hpp>
PrinterParams::PrinterParams(Target t, PrinterParams::PrinterParams(Target t,
@ -65,13 +66,13 @@ void PrinterParams::testInvariant() const
#ifdef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS
switch (target) { switch (target) {
case PRINTER: case PRINTER:
//lyx::support::Assert(!printer_name.empty()); //BOOST_ASSERT(!printer_name.empty());
break; break;
case FILE: case FILE:
lyx::support::Assert(!file_name.empty()); BOOST_ASSERT(!file_name.empty());
break; break;
default: default:
lyx::support::Assert(false); BOOST_ASSERT(false);
break; break;
} }
#endif #endif

View File

@ -13,7 +13,6 @@
#ifdef USE_ASPELL #ifdef USE_ASPELL
#include "support/LAssert.h"
#include "debug.h" #include "debug.h"
#include <aspell.h> #include <aspell.h>
@ -89,14 +88,14 @@ enum ASpell::Result ASpell::check(WordLangTuple const & word)
AspellSpeller * m = it->second.speller; AspellSpeller * m = it->second.speller;
int word_ok = aspell_speller_check(m, word.word().c_str(), -1); int word_ok = aspell_speller_check(m, word.word().c_str(), -1);
Assert(word_ok != -1); BOOST_ASSERT(word_ok != -1);
if (word_ok) { if (word_ok) {
res = OK; res = OK;
} else { } else {
AspellWordList const * sugs = AspellWordList const * sugs =
aspell_speller_suggest(m, word.word().c_str(), -1); aspell_speller_suggest(m, word.word().c_str(), -1);
Assert(sugs != 0); BOOST_ASSERT(sugs != 0);
els = aspell_word_list_elements(sugs); els = aspell_word_list_elements(sugs);
if (aspell_word_list_empty(sugs)) if (aspell_word_list_empty(sugs))
res = UNKNOWN; res = UNKNOWN;

View File

@ -12,10 +12,12 @@
#include "author.h" #include "author.h"
#include "support/LAssert.h"
#include "support/std_istream.h" #include "support/std_istream.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <boost/assert.hpp>
using namespace lyx::support; using namespace lyx::support;
bool operator==(Author const & l, Author const & r) bool operator==(Author const & l, Author const & r)
@ -63,7 +65,7 @@ int AuthorList::record(Author const & a)
void AuthorList::record(int id, Author const & a) void AuthorList::record(int id, Author const & a)
{ {
Assert(unsigned(id) < authors_.size()); BOOST_ASSERT(unsigned(id) < authors_.size());
authors_[id] = a; authors_[id] = a;
} }
@ -72,7 +74,7 @@ void AuthorList::record(int id, Author const & a)
Author const & AuthorList::get(int id) Author const & AuthorList::get(int id)
{ {
Authors::const_iterator it(authors_.find(id)); Authors::const_iterator it(authors_.find(id));
Assert(it != authors_.end()); BOOST_ASSERT(it != authors_.end());
return it->second; return it->second;
} }

View File

@ -10,13 +10,13 @@
#include <config.h> #include <config.h>
#include "lyx_main.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h"
#include <boost/assert.hpp>
#include <exception> #include <exception>
using namespace lyx::support;
using std::endl; using std::endl;
namespace boost { namespace boost {
@ -25,7 +25,33 @@ void throw_exception(std::exception const & e)
{ {
lyxerr << "Exception caught:\n" lyxerr << "Exception caught:\n"
<< e.what() << endl; << e.what() << endl;
Assert(false); BOOST_ASSERT(false);
}
namespace {
void emergencyCleanup()
{
static bool didCleanup;
if (didCleanup)
return;
didCleanup = true;
LyX::emergencyCleanup();
}
}
void assertion_failed(char const * expr, char const * function,
char const * file, long line)
{
lyxerr << "Assertion triggered in " << function << " by \"" <<
expr << " in file " << file << ":" << line << endl;
emergencyCleanup();
assert(false);
} }

View File

@ -51,7 +51,6 @@
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/gzstream.h" #include "support/gzstream.h"
#include "support/LAssert.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/os.h" #include "support/os.h"
#include "support/path.h" #include "support/path.h"
@ -573,7 +572,7 @@ bool Buffer::readFile(string const & filename, ParagraphList::iterator pit)
bool Buffer::readFile(LyXLex & lex, string const & filename, bool Buffer::readFile(LyXLex & lex, string const & filename,
ParagraphList::iterator pit) ParagraphList::iterator pit)
{ {
Assert(!filename.empty()); BOOST_ASSERT(!filename.empty());
if (!lex.isOK()) { if (!lex.isOK()) {
Alert::error(_("Document could not be read"), Alert::error(_("Document could not be read"),

View File

@ -26,7 +26,6 @@
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include <boost/bind.hpp> #include <boost/bind.hpp>
@ -110,7 +109,7 @@ bool BufferList::quitWriteAll()
void BufferList::release(Buffer * buf) void BufferList::release(Buffer * buf)
{ {
Assert(buf); BOOST_ASSERT(buf);
BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf); BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf);
if (it != bstore.end()) { if (it != bstore.end()) {
// Make sure that we don't store a LyXText in // Make sure that we don't store a LyXText in
@ -149,7 +148,7 @@ void BufferList::closeAll()
bool BufferList::close(Buffer * buf, bool ask) bool BufferList::close(Buffer * buf, bool ask)
{ {
Assert(buf); BOOST_ASSERT(buf);
// FIXME: is the quitting check still necessary ? // FIXME: is the quitting check still necessary ?
if (!ask || buf->isClean() || quitting || buf->paragraphs().empty()) { if (!ask || buf->isClean() || quitting || buf->paragraphs().empty()) {
@ -308,7 +307,7 @@ bool BufferList::exists(string const & s) const
bool BufferList::isLoaded(Buffer const * b) const bool BufferList::isLoaded(Buffer const * b) const
{ {
Assert(b); BOOST_ASSERT(b);
BufferStorage::const_iterator cit = BufferStorage::const_iterator cit =
find(bstore.begin(), bstore.end(), b); find(bstore.begin(), bstore.end(), b);

View File

@ -36,7 +36,6 @@
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // for lyx::count #include "support/lyxalgo.h" // for lyx::count
#include <boost/array.hpp> #include <boost/array.hpp>
@ -148,28 +147,28 @@ BranchList const & BufferParams::branchlist() const
Bullet & BufferParams::temp_bullet(lyx::size_type index) Bullet & BufferParams::temp_bullet(lyx::size_type index)
{ {
support::Assert(index < 4); BOOST_ASSERT(index < 4);
return pimpl_->temp_bullets[index]; return pimpl_->temp_bullets[index];
} }
Bullet const & BufferParams::temp_bullet(lyx::size_type index) const Bullet const & BufferParams::temp_bullet(lyx::size_type index) const
{ {
support::Assert(index < 4); BOOST_ASSERT(index < 4);
return pimpl_->temp_bullets[index]; return pimpl_->temp_bullets[index];
} }
Bullet & BufferParams::user_defined_bullet(lyx::size_type index) Bullet & BufferParams::user_defined_bullet(lyx::size_type index)
{ {
support::Assert(index < 4); BOOST_ASSERT(index < 4);
return pimpl_->user_defined_bullets[index]; return pimpl_->user_defined_bullets[index];
} }
Bullet const & BufferParams::user_defined_bullet(lyx::size_type index) const Bullet const & BufferParams::user_defined_bullet(lyx::size_type index) const
{ {
support::Assert(index < 4); BOOST_ASSERT(index < 4);
return pimpl_->user_defined_bullets[index]; return pimpl_->user_defined_bullets[index];
} }

View File

@ -15,13 +15,13 @@
#include "changes.h" #include "changes.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h" #include <boost/assert.hpp>
using namespace lyx::support;
using std::endl; using std::endl;
using lyx::pos_type; using lyx::pos_type;
bool operator==(Change const & l, Change const & r) bool operator==(Change const & l, Change const & r)
{ {
return l.type == r.type && l.author == r.author return l.type == r.type && l.author == r.author
@ -326,7 +326,7 @@ Change const Changes::lookupFull(pos_type pos) const
} }
check(); check();
Assert(false); BOOST_ASSERT(false);
return Change(Change::UNCHANGED); return Change(Change::UNCHANGED);
} }
@ -348,7 +348,7 @@ Change::Type Changes::lookup(pos_type pos) const
} }
check(); check();
Assert(0); BOOST_ASSERT(0);
return Change::UNCHANGED; return Change::UNCHANGED;
} }
@ -486,7 +486,7 @@ void Changes::check() const
if (lyxerr.debugging(Debug::CHANGES)) if (lyxerr.debugging(Debug::CHANGES))
lyxerr[Debug::CHANGES] << "End" << endl; lyxerr[Debug::CHANGES] << "End" << endl;
Assert(dont_assert); BOOST_ASSERT(dont_assert);
} }

View File

@ -13,10 +13,11 @@
#include "counters.h" #include "counters.h"
#include "debug.h" #include "debug.h"
#include "support/std_sstream.h"
#include "support/std_sstream.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h"
#include <boost/assert.hpp>
using namespace lyx::support; using namespace lyx::support;
@ -171,7 +172,7 @@ void Counters::reset()
void Counters::reset(string const & match) void Counters::reset(string const & match)
{ {
Assert(!match.empty()); BOOST_ASSERT(!match.empty());
CounterList::iterator it = counterList.begin(); CounterList::iterator it = counterList.begin();
CounterList::iterator end = counterList.end(); CounterList::iterator end = counterList.end();

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* Timeout.C: change Assert to BOOST_ASSERT
2003-09-07 Angus Leeming <leeming@lyx.org> 2003-09-07 Angus Leeming <leeming@lyx.org>
* Alert.h: remove #include <algorithm>. * Alert.h: remove #include <algorithm>.

View File

@ -13,10 +13,6 @@
#include "Timeout.h" #include "Timeout.h"
#include "support/LAssert.h"
using namespace lyx::support;
Timeout::~Timeout() Timeout::~Timeout()
{ {
@ -68,7 +64,7 @@ Timeout & Timeout::setType(Type t)
Timeout & Timeout::setTimeout(unsigned int msec) Timeout & Timeout::setTimeout(unsigned int msec)
{ {
// Can't have a timeout of zero! // Can't have a timeout of zero!
Assert(msec); BOOST_ASSERT(msec);
timeout_ms = msec; timeout_ms = msec;
return * this; return * this;

View File

@ -8,17 +8,15 @@
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
#include <config.h> #include <config.h>
#include "ButtonController.h" #include "ButtonController.h"
#include "BCView.h" #include "BCView.h"
#include "support/LAssert.h"
using namespace lyx::support;
BCView & ButtonController::view() const BCView & ButtonController::view() const
{ {
Assert(view_.get()); BOOST_ASSERT(view_.get());
return *view_.get(); return *view_.get();
} }
@ -30,7 +28,7 @@ void ButtonController::view(BCView * view)
ButtonPolicy & ButtonController::bp() const ButtonPolicy & ButtonController::bp() const
{ {
Assert(bp_.get()); BOOST_ASSERT(bp_.get());
return *bp_.get(); return *bp_.get();
} }

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* several files: change Assert to BOOST_ASSERT
2003-09-08 Angus Leeming <leeming@lyx.org> 2003-09-08 Angus Leeming <leeming@lyx.org>
* ControlCommandBuffer.C: * ControlCommandBuffer.C:

View File

@ -15,9 +15,7 @@
#include "ButtonController.h" #include "ButtonController.h"
#include "BCView.h" #include "BCView.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "support/LAssert.h"
using namespace lyx::support;
ControlButtons::ControlButtons() ControlButtons::ControlButtons()
: emergency_exit_(false), is_closing_(false), : emergency_exit_(false), is_closing_(false),
@ -68,14 +66,14 @@ bool ControlButtons::IconifyWithMain() const
ButtonController & ControlButtons::bc() ButtonController & ControlButtons::bc()
{ {
Assert(bc_ptr_.get()); BOOST_ASSERT(bc_ptr_.get());
return *bc_ptr_.get(); return *bc_ptr_.get();
} }
ViewBase & ControlButtons::view() ViewBase & ControlButtons::view()
{ {
Assert(view_ptr_); BOOST_ASSERT(view_ptr_);
return *view_ptr_; return *view_ptr_;
} }

View File

@ -29,7 +29,6 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/path_defines.h" #include "support/path_defines.h"
using namespace lyx::support; using namespace lyx::support;
@ -46,7 +45,7 @@ ControlDocument::~ControlDocument()
BufferParams & ControlDocument::params() BufferParams & ControlDocument::params()
{ {
Assert(bp_.get()); BOOST_ASSERT(bp_.get());
return *bp_; return *bp_;
} }

View File

@ -20,7 +20,6 @@
#include "insets/ExternalTemplate.h" #include "insets/ExternalTemplate.h"
#include "support/LAssert.h"
using namespace lyx::support; using namespace lyx::support;
using std::vector; using std::vector;
@ -55,21 +54,21 @@ void ControlExternal::dispatchParams()
void ControlExternal::setParams(InsetExternal::Params const & p) void ControlExternal::setParams(InsetExternal::Params const & p)
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
*params_ = p; *params_ = p;
} }
InsetExternal::Params const & ControlExternal::params() const InsetExternal::Params const & ControlExternal::params() const
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
return *params_; return *params_;
} }
void ControlExternal::editExternal() void ControlExternal::editExternal()
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
dialog().view().apply(); dialog().view().apply();
string const lfun = string const lfun =

View File

@ -14,7 +14,6 @@
#include "debug.h" #include "debug.h"
#include "funcrequest.h" #include "funcrequest.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // sorted #include "support/lyxalgo.h" // sorted
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -340,7 +339,7 @@ string const find_xpm(string const & name)
{ {
XPMmap const * const begin = sorted_xpm_map; XPMmap const * const begin = sorted_xpm_map;
XPMmap const * const end = begin + nr_sorted_xpm_map; XPMmap const * const end = begin + nr_sorted_xpm_map;
Assert(lyx::sorted(begin, end)); BOOST_ASSERT(lyx::sorted(begin, end));
XPMmap const * const it = XPMmap const * const it =
std::find_if(begin, end, CompareKey(name)); std::find_if(begin, end, CompareKey(name));

View File

@ -17,11 +17,8 @@
#include "lyxlex.h" #include "lyxlex.h"
#include "paragraph.h" #include "paragraph.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "support/LAssert.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
using namespace lyx::support;
using std::istringstream; using std::istringstream;
using std::ostringstream; using std::ostringstream;
@ -130,14 +127,14 @@ void ControlParagraph::dispatchParams()
ParagraphParameters & ControlParagraph::params() ParagraphParameters & ControlParagraph::params()
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
return *params_; return *params_;
} }
ParagraphParameters const & ControlParagraph::params() const ParagraphParameters const & ControlParagraph::params() const
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
return *params_; return *params_;
} }

View File

@ -26,7 +26,6 @@
#include "support/tostr.h" #include "support/tostr.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/path.h" #include "support/path.h"
#include "support/systemcall.h" #include "support/systemcall.h"
@ -44,7 +43,7 @@ ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
PrinterParams & ControlPrint::params() const PrinterParams & ControlPrint::params() const
{ {
Assert(params_); BOOST_ASSERT(params_);
return *params_; return *params_;
} }

View File

@ -15,9 +15,6 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "paragraph.h" #include "paragraph.h"
#include "insets/insettabular.h" #include "insets/insettabular.h"
#include "support/LAssert.h"
using namespace lyx::support;
ControlTabular::ControlTabular(Dialog & parent) ControlTabular::ControlTabular(Dialog & parent)
@ -54,7 +51,7 @@ int ControlTabular::getActiveCell() const
LyXTabular const & ControlTabular::tabular() const LyXTabular const & ControlTabular::tabular() const
{ {
Assert(params_.get()); BOOST_ASSERT(params_.get());
return *params_.get(); return *params_.get();
} }

View File

@ -14,9 +14,7 @@
#include "ButtonController.h" #include "ButtonController.h"
#include "BCView.h" #include "BCView.h"
#include "support/LAssert.h"
using namespace lyx::support;
Dialog::Dialog(LyXView & lv, string const & name) Dialog::Dialog(LyXView & lv, string const & name)
: is_closing_(false), kernel_(lv), name_(name), : is_closing_(false), kernel_(lv), name_(name),
@ -142,21 +140,21 @@ void Dialog::redraw()
ButtonController & Dialog::bc() const ButtonController & Dialog::bc() const
{ {
Assert(bc_ptr_.get()); BOOST_ASSERT(bc_ptr_.get());
return *bc_ptr_.get(); return *bc_ptr_.get();
} }
void Dialog::setController(Controller * i) void Dialog::setController(Controller * i)
{ {
Assert(i && !controller_ptr_.get()); BOOST_ASSERT(i && !controller_ptr_.get());
controller_ptr_.reset(i); controller_ptr_.reset(i);
} }
void Dialog::setView(View * v) void Dialog::setView(View * v)
{ {
Assert(v && !view_ptr_.get()); BOOST_ASSERT(v && !view_ptr_.get());
view_ptr_.reset(v); view_ptr_.reset(v);
} }
@ -168,7 +166,7 @@ Dialog::Controller::Controller(Dialog & parent)
Dialog::Controller & Dialog::controller() const Dialog::Controller & Dialog::controller() const
{ {
Assert(controller_ptr_.get()); BOOST_ASSERT(controller_ptr_.get());
return *controller_ptr_.get(); return *controller_ptr_.get();
} }
@ -180,7 +178,7 @@ Dialog::View::View(Dialog & parent, string title) :
Dialog::View & Dialog::view() const Dialog::View & Dialog::view() const
{ {
Assert(view_ptr_.get()); BOOST_ASSERT(view_ptr_.get());
return *view_ptr_.get(); return *view_ptr_.get();
} }

View File

@ -19,9 +19,6 @@
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/LAssert.h"
using lyx::support::Assert;
Kernel::Kernel(LyXView & lyxview) Kernel::Kernel(LyXView & lyxview)
: lyxview_(lyxview) : lyxview_(lyxview)
@ -94,13 +91,13 @@ BufferView const * Kernel::bufferview() const
Buffer & Kernel::buffer() Buffer & Kernel::buffer()
{ {
Assert(lyxview_.buffer()); BOOST_ASSERT(lyxview_.buffer());
return *lyxview_.buffer(); return *lyxview_.buffer();
} }
Buffer const & Kernel::buffer() const Buffer const & Kernel::buffer() const
{ {
Assert(lyxview_.buffer()); BOOST_ASSERT(lyxview_.buffer());
return *lyxview_.buffer(); return *lyxview_.buffer();
} }

View File

@ -12,9 +12,7 @@
#include "ViewBase.h" #include "ViewBase.h"
#include "ControlButtons.h" #include "ControlButtons.h"
#include "support/LAssert.h"
using namespace lyx::support;
ViewBase::ViewBase(string const & t) ViewBase::ViewBase(string const & t)
: controller_ptr_(0), title_(t) : controller_ptr_(0), title_(t)
@ -41,14 +39,14 @@ string const & ViewBase::getTitle() const
ControlButtons & ViewBase::getController() ControlButtons & ViewBase::getController()
{ {
Assert(controller_ptr_); BOOST_ASSERT(controller_ptr_);
return *controller_ptr_; return *controller_ptr_;
} }
ControlButtons const & ViewBase::getController() const ControlButtons const & ViewBase::getController() const
{ {
Assert(controller_ptr_); BOOST_ASSERT(controller_ptr_);
return *controller_ptr_; return *controller_ptr_;
} }

View File

@ -17,7 +17,6 @@
#include "gettext.h" // for _() #include "gettext.h" // for _()
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
@ -57,7 +56,7 @@ string const familyName(string const & name)
string const getAbbreviatedAuthor(InfoMap const & map, string const & key) string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
{ {
Assert(!map.empty()); BOOST_ASSERT(!map.empty());
InfoMap::const_iterator it = map.find(key); InfoMap::const_iterator it = map.find(key);
if (it == map.end()) if (it == map.end())
@ -109,7 +108,7 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
string const getYear(InfoMap const & map, string const & key) string const getYear(InfoMap const & map, string const & key)
{ {
Assert(!map.empty()); BOOST_ASSERT(!map.empty());
InfoMap::const_iterator it = map.find(key); InfoMap::const_iterator it = map.find(key);
if (it == map.end()) if (it == map.end())
@ -173,7 +172,7 @@ vector<string> const getKeys(InfoMap const & map)
string const getInfo(InfoMap const & map, string const & key) string const getInfo(InfoMap const & map, string const & key)
{ {
Assert(!map.empty()); BOOST_ASSERT(!map.empty());
InfoMap::const_iterator it = map.find(key); InfoMap::const_iterator it = map.find(key);
if (it == map.end()) if (it == map.end())

View File

@ -1,3 +1,8 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* GView.C: change Assert to BOOST_ASSERT
* GnomeBase.C: ditto
2003-07-21 Angus Leeming <leeming@lyx.org> 2003-07-21 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (reset): use namespace lyx::graphics rather than grfx * lyx_gui.C (reset): use namespace lyx::graphics rather than grfx

View File

@ -8,13 +8,13 @@
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
#include <config.h> #include <config.h>
#include "GView.h" #include "GView.h"
#include "support/LAssert.h"
#include "debug.h" #include "debug.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "ControlButtons.h" #include "ControlButtons.h"
#include <glib.h> #include <glib.h>
#include <gtkmm/dialog.h> #include <gtkmm/dialog.h>
@ -49,7 +49,7 @@ void GView::loadXML()
if (file.empty()) { if (file.empty()) {
lyxerr << "Cannot find glade file. Aborting." << endl; lyxerr << "Cannot find glade file. Aborting." << endl;
lyx::Assert(true); BOOST_ASSERT(true);
} }
lyxerr[Debug::GUI] << "Glade file to open is " << file << endl; lyxerr[Debug::GUI] << "Glade file to open is " << file << endl;

View File

@ -8,16 +8,17 @@
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
#include <config.h> #include <config.h>
#include "GnomeBase.h" #include "GnomeBase.h"
#include "support/LAssert.h"
#include "debug.h" #include "debug.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "ControlButtons.h" #include "ControlButtons.h"
#include <glib.h> #include <glib.h>
#include <gtkmm/dialog.h> #include <gtkmm/dialog.h>
GnomeBase::GnomeBase(string const & name) GnomeBase::GnomeBase(string const & name)
: ViewBase(), : ViewBase(),
updating_(false), updating_(false),
@ -49,7 +50,7 @@ void GnomeBase::loadXML()
if (file.empty()) { if (file.empty()) {
lyxerr << "Cannot find glade file. Aborting." << std::endl; lyxerr << "Cannot find glade file. Aborting." << std::endl;
lyx::Assert(true); BOOST_ASSERT(true);
} }
lyxerr[Debug::GUI] << "Glade file to open is " << file << endl; lyxerr[Debug::GUI] << "Glade file to open is " << file << endl;

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* GPainter.C: change Assert to BOOST_ASSERT
2003-09-08 Angus Leeming <leeming@lyx.org> 2003-09-08 Angus Leeming <leeming@lyx.org>
* GPainter.h: do not #include <config.h> in header files. * GPainter.h: do not #include <config.h> in header files.

View File

@ -23,11 +23,12 @@
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
#include "codeConvert.h" #include "codeConvert.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <cmath> #include <cmath>

View File

@ -10,10 +10,10 @@
*/ */
#include <config.h> #include <config.h>
#include "qt_helpers.h" #include "qt_helpers.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "QBrowseBox.h" #include "QBrowseBox.h"
#include "BulletsModule.h" #include "BulletsModule.h"
@ -236,7 +236,7 @@ void BulletsModule::setBullet(int level, const Bullet & bullet)
case 1: pb = bullet2PB; co = bulletsize2CO; break; case 1: pb = bullet2PB; co = bulletsize2CO; break;
case 2: pb = bullet3PB; co = bulletsize3CO; break; case 2: pb = bullet3PB; co = bulletsize3CO; break;
case 3: pb = bullet4PB; co = bulletsize4CO; break; case 3: pb = bullet4PB; co = bulletsize4CO; break;
default: Assert(false); break; default: BOOST_ASSERT(false); break;
} }
setBullet(pb, co, bullet); setBullet(pb, co, bullet);

View File

@ -1,3 +1,9 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* BulletsModule.C: change Assert to BOOST_ASSERT
* panelstack.C: ditto
* QDocument.C: ditto
2003-09-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org> 2003-09-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QLToolbar.C: include <qtoolbar.h> * QLToolbar.C: include <qtoolbar.h>

View File

@ -99,9 +99,9 @@ void QDocument::build_dialog()
// paper // paper
QComboBox * cb = dialog_->pageLayoutModule->papersizeCO; QComboBox * cb = dialog_->pageLayoutModule->papersizeCO;
cb->insertItem(qt_("Default")); cb->insertItem(qt_("Default"));
cb->insertItem(qt_("Custom")); cb->insertItem(qt_("Custom"));
cb->insertItem(qt_("US letter")); cb->insertItem(qt_("US letter"));
cb->insertItem(qt_("US legal")); cb->insertItem(qt_("US legal"));
cb->insertItem(qt_("US executive")); cb->insertItem(qt_("US executive"));
cb->insertItem(qt_("A3")); cb->insertItem(qt_("A3"));
cb->insertItem(qt_("A4")); cb->insertItem(qt_("A4"));

View File

@ -12,8 +12,6 @@
#include "panelstack.h" #include "panelstack.h"
#include "support/LAssert.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include <qwidgetstack.h> #include <qwidgetstack.h>
@ -61,7 +59,7 @@ void PanelStack::addCategory(string const & n, string const & parent)
if (!parent.empty()) { if (!parent.empty()) {
PanelMap::iterator it = panel_map_.find(parent); PanelMap::iterator it = panel_map_.find(parent);
Assert(it != panel_map_.end()); BOOST_ASSERT(it != panel_map_.end());
QListViewItem * before = it->second->firstChild(); QListViewItem * before = it->second->firstChild();
if (before) { if (before) {
@ -110,7 +108,7 @@ void PanelStack::addPanel(QWidget * panel, string const & name, string const & p
void PanelStack::setCurrentPanel(string const & name) void PanelStack::setCurrentPanel(string const & name)
{ {
PanelMap::const_iterator cit = panel_map_.find(name); PanelMap::const_iterator cit = panel_map_.find(name);
Assert(cit != panel_map_.end()); BOOST_ASSERT(cit != panel_map_.end());
// force on first set // force on first set
if (list_->currentItem() == cit->second) if (list_->currentItem() == cit->second)

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* several files: change Assert to BOOST_ASSERT
2003-09-08 Angus Leeming <leeming@lyx.org> 2003-09-08 Angus Leeming <leeming@lyx.org>
* FormFiledialog.C (UserCache::add, GroupCache::add): convert * FormFiledialog.C (UserCache::add, GroupCache::add): convert

View File

@ -12,8 +12,6 @@
#include "Color.h" #include "Color.h"
#include "support/LAssert.h"
#include "lyx_forms.h" #include "lyx_forms.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
@ -21,7 +19,6 @@
#include <cmath> #include <cmath>
#include <iomanip> #include <iomanip>
namespace support = lyx::support;
#ifndef CXX_GLOBAL_CSTD #ifndef CXX_GLOBAL_CSTD
using std::floor; using std::floor;
@ -89,7 +86,7 @@ string const X11hexname(RGBColor const & col)
RGBColor::RGBColor(string const & x11hexname) RGBColor::RGBColor(string const & x11hexname)
: r(0), g(0), b(0) : r(0), g(0), b(0)
{ {
support::Assert(x11hexname.size() == 7 && x11hexname[0] == '#'); BOOST_ASSERT(x11hexname.size() == 7 && x11hexname[0] == '#');
r = hexstrToInt(x11hexname.substr(1,2)); r = hexstrToInt(x11hexname.substr(1,2));
g = hexstrToInt(x11hexname.substr(3,2)); g = hexstrToInt(x11hexname.substr(3,2));
b = hexstrToInt(x11hexname.substr(5,2)); b = hexstrToInt(x11hexname.substr(5,2));

View File

@ -21,7 +21,6 @@
#include "controllers/ControlButtons.h" #include "controllers/ControlButtons.h"
#include "support/filetools.h" // LibFileSearch #include "support/filetools.h" // LibFileSearch
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyx_forms.h" #include "lyx_forms.h"
@ -125,7 +124,7 @@ void FormBase::show()
{ {
// build() is/should be called from the controller, so form() should // build() is/should be called from the controller, so form() should
// always exist. // always exist.
Assert(form()); BOOST_ASSERT(form());
// we use minw_ to flag whether the dialog has ever been shown. // we use minw_ to flag whether the dialog has ever been shown.
// In turn, prepare_to_show() initialises various bits 'n' pieces // In turn, prepare_to_show() initialises various bits 'n' pieces
@ -184,14 +183,14 @@ void FormBase::hide()
void FormBase::setPrehandler(FL_OBJECT * ob) void FormBase::setPrehandler(FL_OBJECT * ob)
{ {
Assert(ob); BOOST_ASSERT(ob);
fl_set_object_prehandler(ob, C_PrehandlerCB); fl_set_object_prehandler(ob, C_PrehandlerCB);
} }
void FormBase::setMessageWidget(FL_OBJECT * ob) void FormBase::setMessageWidget(FL_OBJECT * ob)
{ {
Assert(ob && ob->objclass == FL_TEXT); BOOST_ASSERT(ob && ob->objclass == FL_TEXT);
message_widget_ = ob; message_widget_ = ob;
fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE);
} }
@ -218,7 +217,7 @@ ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
// preemptive handler for feedback messages // preemptive handler for feedback messages
void FormBase::MessageCB(FL_OBJECT * ob, int event) void FormBase::MessageCB(FL_OBJECT * ob, int event)
{ {
Assert(ob); BOOST_ASSERT(ob);
switch (event) { switch (event) {
case FL_ENTER: case FL_ENTER:
@ -245,7 +244,7 @@ void FormBase::MessageCB(FL_OBJECT * ob, int event)
void FormBase::PrehandlerCB(FL_OBJECT * ob, int event, int key) void FormBase::PrehandlerCB(FL_OBJECT * ob, int event, int key)
{ {
Assert(ob); BOOST_ASSERT(ob);
if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) {
// Trigger an input event when pasting in an xforms input object // Trigger an input event when pasting in an xforms input object
@ -297,7 +296,7 @@ void FormBase::postWarning(string const & warning)
void FormBase::clearMessage() void FormBase::clearMessage()
{ {
Assert(message_widget_); BOOST_ASSERT(message_widget_);
warning_posted_ = false; warning_posted_ = false;
@ -314,7 +313,7 @@ void FormBase::clearMessage()
void FormBase::postMessage(string const & message) void FormBase::postMessage(string const & message)
{ {
Assert(message_widget_); BOOST_ASSERT(message_widget_);
int const width = message_widget_->w - 10; int const width = message_widget_->w - 10;
string const tmp = warning_posted_ ? string const tmp = warning_posted_ ?
@ -336,7 +335,7 @@ namespace {
FormBase * GetForm(FL_OBJECT * ob) FormBase * GetForm(FL_OBJECT * ob)
{ {
Assert(ob && ob->form && ob->form->u_vdata); BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata); FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata);
return ptr; return ptr;
} }
@ -380,7 +379,7 @@ void C_FormBaseInputCB(FL_OBJECT * ob, long d)
static int C_WMHideCB(FL_FORM * form, void *) static int C_WMHideCB(FL_FORM * form, void *)
{ {
// Close the dialog cleanly, even if the WM is used to do so. // Close the dialog cleanly, even if the WM is used to do so.
Assert(form && form->u_vdata); BOOST_ASSERT(form && form->u_vdata);
FormBase * ptr = static_cast<FormBase *>(form->u_vdata); FormBase * ptr = static_cast<FormBase *>(form->u_vdata);
ptr->getController().CancelButton(); ptr->getController().CancelButton();
return FL_CANCEL; return FL_CANCEL;
@ -391,11 +390,11 @@ static int C_PrehandlerCB(FL_OBJECT * ob, int event,
{ {
// Note that the return value is important in the pre-emptive handler. // Note that the return value is important in the pre-emptive handler.
// Don't return anything other than 0. // Don't return anything other than 0.
Assert(ob); BOOST_ASSERT(ob);
// Don't Assert this one, as it can happen quite naturally when things // Don't Assert this one, as it can happen quite naturally when things
// are being deleted in the d-tor. // are being deleted in the d-tor.
//Assert(ob->form); //BOOST_ASSERT(ob->form);
if (!ob->form) return 0; if (!ob->form) return 0;
FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata); FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata);

View File

@ -20,7 +20,6 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "support/filetools.h" // LibFileSearch #include "support/filetools.h" // LibFileSearch
#include "support/LAssert.h"
#include "support/tostr.h" #include "support/tostr.h"
#include "lyx_forms.h" #include "lyx_forms.h"
@ -346,7 +345,7 @@ extern "C" {
void C_FormColorpickerInputCB(FL_OBJECT * ob, long d) void C_FormColorpickerInputCB(FL_OBJECT * ob, long d)
{ {
lyx::support::Assert(ob && ob->form && ob->form->u_vdata); BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
FormColorpicker * ptr = FormColorpicker * ptr =
static_cast<FormColorpicker *>(ob->form->u_vdata); static_cast<FormColorpicker *>(ob->form->u_vdata);
ptr->input(ob, d); ptr->input(ob, d);
@ -356,7 +355,7 @@ void C_FormColorpickerInputCB(FL_OBJECT * ob, long d)
static int C_WMHideCB(FL_FORM * form, void *) static int C_WMHideCB(FL_FORM * form, void *)
{ {
// Close the dialog cleanly, even if the WM is used to do so. // Close the dialog cleanly, even if the WM is used to do so.
lyx::support::Assert(form && form->u_vdata); BOOST_ASSERT(form && form->u_vdata);
FormColorpicker * ptr = static_cast<FormColorpicker *>(form->u_vdata); FormColorpicker * ptr = static_cast<FormColorpicker *>(form->u_vdata);
ptr->input(0, 0); ptr->input(0, 0);
return FL_CANCEL; return FL_CANCEL;

View File

@ -22,7 +22,6 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "support/filetools.h" // LibFileSearch #include "support/filetools.h" // LibFileSearch
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyx_forms.h" #include "lyx_forms.h"
@ -186,14 +185,14 @@ void FormDialogView::hide()
void FormDialogView::setPrehandler(FL_OBJECT * ob) void FormDialogView::setPrehandler(FL_OBJECT * ob)
{ {
Assert(ob); BOOST_ASSERT(ob);
fl_set_object_prehandler(ob, C_PrehandlerCB); fl_set_object_prehandler(ob, C_PrehandlerCB);
} }
void FormDialogView::setMessageWidget(FL_OBJECT * ob) void FormDialogView::setMessageWidget(FL_OBJECT * ob)
{ {
Assert(ob && ob->objclass == FL_TEXT); BOOST_ASSERT(ob && ob->objclass == FL_TEXT);
message_widget_ = ob; message_widget_ = ob;
fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE);
} }
@ -220,7 +219,7 @@ ButtonPolicy::SMInput FormDialogView::input(FL_OBJECT *, long)
// preemptive handler for feedback messages // preemptive handler for feedback messages
void FormDialogView::MessageCB(FL_OBJECT * ob, int event) void FormDialogView::MessageCB(FL_OBJECT * ob, int event)
{ {
Assert(ob); BOOST_ASSERT(ob);
switch (event) { switch (event) {
case FL_ENTER: case FL_ENTER:
@ -247,7 +246,7 @@ void FormDialogView::MessageCB(FL_OBJECT * ob, int event)
void FormDialogView::PrehandlerCB(FL_OBJECT * ob, int event, int key) void FormDialogView::PrehandlerCB(FL_OBJECT * ob, int event, int key)
{ {
Assert(ob); BOOST_ASSERT(ob);
if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) {
// Trigger an input event when pasting in an xforms input // Trigger an input event when pasting in an xforms input
@ -299,7 +298,7 @@ void FormDialogView::postWarning(string const & warning)
void FormDialogView::clearMessage() void FormDialogView::clearMessage()
{ {
Assert(message_widget_); BOOST_ASSERT(message_widget_);
warning_posted_ = false; warning_posted_ = false;
@ -316,7 +315,7 @@ void FormDialogView::clearMessage()
void FormDialogView::postMessage(string const & message) void FormDialogView::postMessage(string const & message)
{ {
Assert(message_widget_); BOOST_ASSERT(message_widget_);
int const width = message_widget_->w - 10; int const width = message_widget_->w - 10;
string const tmp = warning_posted_ ? string const tmp = warning_posted_ ?
@ -338,7 +337,7 @@ namespace {
FormDialogView * GetForm(FL_OBJECT * ob) FormDialogView * GetForm(FL_OBJECT * ob)
{ {
Assert(ob && ob->form && ob->form->u_vdata); BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
FormDialogView * ptr = FormDialogView * ptr =
static_cast<FormDialogView *>(ob->form->u_vdata); static_cast<FormDialogView *>(ob->form->u_vdata);
return ptr; return ptr;
@ -383,7 +382,7 @@ void C_FormDialogView_InputCB(FL_OBJECT * ob, long d)
static int C_WMHideCB(FL_FORM * form, void *) static int C_WMHideCB(FL_FORM * form, void *)
{ {
// Close the dialog cleanly, even if the WM is used to do so. // Close the dialog cleanly, even if the WM is used to do so.
Assert(form && form->u_vdata); BOOST_ASSERT(form && form->u_vdata);
FormDialogView * ptr = static_cast<FormDialogView *>(form->u_vdata); FormDialogView * ptr = static_cast<FormDialogView *>(form->u_vdata);
ptr->dialog().CancelButton(); ptr->dialog().CancelButton();
return FL_CANCEL; return FL_CANCEL;
@ -394,11 +393,11 @@ static int C_PrehandlerCB(FL_OBJECT * ob, int event,
{ {
// Note that the return value is important in the pre-emptive handler. // Note that the return value is important in the pre-emptive handler.
// Don't return anything other than 0. // Don't return anything other than 0.
Assert(ob); BOOST_ASSERT(ob);
// Don't Assert this one, as it can happen quite naturally when things // Don't Assert this one, as it can happen quite naturally when things
// are being deleted in the d-tor. // are being deleted in the d-tor.
//Assert(ob->form); //BOOST_ASSERT(ob->form);
if (!ob->form) return 0; if (!ob->form) return 0;
FormDialogView * ptr = FormDialogView * ptr =

View File

@ -20,9 +20,6 @@
#include "ControlMath.h" #include "ControlMath.h"
#include "support/LAssert.h"
using namespace lyx::support;
using std::max; using std::max;
using std::vector; using std::vector;
@ -74,7 +71,7 @@ void FormMathsBitmap::addBitmap(BitmapStore const & bm)
void FormMathsBitmap::build() void FormMathsBitmap::build()
{ {
Assert(bitmaps_.size() > 0); BOOST_ASSERT(bitmaps_.size() > 0);
h_+= 42; // Allow room for a Close button h_+= 42; // Allow room for a Close button

View File

@ -21,14 +21,12 @@
#include "controllers/ButtonController.h" #include "controllers/ButtonController.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // lyx::count #include "support/lyxalgo.h" // lyx::count
#include "lyx_forms.h" #include "lyx_forms.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
using namespace lyx::support;
using std::ostringstream; using std::ostringstream;
@ -47,10 +45,10 @@ extern "C" {
int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *, int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
char const * cur, int c) char const * cur, int c)
{ {
Assert(ob); BOOST_ASSERT(ob);
FormMathsMatrix * pre = FormMathsMatrix * pre =
static_cast<FormMathsMatrix *>(ob->u_vdata); static_cast<FormMathsMatrix *>(ob->u_vdata);
Assert(pre); BOOST_ASSERT(pre);
return pre->AlignFilter(cur, c); return pre->AlignFilter(cur, c);
} }

View File

@ -28,7 +28,6 @@
#include "Spacing.h" #include "Spacing.h"
#include "vspace.h" #include "vspace.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h" #include "support/tostr.h"
@ -442,7 +441,7 @@ namespace {
void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length) void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length)
{ {
// Paranoia check! // Paranoia check!
Assert(choice_type && choice_type->objclass == FL_CHOICE && BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT); input_length && input_length->objclass == FL_INPUT);
if (fl_get_choice(choice_type) != 7) if (fl_get_choice(choice_type) != 7)
@ -462,7 +461,7 @@ VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type,
FL_OBJECT * check_keep) FL_OBJECT * check_keep)
{ {
// Paranoia check! // Paranoia check!
Assert(choice_type && choice_type->objclass == FL_CHOICE && BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT && input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE && choice_length && choice_length->objclass == FL_CHOICE &&
check_keep && check_keep->objclass == FL_CHECKBUTTON); check_keep && check_keep->objclass == FL_CHECKBUTTON);
@ -510,7 +509,7 @@ void setWidgetsFromVSpace(VSpace const & space,
FL_OBJECT * check_keep) FL_OBJECT * check_keep)
{ {
// Paranoia check! // Paranoia check!
Assert(choice_type && choice_type->objclass == FL_CHOICE && BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT && input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE && choice_length && choice_length->objclass == FL_CHOICE &&
check_keep && check_keep->objclass == FL_CHECKBUTTON); check_keep && check_keep->objclass == FL_CHECKBUTTON);

View File

@ -27,7 +27,6 @@
#include "frnt_lang.h" #include "frnt_lang.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h" #include "support/tostr.h"
#include "support/path_defines.h" #include "support/path_defines.h"
@ -308,7 +307,7 @@ void FormPreferences::apply()
string const FormPreferences::getFeedback(FL_OBJECT * ob) string const FormPreferences::getFeedback(FL_OBJECT * ob)
{ {
Assert(ob); BOOST_ASSERT(ob);
if (ob->form->fdui == colors_.dialog()) if (ob->form->fdui == colors_.dialog())
return colors_.feedback(ob); return colors_.feedback(ob);
@ -341,7 +340,7 @@ string const FormPreferences::getFeedback(FL_OBJECT * ob)
ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long) ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
{ {
Assert(ob); BOOST_ASSERT(ob);
bool valid = true; bool valid = true;

View File

@ -17,13 +17,10 @@
#include "debug.h" #include "debug.h"
#include "support/LAssert.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include "lyx_forms.h" #include "lyx_forms.h"
using namespace lyx::support;
using std::endl; using std::endl;
@ -31,7 +28,7 @@ void RadioButtonGroup::init(FL_OBJECT * ob, size_type value)
{ {
// Object must be a ROUND3DBUTTON (let all radio buttons look the same) // Object must be a ROUND3DBUTTON (let all radio buttons look the same)
// and of type RADIO_BUTTON (otherwise it ain't work). // and of type RADIO_BUTTON (otherwise it ain't work).
Assert(ob && ob->objclass == FL_ROUND3DBUTTON BOOST_ASSERT(ob && ob->objclass == FL_ROUND3DBUTTON
&& ob->type == FL_RADIO_BUTTON); && ob->type == FL_RADIO_BUTTON);
map.push_back(ButtonValuePair(ob, value)); map.push_back(ButtonValuePair(ob, value));

View File

@ -20,7 +20,6 @@
#include "xforms_helpers.h" // formatted #include "xforms_helpers.h" // formatted
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyx_forms.h" #include "lyx_forms.h"
@ -65,7 +64,7 @@ void Tooltips::set()
void Tooltips::init(FL_OBJECT * ob, string const & tip) void Tooltips::init(FL_OBJECT * ob, string const & tip)
{ {
Assert(ob && ob->form); BOOST_ASSERT(ob && ob->form);
// Store the tooltip string // Store the tooltip string
string const str = formatted(trim(tip), 400); string const str = formatted(trim(tip), 400);

View File

@ -20,7 +20,6 @@
#include "lyxfunc.h" #include "lyxfunc.h"
#include "MenuBackend.h" #include "MenuBackend.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h" #include "support/tostr.h"
@ -343,7 +342,7 @@ void XFormsMenubar::MenuCallback(FL_OBJECT * ob, long button)
} }
// Paranoia check // Paranoia check
Assert(item->kind() == MenuItem::Submenu); BOOST_ASSERT(item->kind() == MenuItem::Submenu);
// set tabstop length // set tabstop length
fl_set_tabstop(menu_tabstop); fl_set_tabstop(menu_tabstop);

View File

@ -15,7 +15,6 @@
#include "xforms_helpers.h" #include "xforms_helpers.h"
#include "lyxgluelength.h" #include "lyxgluelength.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyx_forms.h" #include "lyx_forms.h"
@ -66,7 +65,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label)
CheckedLyXLength::CheckedLyXLength(FL_OBJECT * input, FL_OBJECT * label) CheckedLyXLength::CheckedLyXLength(FL_OBJECT * input, FL_OBJECT * label)
: input_(input), label_(label ? label : input) : input_(input), label_(label ? label : input)
{ {
Assert(input && input->objclass == FL_INPUT); BOOST_ASSERT(input && input->objclass == FL_INPUT);
} }
@ -86,7 +85,7 @@ bool CheckedLyXLength::check() const
CheckedGlueLength::CheckedGlueLength(FL_OBJECT * input, FL_OBJECT * label) CheckedGlueLength::CheckedGlueLength(FL_OBJECT * input, FL_OBJECT * label)
: input_(input), label_(label ? label : input) : input_(input), label_(label ? label : input)
{ {
Assert(input && input->objclass == FL_INPUT); BOOST_ASSERT(input && input->objclass == FL_INPUT);
} }

View File

@ -15,7 +15,6 @@
#include "Color.h" #include "Color.h"
#include "format.h" #include "format.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxfunctional.h" // compare_memfun #include "support/lyxfunctional.h" // compare_memfun
#include "support/lyxlib.h" #include "support/lyxlib.h"
@ -376,7 +375,7 @@ extern "C" {
int status_report(FL_IMAGE * ob, const char *s) int status_report(FL_IMAGE * ob, const char *s)
{ {
Assert(ob && ob->u_vdata); BOOST_ASSERT(ob && ob->u_vdata);
string const str = s ? rtrim(s) : string(); string const str = s ? rtrim(s) : string();
if (str.empty()) if (str.empty())
@ -395,7 +394,7 @@ int status_report(FL_IMAGE * ob, const char *s)
static void error_report(FL_IMAGE * ob, const char *s) static void error_report(FL_IMAGE * ob, const char *s)
{ {
Assert(ob && ob->u_vdata); BOOST_ASSERT(ob && ob->u_vdata);
string const str = s ? rtrim(s) : string(); string const str = s ? rtrim(s) : string();
if (str.empty()) if (str.empty())

View File

@ -18,7 +18,6 @@
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lstrings.h" // frontStrip, strip #include "support/lstrings.h" // frontStrip, strip
#include "support/tostr.h" #include "support/tostr.h"
@ -100,7 +99,7 @@ vector<string> const getVector(FL_OBJECT * ob)
} }
break; break;
default: default:
Assert(0); BOOST_ASSERT(false);
} }
return vec; return vec;
@ -111,7 +110,7 @@ vector<string> const getVector(FL_OBJECT * ob)
string const getString(FL_OBJECT * ob, int line) string const getString(FL_OBJECT * ob, int line)
{ {
// Negative line value does not make sense. // Negative line value does not make sense.
Assert(line >= 0); BOOST_ASSERT(line >= 0);
char const * tmp = 0; char const * tmp = 0;
switch (ob->objclass) { switch (ob->objclass) {
@ -140,7 +139,7 @@ string const getString(FL_OBJECT * ob, int line)
break; break;
default: default:
Assert(0); BOOST_ASSERT(false);
} }
return tmp ? trim(tmp) : string(); return tmp ? trim(tmp) : string();
@ -149,7 +148,7 @@ string const getString(FL_OBJECT * ob, int line)
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice) string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice)
{ {
// Paranoia check // Paranoia check
Assert(input && input->objclass == FL_INPUT && BOOST_ASSERT(input && input->objclass == FL_INPUT &&
choice && choice->objclass == FL_CHOICE); choice && choice->objclass == FL_CHOICE);
string const length = trim(fl_get_input(input)); string const length = trim(fl_get_input(input));
@ -190,7 +189,7 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
string const & default_unit) string const & default_unit)
{ {
// Paranoia check // Paranoia check
Assert(input && input->objclass == FL_INPUT && BOOST_ASSERT(input && input->objclass == FL_INPUT &&
choice && choice->objclass == FL_CHOICE); choice && choice->objclass == FL_CHOICE);
if (len.empty()) { if (len.empty()) {

View File

@ -12,11 +12,12 @@
#include "xforms_resize.h" #include "xforms_resize.h"
#include "support/LAssert.h"
#include <boost/assert.hpp>
#include <algorithm> // std::max. Use FL_max in .c code... #include <algorithm> // std::max. Use FL_max in .c code...
#include "lyx_forms.h" #include "lyx_forms.h"
using namespace lyx::support;
namespace { namespace {
@ -95,7 +96,7 @@ double get_scaling_factor(FL_FORM * form)
double get_tabfolder_scale_to_fit(FL_OBJECT * folder) double get_tabfolder_scale_to_fit(FL_OBJECT * folder)
{ {
Assert(folder && folder->objclass == FL_TABFOLDER); BOOST_ASSERT(folder && folder->objclass == FL_TABFOLDER);
fl_freeze_form(folder->form); fl_freeze_form(folder->form);
int const saved_folder_id = fl_get_folder_number(folder); int const saved_folder_id = fl_get_folder_number(folder);
@ -117,7 +118,7 @@ double get_tabfolder_scale_to_fit(FL_OBJECT * folder)
void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor) void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor)
{ {
Assert(folder && folder->objclass == FL_TABFOLDER); BOOST_ASSERT(folder && folder->objclass == FL_TABFOLDER);
fl_freeze_form(folder->form); fl_freeze_form(folder->form);
int const saved_folder_id = fl_get_folder_number(folder); int const saved_folder_id = fl_get_folder_number(folder);
@ -138,7 +139,7 @@ void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor)
double get_scale_to_fit(FL_FORM * form) double get_scale_to_fit(FL_FORM * form)
{ {
Assert(form); BOOST_ASSERT(form);
double factor = get_scaling_factor(form); double factor = get_scaling_factor(form);
for (FL_OBJECT * ob = form->first; ob; ob = ob->next) { for (FL_OBJECT * ob = form->first; ob; ob = ob->next) {
@ -152,7 +153,7 @@ double get_scale_to_fit(FL_FORM * form)
void scale_form_horizontally(FL_FORM * form, double factor) void scale_form_horizontally(FL_FORM * form, double factor)
{ {
Assert(form); BOOST_ASSERT(form);
if (factor <= 1.0) if (factor <= 1.0)
return; return;

View File

@ -1,3 +1,8 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* GraphicsCacheItem.C: change Assert to BOOST_ASSERT
* Previews.C: ditto
2003-09-08 Angus Leeming <leeming@lyx.org> 2003-09-08 Angus Leeming <leeming@lyx.org>
* GraphicsImage.C: * GraphicsImage.C:

View File

@ -20,14 +20,12 @@
#include "support/filetools.h" #include "support/filetools.h"
#include "support/FileMonitor.h" #include "support/FileMonitor.h"
#include "support/LAssert.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include <boost/bind.hpp> #include <boost/bind.hpp>
namespace support = lyx::support; namespace support = lyx::support;
using support::Assert;
using support::ChangeExtension; using support::ChangeExtension;
using support::FileMonitor; using support::FileMonitor;
using support::IsFileReadable; using support::IsFileReadable;
@ -333,7 +331,7 @@ string const findTargetFormat(string const & from)
FormatList const formats = lyx::graphics::Image::loadableFormats(); FormatList const formats = lyx::graphics::Image::loadableFormats();
// There must be a format to load from. // There must be a format to load from.
Assert(!formats.empty()); BOOST_ASSERT(!formats.empty());
// First ascertain if we can load directly with no conversion // First ascertain if we can load directly with no conversion
FormatList::const_iterator it = formats.begin(); FormatList::const_iterator it = formats.begin();

View File

@ -18,10 +18,6 @@
#include "insets/inset.h" #include "insets/inset.h"
#include "support/LAssert.h"
namespace support = lyx::support;
namespace lyx { namespace lyx {
namespace graphics { namespace graphics {

View File

@ -1,3 +1,7 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* several files: change Assert to BOOST_ASSERT
2003-09-09 Martin Vermeer <martin.vermeer@hut.fi> 2003-09-09 Martin Vermeer <martin.vermeer@hut.fi>
* insettext.[Ch]: remove drawText[XY]Offset * insettext.[Ch]: remove drawText[XY]Offset

View File

@ -16,11 +16,12 @@
#include "lyxlex.h" #include "lyxlex.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/path.h" #include "support/path.h"
#include "support/path_defines.h" #include "support/path_defines.h"
#include <boost/assert.hpp>
#include <algorithm> #include <algorithm>
namespace support = lyx::support; namespace support = lyx::support;
@ -307,7 +308,7 @@ void ExternalTemplate::readTemplate(LyXLex & lex)
default: default:
lex.printError("ExternalTemplate::readTemplate: " lex.printError("ExternalTemplate::readTemplate: "
"Wrong tag: $$Token"); "Wrong tag: $$Token");
support::Assert(false); BOOST_ASSERT(false);
break; break;
} }
} }

View File

@ -26,7 +26,6 @@
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
@ -93,7 +92,7 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
else if (i2->lyxCode() == WRAP_CODE) else if (i2->lyxCode() == WRAP_CODE)
type = static_cast<InsetWrap *>(i2)->params().type; type = static_cast<InsetWrap *>(i2)->params().type;
else else
Assert(0); BOOST_ASSERT(false);
FloatList const & floats = FloatList const & floats =
pi.base.bv->buffer()->params().getLyXTextClass().floats(); pi.base.bv->buffer()->params().getLyXTextClass().floats();

View File

@ -27,9 +27,6 @@
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/LAssert.h"
using namespace lyx::support;
using namespace lyx::graphics; using namespace lyx::graphics;
using std::endl; using std::endl;
@ -140,7 +137,7 @@ void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
{ {
Assert(pi.base.bv); BOOST_ASSERT(pi.base.bv);
cache(pi.base.bv); cache(pi.base.bv);
Dimension dim_collapsed; Dimension dim_collapsed;

View File

@ -132,7 +132,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
switch (cmd.action) { switch (cmd.action) {
case LFUN_EXTERNAL_EDIT: { case LFUN_EXTERNAL_EDIT: {
support::Assert(cmd.view()); BOOST_ASSERT(cmd.view());
Buffer const & buffer = *cmd.view()->buffer(); Buffer const & buffer = *cmd.view()->buffer();
InsetExternal::Params p; InsetExternal::Params p;
@ -142,7 +142,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
} }
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {
support::Assert(cmd.view()); BOOST_ASSERT(cmd.view());
Buffer const & buffer = *cmd.view()->buffer(); Buffer const & buffer = *cmd.view()->buffer();
InsetExternal::Params p; InsetExternal::Params p;
@ -528,7 +528,7 @@ void InsetExternal::updateExternal(string const & format,
// Cannot proceed... // Cannot proceed...
if (!support::copy(from_file, temp_file)) if (!support::copy(from_file, temp_file))
return; return;
from_file = temp_file; from_file = temp_file;
} }

View File

@ -70,7 +70,6 @@ TODO
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // lyx::count #include "support/lyxalgo.h" // lyx::count
#include "support/lyxlib.h" // float_equal #include "support/lyxlib.h" // float_equal
#include "support/os.h" #include "support/os.h"
@ -342,7 +341,7 @@ copyToDirIfNeeded(string const & file_in, string const & dir)
{ {
using support::rtrim; using support::rtrim;
support::Assert(AbsolutePath(file_in)); BOOST_ASSERT(AbsolutePath(file_in));
string const only_path = support::OnlyPath(file_in); string const only_path = support::OnlyPath(file_in);
if (rtrim(support::OnlyPath(file_in) , "/") == rtrim(dir, "/")) if (rtrim(support::OnlyPath(file_in) , "/") == rtrim(dir, "/"))

View File

@ -27,7 +27,6 @@
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
using namespace lyx::support; using namespace lyx::support;
@ -257,7 +256,7 @@ int InsetQuotes::latex(Buffer const & buf, ostream & os,
{ {
// How do we get the local language here?? // How do we get the local language here??
lyx::pos_type curr_pos = ownerPar(buf, this).getPositionOfInset(this); lyx::pos_type curr_pos = ownerPar(buf, this).getPositionOfInset(this);
Assert(curr_pos != -1); BOOST_ASSERT(curr_pos != -1);
#warning FIXME. We _must_ find another way to get the language. (Lgb) #warning FIXME. We _must_ find another way to get the language. (Lgb)
#if 0 #if 0

View File

@ -34,8 +34,6 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
using namespace lyx::support; using namespace lyx::support;
@ -199,7 +197,7 @@ Buffer const & InsetTabular::buffer() const
BufferView * InsetTabular::view() const BufferView * InsetTabular::view() const
{ {
Assert(false); BOOST_ASSERT(false);
return 0; return 0;
} }
@ -245,7 +243,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
// mi.base.textwidth << "\n"; // mi.base.textwidth << "\n";
if (!mi.base.bv) { if (!mi.base.bv) {
lyxerr << "InsetTabular::metrics: need bv" << endl; lyxerr << "InsetTabular::metrics: need bv" << endl;
Assert(0); BOOST_ASSERT(false);
} }
calculate_dimensions_of_cells(mi); calculate_dimensions_of_cells(mi);
@ -361,7 +359,7 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int y,
void InsetTabular::drawCellSelection(Painter & pain, int x, int y, void InsetTabular::drawCellSelection(Painter & pain, int x, int y,
int row, int column, int cell) const int row, int column, int cell) const
{ {
Assert(hasSelection()); BOOST_ASSERT(hasSelection());
int cs = tabular.column_of_cell(sel_cell_start); int cs = tabular.column_of_cell(sel_cell_start);
int ce = tabular.column_of_cell(sel_cell_end); int ce = tabular.column_of_cell(sel_cell_end);
if (cs > ce) { if (cs > ce) {
@ -2400,7 +2398,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) const WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
{ {
// when entering this function the inset should be ALWAYS locked! // when entering this function the inset should be ALWAYS locked!
Assert(the_locking_inset); BOOST_ASSERT(the_locking_inset);
WordLangTuple word(the_locking_inset->selectNextWordToSpellcheck(bv, value)); WordLangTuple word(the_locking_inset->selectNextWordToSpellcheck(bv, value));
if (!word.word().empty()) if (!word.word().empty())

View File

@ -17,14 +17,10 @@
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/LAssert.h"
using namespace lyx::support;
void MailInset::showDialog(BufferView * bv) const void MailInset::showDialog(BufferView * bv) const
{ {
Assert(bv); BOOST_ASSERT(bv);
bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()), bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
&inset()); &inset());
} }
@ -32,7 +28,7 @@ void MailInset::showDialog(BufferView * bv) const
void MailInset::updateDialog(BufferView * bv) const void MailInset::updateDialog(BufferView * bv) const
{ {
Assert(bv); BOOST_ASSERT(bv);
if(bv->owner()->getDialogs().visible(name())) if(bv->owner()->getDialogs().visible(name()))
bv->owner()->getDialogs().update(name(), bv->owner()->getDialogs().update(name(),
inset2string(*bv->buffer())); inset2string(*bv->buffer()));

View File

@ -25,7 +25,6 @@
#include "graphics/GraphicsImage.h" #include "graphics/GraphicsImage.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h"
using namespace lyx::support; using namespace lyx::support;
@ -77,7 +76,7 @@ void ButtonRenderer::update(string const & text, bool editable)
void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
Assert(mi.base.bv); BOOST_ASSERT(mi.base.bv);
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
font.decSize(); font.decSize();
@ -93,7 +92,7 @@ void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const
void ButtonRenderer::draw(PainterInfo & pi, int x, int y) const void ButtonRenderer::draw(PainterInfo & pi, int x, int y) const
{ {
Assert(pi.base.bv); BOOST_ASSERT(pi.base.bv);
view_ = pi.base.bv->owner()->view(); view_ = pi.base.bv->owner()->view();
// Draw it as a box with the LaTeX text // Draw it as a box with the LaTeX text
@ -133,7 +132,7 @@ void GraphicRenderer::update(lyx::graphics::Params const & params)
params_ = params; params_ = params;
if (!params_.filename.empty()) { if (!params_.filename.empty()) {
Assert(AbsolutePath(params_.filename)); BOOST_ASSERT(AbsolutePath(params_.filename));
loader_.reset(params_.filename, params_); loader_.reset(params_.filename, params_);
} }
} }
@ -231,7 +230,7 @@ void GraphicRenderer::metrics(MetricsInfo & mi, Dimension & dim) const
void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const
{ {
Assert(pi.base.bv); BOOST_ASSERT(pi.base.bv);
view_ = pi.base.bv->owner()->view(); view_ = pi.base.bv->owner()->view();
#if 0 #if 0

View File

@ -67,7 +67,6 @@
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/forkedcontr.h" #include "support/forkedcontr.h"
#include "support/LAssert.h"
#include "support/path.h" #include "support/path.h"
#include "support/path_defines.h" #include "support/path_defines.h"
#include "support/tostr.h" #include "support/tostr.h"
@ -1466,7 +1465,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW); FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
inset->localDispatch(cmd); inset->localDispatch(cmd);
} }
} }
break; break;
case LFUN_DIALOG_UPDATE: { case LFUN_DIALOG_UPDATE: {
@ -1982,7 +1981,7 @@ string const LyXFunc::view_status_message()
BufferView * LyXFunc::view() const BufferView * LyXFunc::view() const
{ {
Assert(owner); BOOST_ASSERT(owner);
return owner->view().get(); return owner->view().get();
} }

View File

@ -18,12 +18,9 @@
#include "lyxtext.h" #include "lyxtext.h"
#include "paragraph.h" #include "paragraph.h"
#include "support/LAssert.h"
#include <boost/next_prior.hpp> #include <boost/next_prior.hpp>
using lyx::pos_type; using lyx::pos_type;
using lyx::support::Assert;
using std::max; using std::max;
using std::min; using std::min;
@ -38,7 +35,7 @@ bool isParEnd(Paragraph const & par, RowList::iterator rit)
lyxerr << "broken row 1: end: " << rit->end() << " next: " lyxerr << "broken row 1: end: " << rit->end() << " next: "
<< boost::next(rit)->pos() << endl; << boost::next(rit)->pos() << endl;
lyxerr << endl; lyxerr << endl;
Assert(false); BOOST_ASSERT(false);
} }
#endif #endif
return boost::next(rit) == par.rows.end(); return boost::next(rit) == par.rows.end();
@ -58,7 +55,7 @@ pos_type lastPos(Paragraph const & par, RowList::iterator rit)
lyxerr << "broken row 2: end: " << rit->end() << " next: " lyxerr << "broken row 2: end: " << rit->end() << " next: "
<< boost::next(rit)->pos() << endl; << boost::next(rit)->pos() << endl;
lyxerr << endl; lyxerr << endl;
Assert(false); BOOST_ASSERT(false);
} }
return boost::next(rit)->pos() - 1; return boost::next(rit)->pos() - 1;
} }

View File

@ -22,7 +22,6 @@
#include "FloatList.h" #include "FloatList.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -760,7 +759,7 @@ bool LyXTextClass::hasLayout(string const & n) const
LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const
{ {
Assert(!name.empty()); BOOST_ASSERT(!name.empty());
LayoutList::const_iterator cit = LayoutList::const_iterator cit =
find_if(layoutlist_.begin(), find_if(layoutlist_.begin(),
@ -776,7 +775,7 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const
lyxerr << " " << it->get()->name() << endl; lyxerr << " " << it->get()->name() << endl;
// we require the name to exist // we require the name to exist
Assert(false); BOOST_ASSERT(false);
} }
return (*cit); return (*cit);

View File

@ -13,7 +13,6 @@
#include "formulabase.h" #include "formulabase.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "support/LAssert.h"
#include "formula.h" #include "formula.h"
#include "formulamacro.h" #include "formulamacro.h"
#include "funcrequest.h" #include "funcrequest.h"
@ -712,7 +711,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
mathcursor->normalize(); mathcursor->normalize();
mathcursor->touch(); mathcursor->touch();
Assert(mathcursor); BOOST_ASSERT(mathcursor);
if (mathcursor->selection() || was_selection) if (mathcursor->selection() || was_selection)
toggleInsetSelection(bv); toggleInsetSelection(bv);

View File

@ -12,7 +12,6 @@
#include <config.h> #include <config.h>
#include "lyxrc.h" #include "lyxrc.h"
#include "support/LAssert.h"
#include "support/limited_stack.h" #include "support/limited_stack.h"
#include "debug.h" #include "debug.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
@ -35,8 +34,6 @@
//#define FILEDEBUG 1 //#define FILEDEBUG 1
using namespace lyx::support;
using std::endl; using std::endl;
using std::isalpha; using std::isalpha;
using std::min; using std::min;
@ -823,28 +820,28 @@ bool MathCursor::hasNextAtom() const
MathAtom const & MathCursor::prevAtom() const MathAtom const & MathCursor::prevAtom() const
{ {
Assert(pos() > 0); BOOST_ASSERT(pos() > 0);
return array()[pos() - 1]; return array()[pos() - 1];
} }
MathAtom & MathCursor::prevAtom() MathAtom & MathCursor::prevAtom()
{ {
Assert(pos() > 0); BOOST_ASSERT(pos() > 0);
return array()[pos() - 1]; return array()[pos() - 1];
} }
MathAtom const & MathCursor::nextAtom() const MathAtom const & MathCursor::nextAtom() const
{ {
Assert(pos() < size()); BOOST_ASSERT(pos() < size());
return array()[pos()]; return array()[pos()];
} }
MathAtom & MathCursor::nextAtom() MathAtom & MathCursor::nextAtom()
{ {
Assert(pos() < size()); BOOST_ASSERT(pos() < size());
return array()[pos()]; return array()[pos()];
} }
@ -910,14 +907,14 @@ void MathCursor::getSelection(CursorPos & i1, CursorPos & i2) const
CursorPos & MathCursor::cursor() CursorPos & MathCursor::cursor()
{ {
Assert(depth()); BOOST_ASSERT(depth());
return Cursor_.back(); return Cursor_.back();
} }
CursorPos const & MathCursor::cursor() const CursorPos const & MathCursor::cursor() const
{ {
Assert(depth()); BOOST_ASSERT(depth());
return Cursor_.back(); return Cursor_.back();
} }
@ -1392,7 +1389,7 @@ CursorPos MathCursor::normalAnchor() const
Anchor_ = Cursor_; Anchor_ = Cursor_;
lyxerr << "unusual Anchor size" << endl; lyxerr << "unusual Anchor size" << endl;
} }
//lyx::Assert(Anchor_.size() >= cursor.depth()); //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
// use Anchor on the same level as Cursor // use Anchor on the same level as Cursor
CursorPos normal = Anchor_[depth() - 1]; CursorPos normal = Anchor_[depth() - 1];
if (depth() < Anchor_.size() && !(normal < cursor())) { if (depth() < Anchor_.size() && !(normal < cursor())) {

View File

@ -18,11 +18,8 @@
#include "math_support.h" #include "math_support.h"
#include "math_replace.h" #include "math_replace.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
using namespace lyx::support;
using std::abs; using std::abs;
using std::endl; using std::endl;
using std::min; using std::min;
@ -47,14 +44,14 @@ void MathArray::substitute(MathMacro const & m)
MathAtom & MathArray::operator[](pos_type pos) MathAtom & MathArray::operator[](pos_type pos)
{ {
Assert(pos < size()); BOOST_ASSERT(pos < size());
return base_type::operator[](pos); return base_type::operator[](pos);
} }
MathAtom const & MathArray::operator[](pos_type pos) const MathAtom const & MathArray::operator[](pos_type pos) const
{ {
Assert(pos < size()); BOOST_ASSERT(pos < size());
return base_type::operator[](pos); return base_type::operator[](pos);
} }
@ -67,7 +64,7 @@ void MathArray::insert(size_type pos, MathAtom const & t)
void MathArray::insert(size_type pos, MathArray const & ar) void MathArray::insert(size_type pos, MathArray const & ar)
{ {
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
base_type::insert(begin() + pos, ar.begin(), ar.end()); base_type::insert(begin() + pos, ar.begin(), ar.end());
} }

View File

@ -22,7 +22,6 @@
#include "funcrequest.h" #include "funcrequest.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "support/LAssert.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "lyxrc.h" #include "lyxrc.h"
@ -263,7 +262,7 @@ void MathHullInset::drawT(TextPainter & pain, int x, int y) const
string MathHullInset::label(row_type row) const string MathHullInset::label(row_type row) const
{ {
row_type n = nrows(); row_type n = nrows();
Assert(row < n); BOOST_ASSERT(row < n);
return label_[row]; return label_[row];
} }
@ -672,8 +671,8 @@ void MathHullInset::infoize(std::ostream & os) const
void MathHullInset::check() const void MathHullInset::check() const
{ {
Assert(nonum_.size() == nrows()); BOOST_ASSERT(nonum_.size() == nrows());
Assert(label_.size() == nrows()); BOOST_ASSERT(label_.size() == nrows());
} }

View File

@ -12,9 +12,9 @@
#include "math_iterator.h" #include "math_iterator.h"
#include "math_inset.h" #include "math_inset.h"
#include "support/LAssert.h"
using namespace lyx::support; #include <boost/assert.hpp>
MathIterator::MathIterator() MathIterator::MathIterator()
{} {}
@ -56,7 +56,7 @@ void MathIterator::push(MathInset * p)
void MathIterator::pop() void MathIterator::pop()
{ {
//lyxerr << "pop: " << endl; //lyxerr << "pop: " << endl;
Assert(size()); BOOST_ASSERT(size());
pop_back(); pop_back();
} }
@ -124,8 +124,8 @@ void MathIterator::operator++()
void MathIterator::jump(difference_type i) void MathIterator::jump(difference_type i)
{ {
back().pos_ += i; back().pos_ += i;
//Assert(back().pos_ >= 0); //BOOST_ASSERT(back().pos_ >= 0);
Assert(back().pos_ <= cell().size()); BOOST_ASSERT(back().pos_ <= cell().size());
} }

View File

@ -721,7 +721,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
if (flags & FLAG_BRACE_LAST) if (flags & FLAG_BRACE_LAST)
return; return;
error("found '}' unexpectedly"); error("found '}' unexpectedly");
//lyx::Assert(0); //BOOST_ASSERT(false);
//add(cell, '}', LM_TC_TEX); //add(cell, '}', LM_TC_TEX);
} }

View File

@ -13,9 +13,8 @@
#include "math_pos.h" #include "math_pos.h"
#include "math_inset.h" #include "math_inset.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h"
using namespace lyx::support; #include <boost/assert.hpp>
using std::endl; using std::endl;
@ -28,21 +27,21 @@ CursorPos::CursorPos()
CursorPos::CursorPos(MathInset * p) CursorPos::CursorPos(MathInset * p)
: inset_(p), idx_(0), pos_(0) : inset_(p), idx_(0), pos_(0)
{ {
Assert(inset_); BOOST_ASSERT(inset_);
} }
MathArray & CursorPos::cell(MathArray::idx_type idx) const MathArray & CursorPos::cell(MathArray::idx_type idx) const
{ {
Assert(inset_); BOOST_ASSERT(inset_);
return inset_->cell(idx); return inset_->cell(idx);
} }
MathArray & CursorPos::cell() const MathArray & CursorPos::cell() const
{ {
Assert(inset_); BOOST_ASSERT(inset_);
return inset_->cell(idx_); return inset_->cell(idx_);
} }

View File

@ -17,9 +17,6 @@
#include "math_symbolinset.h" #include "math_symbolinset.h"
#include "debug.h" #include "debug.h"
#include "funcrequest.h" #include "funcrequest.h"
#include "support/LAssert.h"
using namespace lyx::support;
using std::max; using std::max;
using std::auto_ptr; using std::auto_ptr;
@ -159,14 +156,14 @@ int MathScriptInset::dy1() const
int MathScriptInset::dx0() const int MathScriptInset::dx0() const
{ {
Assert(hasDown()); BOOST_ASSERT(hasDown());
return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid(); return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid();
} }
int MathScriptInset::dx1() const int MathScriptInset::dx1() const
{ {
Assert(hasUp()); BOOST_ASSERT(hasUp());
return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid(); return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid();
} }

View File

@ -36,9 +36,7 @@
#include "insets/insetoptarg.h" #include "insets/insetoptarg.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h"
#include "support/textutils.h" #include "support/textutils.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
@ -294,14 +292,14 @@ bool Paragraph::insetAllowed(InsetOld::Code code)
InsetOld * Paragraph::getInset(pos_type pos) InsetOld * Paragraph::getInset(pos_type pos)
{ {
Assert(pos < size()); BOOST_ASSERT(pos < size());
return insetlist.get(pos); return insetlist.get(pos);
} }
InsetOld const * Paragraph::getInset(pos_type pos) const InsetOld const * Paragraph::getInset(pos_type pos) const
{ {
Assert(pos < size()); BOOST_ASSERT(pos < size());
return insetlist.get(pos); return insetlist.get(pos);
} }
@ -310,7 +308,7 @@ InsetOld const * Paragraph::getInset(pos_type pos) const
LyXFont const Paragraph::getFontSettings(BufferParams const & bparams, LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
pos_type pos) const pos_type pos) const
{ {
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin(); Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end(); Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
@ -330,7 +328,7 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
lyx::pos_type Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const lyx::pos_type Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const
{ {
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin(); Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end(); Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
@ -363,7 +361,7 @@ LyXFont const Paragraph::getFirstFontSettings() const
LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos, LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
LyXFont const & outerfont) const LyXFont const & outerfont) const
{ {
Assert(pos >= 0); BOOST_ASSERT(pos >= 0);
LyXLayout_ptr const & lout = layout(); LyXLayout_ptr const & lout = layout();
@ -485,7 +483,7 @@ Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
void Paragraph::setFont(pos_type pos, LyXFont const & font) void Paragraph::setFont(pos_type pos, LyXFont const & font)
{ {
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
// First, reduce font against layout/label font // First, reduce font against layout/label font
// Update: The SetCharFont() routine in text2.C already // Update: The SetCharFont() routine in text2.C already
@ -1208,14 +1206,14 @@ void Paragraph::cleanChanges()
Change::Type Paragraph::lookupChange(lyx::pos_type pos) const Change::Type Paragraph::lookupChange(lyx::pos_type pos) const
{ {
Assert(!size() || pos < size()); BOOST_ASSERT(!size() || pos < size());
return pimpl_->lookupChange(pos); return pimpl_->lookupChange(pos);
} }
Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const
{ {
Assert(!size() || pos < size()); BOOST_ASSERT(!size() || pos < size());
return pimpl_->lookupChangeFull(pos); return pimpl_->lookupChangeFull(pos);
} }

View File

@ -37,9 +37,7 @@
#include "insets/insetspecialchar.h" #include "insets/insetspecialchar.h"
#include "insets/insettabular.h" #include "insets/insettabular.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
using namespace lyx::support; using namespace lyx::support;
@ -1072,7 +1070,7 @@ ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
return pit.outerPar(); return pit.outerPar();
} }
lyxerr << "outerPar: should not happen" << endl; lyxerr << "outerPar: should not happen" << endl;
Assert(false); BOOST_ASSERT(false);
return const_cast<Buffer &>(buf).paragraphs().end(); // shut up compiler return const_cast<Buffer &>(buf).paragraphs().end(); // shut up compiler
} }
@ -1095,6 +1093,6 @@ Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
return *pit.pit(); return *pit.pit();
} }
lyxerr << "ownerPar: should not happen" << endl; lyxerr << "ownerPar: should not happen" << endl;
Assert(false); BOOST_ASSERT(false);
return buf.paragraphs().front(); // shut up compiler return buf.paragraphs().front(); // shut up compiler
} }

View File

@ -25,9 +25,6 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "texrow.h" #include "texrow.h"
#include "support/LAssert.h"
using namespace lyx::support;
using lyx::pos_type; using lyx::pos_type;
@ -177,7 +174,7 @@ Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const
void Paragraph::Pimpl::markErased() void Paragraph::Pimpl::markErased()
{ {
Assert(tracking()); BOOST_ASSERT(tracking());
// FIXME: we should actually remove INSERTED chars. // FIXME: we should actually remove INSERTED chars.
// difficult because owning insettexts/tabulars need // difficult because owning insettexts/tabulars need
@ -262,7 +259,7 @@ Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
// This is in the critical path for loading! // This is in the critical path for loading!
pos_type const siz = size(); pos_type const siz = size();
Assert(pos <= siz); BOOST_ASSERT(pos <= siz);
if (pos == siz) { if (pos == siz) {
lyxerr << "getChar() on pos " << pos << " in par id " lyxerr << "getChar() on pos " << pos << " in par id "
@ -273,7 +270,7 @@ Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
return text[pos]; return text[pos];
#else #else
Assert(pos < size()); BOOST_ASSERT(pos < size());
return text[pos]; return text[pos];
#endif #endif
} }
@ -289,7 +286,7 @@ void Paragraph::Pimpl::setChar(pos_type pos, value_type c)
void Paragraph::Pimpl::insertChar(pos_type pos, value_type c, void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
LyXFont const & font, Change change) LyXFont const & font, Change change)
{ {
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
if (tracking()) { if (tracking()) {
changes_->record(change, pos); changes_->record(change, pos);
@ -326,11 +323,11 @@ void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
void Paragraph::Pimpl::insertInset(pos_type pos, void Paragraph::Pimpl::insertInset(pos_type pos,
InsetOld * inset, LyXFont const & font, Change change) InsetOld * inset, LyXFont const & font, Change change)
{ {
Assert(inset); BOOST_ASSERT(inset);
Assert(pos <= size()); BOOST_ASSERT(pos <= size());
insertChar(pos, META_INSET, font, change); insertChar(pos, META_INSET, font, change);
Assert(text[pos] == META_INSET); BOOST_ASSERT(text[pos] == META_INSET);
// Add a new entry in the insetlist. // Add a new entry in the insetlist.
owner_->insetlist.insert(inset, pos); owner_->insetlist.insert(inset, pos);
@ -386,7 +383,7 @@ void Paragraph::Pimpl::eraseIntern(pos_type pos)
bool Paragraph::Pimpl::erase(pos_type pos) bool Paragraph::Pimpl::erase(pos_type pos)
{ {
Assert(pos < size()); BOOST_ASSERT(pos < size());
if (tracking()) { if (tracking()) {
Change::Type changetype(changes_->lookup(pos)); Change::Type changetype(changes_->lookup(pos));

View File

@ -13,7 +13,6 @@
#ifdef USE_PSPELL #ifdef USE_PSPELL
#include "support/LAssert.h"
#include "debug.h" #include "debug.h"
#define USE_ORIGINAL_MANAGER_FUNCS 1 #define USE_ORIGINAL_MANAGER_FUNCS 1
@ -96,14 +95,14 @@ enum PSpell::Result PSpell::check(WordLangTuple const & word)
PspellManager * m = it->second.manager; PspellManager * m = it->second.manager;
int word_ok = pspell_manager_check(m, word.word().c_str()); int word_ok = pspell_manager_check(m, word.word().c_str());
Assert(word_ok != -1); BOOST_ASSERT(word_ok != -1);
if (word_ok) { if (word_ok) {
res = OK; res = OK;
} else { } else {
PspellWordList const * sugs = PspellWordList const * sugs =
pspell_manager_suggest(m, word.word().c_str()); pspell_manager_suggest(m, word.word().c_str());
Assert(sugs != 0); BOOST_ASSERT(sugs != 0);
els = pspell_word_list_elements(sugs); els = pspell_word_list_elements(sugs);
if (pspell_word_list_empty(sugs)) if (pspell_word_list_empty(sugs))
res = UNKNOWN; res = UNKNOWN;

View File

@ -32,10 +32,8 @@
#include "insets/insettext.h" #include "insets/insettext.h"
#include "support/LAssert.h"
#include "support/textutils.h" #include "support/textutils.h"
using namespace lyx::support;
using std::max; using std::max;
using lyx::pos_type; using lyx::pos_type;
@ -178,7 +176,7 @@ void RowPainter::paintInset(pos_type const pos)
{ {
InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos)); InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos));
Assert(inset); BOOST_ASSERT(inset);
PainterInfo pi(perv(bv_)); PainterInfo pi(perv(bv_));
pi.base.font = getFont(pos); pi.base.font = getFont(pos);

View File

@ -1,3 +1,12 @@
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* Makefile.am (libsupport_la_SOURCES): remove LAssert.C and LAssert.h
* several files: change Assert to BOOST_ASSERT
* LAssert.C:
* LAssert.h: remove files
2003-09-08 Angus Leeming <leeming@lyx.org> 2003-09-08 Angus Leeming <leeming@lyx.org>
* filename.C: * filename.C:

View File

@ -10,9 +10,11 @@
#include <config.h> #include <config.h>
#include <cerrno>
#include "FileInfo.h" #include "FileInfo.h"
#include "LAssert.h"
#include <boost/assert.hpp>
#include <cerrno>
#if !S_IRUSR #if !S_IRUSR
# if S_IREAD # if S_IREAD
@ -207,7 +209,7 @@ FileInfo & FileInfo::newFile(int fildes)
// should not be in FileInfo // should not be in FileInfo
char FileInfo::typeIndicator() const char FileInfo::typeIndicator() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
if (S_ISDIR(buf_.st_mode)) if (S_ISDIR(buf_.st_mode))
return '/'; return '/';
#ifdef S_ISLNK #ifdef S_ISLNK
@ -230,7 +232,7 @@ char FileInfo::typeIndicator() const
mode_t FileInfo::getMode() const mode_t FileInfo::getMode() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_mode; return buf_.st_mode;
} }
@ -238,7 +240,7 @@ mode_t FileInfo::getMode() const
// should not be in FileInfo // should not be in FileInfo
string FileInfo::modeString() const string FileInfo::modeString() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
char str[11]; char str[11];
str[0] = typeLetter(buf_.st_mode); str[0] = typeLetter(buf_.st_mode);
flagRWX((buf_.st_mode & 0700) << 0, &str[1]); flagRWX((buf_.st_mode & 0700) << 0, &str[1]);
@ -253,49 +255,49 @@ string FileInfo::modeString() const
time_t FileInfo::getModificationTime() const time_t FileInfo::getModificationTime() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_mtime; return buf_.st_mtime;
} }
time_t FileInfo::getAccessTime() const time_t FileInfo::getAccessTime() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_atime; return buf_.st_atime;
} }
time_t FileInfo::getStatusChangeTime() const time_t FileInfo::getStatusChangeTime() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_ctime; return buf_.st_ctime;
} }
nlink_t FileInfo::getNumberOfLinks() const nlink_t FileInfo::getNumberOfLinks() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_nlink; return buf_.st_nlink;
} }
uid_t FileInfo::getUid() const uid_t FileInfo::getUid() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_uid; return buf_.st_uid;
} }
gid_t FileInfo::getGid() const gid_t FileInfo::getGid() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_gid; return buf_.st_gid;
} }
off_t FileInfo::getSize() const off_t FileInfo::getSize() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return buf_.st_size; return buf_.st_size;
} }
@ -314,49 +316,49 @@ bool FileInfo::isOK() const
bool FileInfo::isLink() const bool FileInfo::isLink() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISLNK(buf_.st_mode); return S_ISLNK(buf_.st_mode);
} }
bool FileInfo::isRegular() const bool FileInfo::isRegular() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISREG(buf_.st_mode); return S_ISREG(buf_.st_mode);
} }
bool FileInfo::isDir() const bool FileInfo::isDir() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISDIR(buf_.st_mode); return S_ISDIR(buf_.st_mode);
} }
bool FileInfo::isChar() const bool FileInfo::isChar() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISCHR(buf_.st_mode); return S_ISCHR(buf_.st_mode);
} }
bool FileInfo::isBlock() const bool FileInfo::isBlock() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISBLK(buf_.st_mode); return S_ISBLK(buf_.st_mode);
} }
bool FileInfo::isFifo() const bool FileInfo::isFifo() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
return S_ISFIFO(buf_.st_mode); return S_ISFIFO(buf_.st_mode);
} }
bool FileInfo::isSocket() const bool FileInfo::isSocket() const
{ {
Assert(isOK()); BOOST_ASSERT(isOK());
#ifdef S_ISSOCK #ifdef S_ISSOCK
return S_ISSOCK(buf_.st_mode); return S_ISSOCK(buf_.st_mode);
#else #else

View File

@ -1,49 +0,0 @@
/**
* \file LAssert.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "LAssert.h"
#include "support/lyxlib.h"
#ifdef ENABLE_ASSERTIONS
#include "lyx_main.h"
#include "errorlist.h"
namespace lyx {
namespace support {
namespace {
void emergencyCleanup()
{
static bool didCleanup;
if (didCleanup)
return;
didCleanup = true;
LyX::emergencyCleanup();
}
} // namespace anon
void Assert(bool assertion)
{
if (!assertion) {
emergencyCleanup();
lyx::support::abort();
}
}
} // namespace support
} // namespace lyx
#endif

View File

@ -1,40 +0,0 @@
// -*- C++ -*-
/**
* \file LAssert.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LASSERT_H
#define LASSERT_H
namespace lyx {
namespace support {
#ifdef ENABLE_ASSERTIONS
/** Live assertion.
This is a debug tool to ensure that the assertion holds. If it don't hole
we run #emergencyCleanup()# and then #lyx::abort".
@param assertion this should evaluate to true unless you want an abort.
*/
void Assert(bool assertion);
#else
/** Dummy assertion.
When compiling without assertions we use this no-op function.
*/
inline
void Assert(bool /*assertion*/) {}
#endif /* ENABLE_ASSERTIONS */
} // namespace support
} // namespace lyx
#endif /* LASSERT_H */

View File

@ -27,8 +27,6 @@ libsupport_la_SOURCES = \
FileInfo.h \ FileInfo.h \
FileMonitor.h \ FileMonitor.h \
FileMonitor.C \ FileMonitor.C \
LAssert.C \
LAssert.h \
abort.C \ abort.C \
atoi.C \ atoi.C \
boost-inst.C \ boost-inst.C \

View File

@ -12,11 +12,12 @@
#include "filename.h" #include "filename.h"
#include "LAssert.h"
#include "filetools.h" #include "filetools.h"
#include "lstrings.h" #include "lstrings.h"
#include "os.h" #include "os.h"
#include <boost/assert.hpp>
namespace lyx { namespace lyx {
namespace support { namespace support {
@ -30,7 +31,7 @@ FileName::FileName()
FileName::FileName(string const & abs_filename, bool save_abs) FileName::FileName(string const & abs_filename, bool save_abs)
: name_(abs_filename), save_abs_path_(save_abs) : name_(abs_filename), save_abs_path_(save_abs)
{ {
Assert(AbsolutePath(name_)); BOOST_ASSERT(AbsolutePath(name_));
} }

View File

@ -24,7 +24,6 @@
#include "debug.h" #include "debug.h"
#include "support/tostr.h" #include "support/tostr.h"
#include "support/systemcall.h" #include "support/systemcall.h"
#include "support/LAssert.h"
#include "filetools.h" #include "filetools.h"
#include "lstrings.h" #include "lstrings.h"
@ -37,7 +36,9 @@
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include <boost/assert.hpp>
#include <boost/cregex.hpp> #include <boost/cregex.hpp>
#include <cctype> #include <cctype>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
@ -514,7 +515,7 @@ bool createDirectory(string const & path, int permission)
{ {
string temp(rtrim(os::slashify_path(path), "/")); string temp(rtrim(os::slashify_path(path), "/"));
Assert(!temp.empty()); BOOST_ASSERT(!temp.empty());
if (mkdir(temp, permission)) if (mkdir(temp, permission))
return false; return false;
@ -1343,7 +1344,7 @@ string const readBB_from_PSFile(string const & file)
int compare_timestamps(string const & file1, string const & file2) int compare_timestamps(string const & file1, string const & file2)
{ {
Assert(AbsolutePath(file1) && AbsolutePath(file2)); BOOST_ASSERT(AbsolutePath(file1) && AbsolutePath(file2));
// If the original is newer than the copy, then copy the original // If the original is newer than the copy, then copy the original
// to the new directory. // to the new directory.

View File

@ -13,7 +13,6 @@
#include "support/std_string.h" #include "support/std_string.h"
#include "lstrings.h" #include "lstrings.h"
#include "LAssert.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "debug.h" #include "debug.h"
#include "BoostFormat.h" #include "BoostFormat.h"
@ -434,7 +433,7 @@ string const subst(string const & a,
string const trim(string const & a, char const * p) string const trim(string const & a, char const * p)
{ {
Assert(p); BOOST_ASSERT(p);
if (a.empty() || !*p) if (a.empty() || !*p)
return a; return a;
@ -452,7 +451,7 @@ string const trim(string const & a, char const * p)
string const rtrim(string const & a, char const * p) string const rtrim(string const & a, char const * p)
{ {
Assert(p); BOOST_ASSERT(p);
if (a.empty() || !*p) if (a.empty() || !*p)
return a; return a;
@ -469,7 +468,7 @@ string const rtrim(string const & a, char const * p)
string const ltrim(string const & a, char const * p) string const ltrim(string const & a, char const * p)
{ {
Assert(p); BOOST_ASSERT(p);
if (a.empty() || !*p) if (a.empty() || !*p)
return a; return a;
@ -662,7 +661,7 @@ string bformat(string const & fmt, string const & arg1, string const & arg2,
string bformat(string const & fmt, string const & arg1) string bformat(string const & fmt, string const & arg1)
{ {
Assert(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%1$s"));
string const str = subst(fmt, "%1$s", arg1); string const str = subst(fmt, "%1$s", arg1);
return subst(str, "%%", "%"); return subst(str, "%%", "%");
} }
@ -670,8 +669,8 @@ string bformat(string const & fmt, string const & arg1)
string bformat(string const & fmt, string const & arg1, string const & arg2) string bformat(string const & fmt, string const & arg1, string const & arg2)
{ {
Assert(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%1$s"));
Assert(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%2$s"));
string str = subst(fmt, "%1$s", arg1); string str = subst(fmt, "%1$s", arg1);
str = subst(str, "%2$s", arg2); str = subst(str, "%2$s", arg2);
return subst(str, "%%", "%"); return subst(str, "%%", "%");
@ -680,8 +679,8 @@ string bformat(string const & fmt, string const & arg1, string const & arg2)
string bformat(string const & fmt, int arg1, int arg2) string bformat(string const & fmt, int arg1, int arg2)
{ {
Assert(contains(fmt, "%1$d")); BOOST_ASSERT(contains(fmt, "%1$d"));
Assert(contains(fmt, "%2$d")); BOOST_ASSERT(contains(fmt, "%2$d"));
string str = subst(fmt, "%1$d", tostr(arg1)); string str = subst(fmt, "%1$d", tostr(arg1));
str = subst(str, "%2$d", tostr(arg2)); str = subst(str, "%2$d", tostr(arg2));
return subst(str, "%%", "%"); return subst(str, "%%", "%");
@ -691,9 +690,9 @@ string bformat(string const & fmt, int arg1, int arg2)
string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1, string const & arg2,
string const & arg3) string const & arg3)
{ {
Assert(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%1$s"));
Assert(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%2$s"));
Assert(contains(fmt, "%3$s")); BOOST_ASSERT(contains(fmt, "%3$s"));
string str = subst(fmt, "%1$s", arg1); string str = subst(fmt, "%1$s", arg1);
str = subst(str, "%2$s", arg2); str = subst(str, "%2$s", arg2);
str = subst(str, "%3$s", arg3); str = subst(str, "%3$s", arg3);
@ -704,10 +703,10 @@ string bformat(string const & fmt, string const & arg1, string const & arg2,
string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1, string const & arg2,
string const & arg3, string const & arg4) string const & arg3, string const & arg4)
{ {
Assert(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%1$s"));
Assert(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%2$s"));
Assert(contains(fmt, "%3$s")); BOOST_ASSERT(contains(fmt, "%3$s"));
Assert(contains(fmt, "%4$s")); BOOST_ASSERT(contains(fmt, "%4$s"));
string str = subst(fmt, "%1$s", arg1); string str = subst(fmt, "%1$s", arg1);
str = subst(str, "%2$s", arg2); str = subst(str, "%2$s", arg2);
str = subst(str, "%3$s", arg3); str = subst(str, "%3$s", arg3);
@ -719,11 +718,11 @@ string bformat(string const & fmt, string const & arg1, string const & arg2,
string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1, string const & arg2,
string const & arg3, string const & arg4, string const & arg5) string const & arg3, string const & arg4, string const & arg5)
{ {
Assert(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%1$s"));
Assert(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%2$s"));
Assert(contains(fmt, "%3$s")); BOOST_ASSERT(contains(fmt, "%3$s"));
Assert(contains(fmt, "%4$s")); BOOST_ASSERT(contains(fmt, "%4$s"));
Assert(contains(fmt, "%5$s")); BOOST_ASSERT(contains(fmt, "%5$s"));
string str = subst(fmt, "%1$s", arg1); string str = subst(fmt, "%1$s", arg1);
str = subst(str, "%2$s", arg2); str = subst(str, "%2$s", arg2);
str = subst(str, "%3$s", arg3); str = subst(str, "%3$s", arg3);

View File

@ -14,8 +14,6 @@
#include "lyxstring.h" #include "lyxstring.h"
#include "LAssert.h"
#include "debug.h" #include "debug.h"
#include <iostream> #include <iostream>
@ -63,7 +61,7 @@ using std::ostream;
namespace lyx { namespace lyx {
using support::Assert; using support::BOOST_ASSERT;
/////////////////////////////////////// ///////////////////////////////////////
// The internal string representation // The internal string representation
@ -375,13 +373,13 @@ void stringInvariant::helper() const
// test every last little thing we *know* should be true. // test every last little thing we *know* should be true.
// I may have missed a test or two, so feel free to fill // I may have missed a test or two, so feel free to fill
// in the gaps. ARRae. // in the gaps. ARRae.
Assert(object); BOOST_ASSERT(object);
Assert(object->rep); BOOST_ASSERT(object->rep);
Assert(object->rep->s); // s is never 0 BOOST_ASSERT(object->rep->s); // s is never 0
Assert(object->rep->res); // res cannot be 0 BOOST_ASSERT(object->rep->res); // res cannot be 0
Assert(object->rep->sz <= object->rep->res); BOOST_ASSERT(object->rep->sz <= object->rep->res);
Assert(object->rep->ref >= 1); // its in use so it must be referenced BOOST_ASSERT(object->rep->ref >= 1); // its in use so it must be referenced
Assert(object->rep->ref < 1UL << (8UL * sizeof(object->rep->ref) - 1)); BOOST_ASSERT(object->rep->ref < 1UL << (8UL * sizeof(object->rep->ref) - 1));
// if it does ever == then we should be generating a new copy // if it does ever == then we should be generating a new copy
// and starting again. (Is char always 8-bits?) // and starting again. (Is char always 8-bits?)
} }
@ -409,7 +407,7 @@ string::string()
string::string(string const & x, size_type pos, size_type n) string::string(string const & x, size_type pos, size_type n)
{ {
Assert(pos <= x.rep->sz); // STD! BOOST_ASSERT(pos <= x.rep->sz); // STD!
if (pos == 0 && n >= x.length()) { // this is the default if (pos == 0 && n >= x.length()) { // this is the default
x.rep->ref++; x.rep->ref++;
rep = x.rep; rep = x.rep;
@ -421,7 +419,7 @@ string::string(string const & x, size_type pos, size_type n)
string::string(value_type const * s, size_type n) string::string(value_type const * s, size_type n)
{ {
Assert(s && n < npos); // STD! BOOST_ASSERT(s && n < npos); // STD!
static Srep empty_rep(0, ""); static Srep empty_rep(0, "");
if (n) { // n > 0 if (n) { // n > 0
rep = new Srep(n, s); rep = new Srep(n, s);
@ -434,7 +432,7 @@ string::string(value_type const * s, size_type n)
string::string(value_type const * s) string::string(value_type const * s)
{ {
Assert(s); // STD! BOOST_ASSERT(s); // STD!
static Srep empty_rep(0, ""); static Srep empty_rep(0, "");
if (*s) { // s is not empty string if (*s) { // s is not empty string
rep = new Srep(strlen(s), s); rep = new Srep(strlen(s), s);
@ -447,7 +445,7 @@ string::string(value_type const * s)
string::string(size_type n, value_type c) string::string(size_type n, value_type c)
{ {
Assert(n < npos); // STD! BOOST_ASSERT(n < npos); // STD!
rep = new Srep(n, c); rep = new Srep(n, c);
} }
@ -534,7 +532,7 @@ string::size_type string::size() const
void string::resize(size_type n, value_type c) void string::resize(size_type n, value_type c)
{ {
Assert(n <= npos); // STD! BOOST_ASSERT(n <= npos); // STD!
TeststringInvariant(this); TeststringInvariant(this);
// This resets sz to res_arg // This resets sz to res_arg
@ -572,7 +570,7 @@ string & string::operator=(string const & x)
string & string::operator=(value_type const * s) string & string::operator=(value_type const * s)
{ {
Assert(s); // OURS! BOOST_ASSERT(s); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
// printf("string::operator= (value_type const *)\n"); // printf("string::operator= (value_type const *)\n");
@ -609,7 +607,7 @@ string & string::assign(string const & x)
string & string::assign(string const & x, size_type pos, size_type n) string & string::assign(string const & x, size_type pos, size_type n)
{ {
Assert(pos <= x.rep->sz); // STD! BOOST_ASSERT(pos <= x.rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
return assign(x.substr(pos, n)); return assign(x.substr(pos, n));
@ -618,7 +616,7 @@ string & string::assign(string const & x, size_type pos, size_type n)
string & string::assign(value_type const * s, size_type n) string & string::assign(value_type const * s, size_type n)
{ {
Assert(s && n < npos); // STD! BOOST_ASSERT(s && n < npos); // STD!
TeststringInvariant(this); TeststringInvariant(this);
if (rep->ref == 1) // recycle rep if (rep->ref == 1) // recycle rep
@ -633,7 +631,7 @@ string & string::assign(value_type const * s, size_type n)
string & string::assign(value_type const * s) string & string::assign(value_type const * s)
{ {
Assert(s); // OURS! BOOST_ASSERT(s); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return assign(s, strlen(s)); return assign(s, strlen(s));
@ -668,13 +666,13 @@ string::const_reference string::operator[](size_type pos) const
{ {
#if 0 #if 0
// This is actually what the standard requires, // This is actually what the standard requires,
Assert(pos <= rep->sz); // OURS! BOOST_ASSERT(pos <= rep->sz); // OURS!
static char const helper = '\0'; static char const helper = '\0';
return pos == rep->sz ? helper : rep->s[pos]; return pos == rep->sz ? helper : rep->s[pos];
#else #else
// but we use this one since it is stricter // but we use this one since it is stricter
// and more according to the real intent of std::string. // and more according to the real intent of std::string.
Assert(pos < rep->sz); // OURS! BOOST_ASSERT(pos < rep->sz); // OURS!
return rep->s[pos]; return rep->s[pos];
#endif #endif
} }
@ -682,7 +680,7 @@ string::const_reference string::operator[](size_type pos) const
string::reference string::operator[](size_type pos) string::reference string::operator[](size_type pos)
{ {
Assert(pos < rep->sz); // OURS! BOOST_ASSERT(pos < rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -692,14 +690,14 @@ string::reference string::operator[](size_type pos)
string::const_reference string::at(size_type n) const string::const_reference string::at(size_type n) const
{ {
Assert(n < rep->sz); // STD! BOOST_ASSERT(n < rep->sz); // STD!
return rep->s[n]; return rep->s[n];
} }
string::reference string::at(size_type n) string::reference string::at(size_type n)
{ {
Assert(n < rep->sz); // STD! BOOST_ASSERT(n < rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -721,7 +719,7 @@ string & string::operator+=(string const & x)
string & string::operator+=(value_type const * x) string & string::operator+=(value_type const * x)
{ {
Assert(x); // OURS! BOOST_ASSERT(x); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return append(x); return append(x);
@ -759,7 +757,7 @@ string & string::append(string const & x)
string & string::append(string const & x, size_type pos, size_type n) string & string::append(string const & x, size_type pos, size_type n)
{ {
Assert(pos <= x.rep->sz); // STD! BOOST_ASSERT(pos <= x.rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
return append(x.substr(pos, n)); return append(x.substr(pos, n));
@ -768,7 +766,7 @@ string & string::append(string const & x, size_type pos, size_type n)
string & string::append(value_type const * p, size_type n) string & string::append(value_type const * p, size_type n)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (!*p || !n) return *this; if (!*p || !n) return *this;
@ -780,7 +778,7 @@ string & string::append(value_type const * p, size_type n)
string & string::append(value_type const * p) string & string::append(value_type const * p)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
return append(p, strlen(p)); return append(p, strlen(p));
} }
@ -820,7 +818,7 @@ string & string::insert(size_type pos, string const & x)
string & string::insert(size_type pos, string const & x, string & string::insert(size_type pos, string const & x,
size_type pos2, size_type n) size_type pos2, size_type n)
{ {
Assert(pos <= rep->sz && pos2 <= x.rep->sz); // STD! BOOST_ASSERT(pos <= rep->sz && pos2 <= x.rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -831,7 +829,7 @@ string & string::insert(size_type pos, string const & x,
string & string::insert(size_type pos, value_type const * p, size_type n) string & string::insert(size_type pos, value_type const * p, size_type n)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (*p && n) { if (*p && n) {
@ -845,7 +843,7 @@ string & string::insert(size_type pos, value_type const * p, size_type n)
string & string::insert(size_type pos, value_type const * p) string & string::insert(size_type pos, value_type const * p)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
return insert(pos, p, strlen(p)); return insert(pos, p, strlen(p));
} }
@ -928,7 +926,7 @@ string::size_type string::find(string const & a, size_type i) const
string::size_type string::find(value_type const * ptr, size_type i, string::size_type string::find(value_type const * ptr, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
if (!rep->sz || !*ptr || i >= rep->sz) return npos; if (!rep->sz || !*ptr || i >= rep->sz) return npos;
TeststringInvariant(this); TeststringInvariant(this);
@ -959,7 +957,7 @@ string::size_type string::find(value_type const * ptr, size_type i,
string::size_type string::find(value_type const * s, size_type i) const string::size_type string::find(value_type const * s, size_type i) const
{ {
Assert(s); // OURS! BOOST_ASSERT(s); // OURS!
if (!rep->sz || i >= rep->sz) return npos; if (!rep->sz || i >= rep->sz) return npos;
TeststringInvariant(this); TeststringInvariant(this);
@ -1011,7 +1009,7 @@ string::size_type string::rfind(string const & a, size_type i) const
string::size_type string::rfind(value_type const * ptr, size_type i, string::size_type string::rfind(value_type const * ptr, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
n = min(n, strlen(ptr)); n = min(n, strlen(ptr));
@ -1039,7 +1037,7 @@ string::size_type string::rfind(value_type const * ptr, size_type i,
string::size_type string::rfind(value_type const * ptr, string::size_type string::rfind(value_type const * ptr,
size_type i) const size_type i) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
if (!ptr || !*ptr) return npos; if (!ptr || !*ptr) return npos;
return rfind(ptr, i, strlen(ptr)); return rfind(ptr, i, strlen(ptr));
@ -1063,7 +1061,7 @@ string::size_type string::rfind(value_type c, size_type i) const
string::size_type string::find_first_of(string const & a, string::size_type string::find_first_of(string const & a,
size_type i) const size_type i) const
{ {
Assert(i <= rep->sz); // OURS! BOOST_ASSERT(i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
@ -1077,7 +1075,7 @@ string::size_type string::find_first_of(value_type const * ptr,
size_type i, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr && i <= rep->sz); // OURS! BOOST_ASSERT(ptr && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (!n) return npos; if (!n) return npos;
@ -1091,7 +1089,7 @@ string::size_type string::find_first_of(value_type const * ptr,
string::size_type string::find_first_of(value_type const * ptr, string::size_type string::find_first_of(value_type const * ptr,
size_type i) const size_type i) const
{ {
Assert(ptr && i <= rep->sz); // OURS! BOOST_ASSERT(ptr && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
@ -1103,7 +1101,7 @@ string::size_type string::find_first_of(value_type const * ptr,
string::size_type string::find_first_of(value_type c, size_type i) const string::size_type string::find_first_of(value_type c, size_type i) const
{ {
Assert(i <= rep->sz); // OURS! BOOST_ASSERT(i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
@ -1130,7 +1128,7 @@ string::size_type string::find_last_of(value_type const * ptr,
size_type i, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (!n) return npos; if (!n) return npos;
@ -1145,7 +1143,7 @@ string::size_type string::find_last_of(value_type const * ptr,
string::size_type string::find_last_of(value_type const * ptr, string::size_type string::find_last_of(value_type const * ptr,
size_type i) const size_type i) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
size_type ii = min(rep->sz - 1, i); size_type ii = min(rep->sz - 1, i);
@ -1175,7 +1173,7 @@ string::size_type string::find_first_not_of(string const & a,
TeststringInvariant(this); TeststringInvariant(this);
if (!rep->sz) return npos; if (!rep->sz) return npos;
Assert(i <= rep->sz); BOOST_ASSERT(i <= rep->sz);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
if (a.find(rep->s[t]) == npos) return t; if (a.find(rep->s[t]) == npos) return t;
} }
@ -1187,7 +1185,7 @@ string::size_type string::find_first_not_of(value_type const * ptr,
size_type i, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr && i <= rep->sz); // OURS! BOOST_ASSERT(ptr && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (!n) return (i < rep->sz) ? i : npos; if (!n) return (i < rep->sz) ? i : npos;
@ -1201,7 +1199,7 @@ string::size_type string::find_first_not_of(value_type const * ptr,
string::size_type string::find_first_not_of(value_type const * ptr, string::size_type string::find_first_not_of(value_type const * ptr,
size_type i) const size_type i) const
{ {
Assert(ptr && i <= rep->sz); // OURS! BOOST_ASSERT(ptr && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
@ -1215,7 +1213,7 @@ string::size_type string::find_first_not_of(value_type c,
size_type i) const size_type i) const
{ {
if (!rep->sz) return npos; if (!rep->sz) return npos;
Assert(i <= rep->sz); // OURS! BOOST_ASSERT(i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
for (size_type t = i; t < rep->sz; ++t) { for (size_type t = i; t < rep->sz; ++t) {
@ -1242,7 +1240,7 @@ string::size_type string::find_last_not_of(value_type const * ptr,
size_type i, size_type i,
size_type n) const size_type n) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
if (!n) return npos; if (!n) return npos;
@ -1258,7 +1256,7 @@ string::size_type string::find_last_not_of(value_type const * ptr,
string::size_type string::find_last_not_of(value_type const * ptr, string::size_type string::find_last_not_of(value_type const * ptr,
size_type i) const size_type i) const
{ {
Assert(ptr); // OURS! BOOST_ASSERT(ptr); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
size_type ii = min(rep->sz - 1, i); size_type ii = min(rep->sz - 1, i);
@ -1288,7 +1286,7 @@ string::size_type string::find_last_not_of(value_type c,
string & string::replace(size_type i, size_type n, string const & x) string & string::replace(size_type i, size_type n, string const & x)
{ {
Assert(i <= rep->sz); // OURS! BOOST_ASSERT(i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return replace(i, n, x, 0, x.rep->sz); return replace(i, n, x, 0, x.rep->sz);
@ -1298,7 +1296,7 @@ string & string::replace(size_type i, size_type n, string const & x)
string & string::replace(size_type i, size_type n, string const & x, string & string::replace(size_type i, size_type n, string const & x,
size_type i2, size_type n2) size_type i2, size_type n2)
{ {
Assert(i <= rep->sz && i2 <= x.rep->sz); // STD! BOOST_ASSERT(i <= rep->sz && i2 <= x.rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -1310,7 +1308,7 @@ string & string::replace(size_type i, size_type n, string const & x,
string & string::replace(size_type i, size_type n, string & string::replace(size_type i, size_type n,
value_type const * p, size_type n2) value_type const * p, size_type n2)
{ {
Assert(p && i <= rep->sz); // OURS! BOOST_ASSERT(p && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -1321,7 +1319,7 @@ string & string::replace(size_type i, size_type n,
string & string::replace(size_type i, size_type n, value_type const * p) string & string::replace(size_type i, size_type n, value_type const * p)
{ {
Assert(p && i <= rep->sz); // OURS! BOOST_ASSERT(p && i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return replace(i, min(n, rep->sz), p, (!p) ? 0 : strlen(p)); return replace(i, min(n, rep->sz), p, (!p) ? 0 : strlen(p));
@ -1331,7 +1329,7 @@ string & string::replace(size_type i, size_type n, value_type const * p)
string & string::replace(size_type i, size_type n, string & string::replace(size_type i, size_type n,
size_type n2, value_type c) size_type n2, value_type c)
{ {
Assert(i <= rep->sz); // OURS! BOOST_ASSERT(i <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -1361,7 +1359,7 @@ string & string::replace(iterator i, iterator i2, const string & str)
string & string::replace(iterator i, iterator i2, string & string::replace(iterator i, iterator i2,
value_type const * p, size_type n) value_type const * p, size_type n)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return replace(i - begin(), i2 - i, p, n); return replace(i - begin(), i2 - i, p, n);
@ -1370,7 +1368,7 @@ string & string::replace(iterator i, iterator i2,
string & string::replace(iterator i, iterator i2, value_type const * p) string & string::replace(iterator i, iterator i2, value_type const * p)
{ {
Assert(p); // OURS! BOOST_ASSERT(p); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return replace(i - begin(), i2 - i, p); return replace(i - begin(), i2 - i, p);
@ -1406,7 +1404,7 @@ void string::swap(string & str)
string & string::erase(size_type i, size_type n) string & string::erase(size_type i, size_type n)
{ {
Assert(i <= rep->sz); // STD! BOOST_ASSERT(i <= rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
rep = rep->get_own_copy(); rep = rep->get_own_copy();
@ -1461,8 +1459,8 @@ string::value_type const * string::data() const
string::size_type string::copy(value_type * buf, size_type len, string::size_type string::copy(value_type * buf, size_type len,
size_type pos) const size_type pos) const
{ {
Assert(buf); // OURS! BOOST_ASSERT(buf); // OURS!
Assert(pos <= rep->sz); // STD! BOOST_ASSERT(pos <= rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
register int nn = min(len, length() - pos); register int nn = min(len, length() - pos);
@ -1510,7 +1508,7 @@ int string::compare(string const & str) const
int string::compare(value_type const * s) const int string::compare(value_type const * s) const
{ {
Assert(s); //OURS! BOOST_ASSERT(s); //OURS!
TeststringInvariant(this); TeststringInvariant(this);
int n = (!s) ? 0 : strlen(s); int n = (!s) ? 0 : strlen(s);
return internal_compare(0, rep->sz, s, n, n); return internal_compare(0, rep->sz, s, n, n);
@ -1520,7 +1518,7 @@ int string::compare(value_type const * s) const
int string::compare(size_type pos, size_type n, int string::compare(size_type pos, size_type n,
string const & str) const string const & str) const
{ {
Assert(pos <= rep->sz); // OURS! BOOST_ASSERT(pos <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return internal_compare(pos, n, str.rep->s, str.rep->sz, str.rep->sz); return internal_compare(pos, n, str.rep->s, str.rep->sz, str.rep->sz);
} }
@ -1529,8 +1527,8 @@ int string::compare(size_type pos, size_type n,
int string::compare(size_type pos, size_type n, string const & str, int string::compare(size_type pos, size_type n, string const & str,
size_type pos2, size_type n2) const size_type pos2, size_type n2) const
{ {
Assert(pos <= rep->sz); // OURS! BOOST_ASSERT(pos <= rep->sz); // OURS!
Assert(pos2 <= str.rep->sz); // OURS! BOOST_ASSERT(pos2 <= str.rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return internal_compare(pos, n, return internal_compare(pos, n,
str.rep->s + pos2, str.rep->s + pos2,
@ -1541,7 +1539,7 @@ int string::compare(size_type pos, size_type n, string const & str,
int string::compare(size_type pos, size_type n, value_type const * s, int string::compare(size_type pos, size_type n, value_type const * s,
size_type n2) const size_type n2) const
{ {
Assert(s && pos <= rep->sz); // OURS! BOOST_ASSERT(s && pos <= rep->sz); // OURS!
TeststringInvariant(this); TeststringInvariant(this);
return internal_compare(pos, n, s, (!s) ? 0 : strlen(s), n2); return internal_compare(pos, n, s, (!s) ? 0 : strlen(s), n2);
} }
@ -1554,7 +1552,7 @@ int string::compare(size_type pos, size_type n, value_type const * s,
// i = index, n = length // i = index, n = length
string string::substr(size_type i, size_type n) const string string::substr(size_type i, size_type n) const
{ {
Assert(i <= rep->sz); // STD! BOOST_ASSERT(i <= rep->sz); // STD!
TeststringInvariant(this); TeststringInvariant(this);
return string(*this, i, n); return string(*this, i, n);
@ -1573,14 +1571,14 @@ bool operator==(string const & a, string const & b)
bool operator==(string::value_type const * a, string const & b) bool operator==(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) == 0; return b.compare(a) == 0;
} }
bool operator==(string const & a, string::value_type const * b) bool operator==(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) == 0; return a.compare(b) == 0;
} }
@ -1593,14 +1591,14 @@ bool operator!=(string const & a, string const & b)
bool operator!=(string::value_type const * a, string const & b) bool operator!=(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) != 0; return b.compare(a) != 0;
} }
bool operator!=(string const & a, string::value_type const * b) bool operator!=(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) != 0; return a.compare(b) != 0;
} }
@ -1613,14 +1611,14 @@ bool operator>(string const & a, string const & b)
bool operator>(string::value_type const * a, string const & b) bool operator>(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) < 0; // since we reverse the parameters return b.compare(a) < 0; // since we reverse the parameters
} }
bool operator>(string const & a, string::value_type const * b) bool operator>(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) > 0; return a.compare(b) > 0;
} }
@ -1633,14 +1631,14 @@ bool operator<(string const & a, string const & b)
bool operator<(string::value_type const * a, string const & b) bool operator<(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) > 0; // since we reverse the parameters return b.compare(a) > 0; // since we reverse the parameters
} }
bool operator<(string const & a, string::value_type const * b) bool operator<(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) < 0; return a.compare(b) < 0;
} }
@ -1653,14 +1651,14 @@ bool operator>=(string const & a, string const & b)
bool operator>=(string::value_type const * a, string const & b) bool operator>=(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) <= 0; // since we reverse the parameters return b.compare(a) <= 0; // since we reverse the parameters
} }
bool operator>=(string const & a, string::value_type const * b) bool operator>=(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) >= 0; return a.compare(b) >= 0;
} }
@ -1673,14 +1671,14 @@ bool operator<=(string const & a, string const & b)
bool operator<=(string::value_type const * a, string const & b) bool operator<=(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
return b.compare(a) >= 0; // since we reverse the parameters return b.compare(a) >= 0; // since we reverse the parameters
} }
bool operator<=(string const & a, string::value_type const * b) bool operator<=(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
return a.compare(b) <= 0; return a.compare(b) <= 0;
} }
@ -1695,7 +1693,7 @@ string operator+(string const & a, string const & b)
string operator+(string::value_type const * a, string const & b) string operator+(string::value_type const * a, string const & b)
{ {
Assert(a); // OURS! BOOST_ASSERT(a); // OURS!
string tmp(a); string tmp(a);
tmp += b; tmp += b;
return tmp; return tmp;
@ -1713,7 +1711,7 @@ string operator+(string::value_type a, string const & b)
string operator+(string const & a, string::value_type const * b) string operator+(string const & a, string::value_type const * b)
{ {
Assert(b); // OURS! BOOST_ASSERT(b); // OURS!
string tmp(a); string tmp(a);
tmp += b; tmp += b;
return tmp; return tmp;

View File

@ -17,7 +17,6 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include "support/LAssert.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
/** /**
* This class template is used to translate between two elements, specifically * This class template is used to translate between two elements, specifically
@ -50,7 +49,7 @@ public:
/// Find the mapping for the first argument /// Find the mapping for the first argument
T2 const & find(T1 const & first) const { T2 const & find(T1 const & first) const {
lyx::support::Assert(!map.empty()); BOOST_ASSERT(!map.empty());
// For explanation see the next find() function. // For explanation see the next find() function.
typename Map::const_iterator it = typename Map::const_iterator it =
@ -67,7 +66,7 @@ public:
/// Find the mapping for the second argument /// Find the mapping for the second argument
T1 const & find(T2 const & second) const { T1 const & find(T2 const & second) const {
lyx::support::Assert(!map.empty()); BOOST_ASSERT(!map.empty());
// The idea is as follows: // The idea is as follows:
// find_if() will try to compare the data in the vector with // find_if() will try to compare the data in the vector with

View File

@ -11,9 +11,10 @@
#include <config.h> #include <config.h>
#include "userinfo.h" #include "userinfo.h"
#include "LAssert.h"
#include "filetools.h" #include "filetools.h"
#include <boost/assert.hpp>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
@ -24,7 +25,7 @@ namespace support {
string const user_name() string const user_name()
{ {
struct passwd * pw(getpwuid(geteuid())); struct passwd * pw(getpwuid(geteuid()));
Assert(pw); BOOST_ASSERT(pw);
string name = pw->pw_gecos; string name = pw->pw_gecos;
if (name.empty()) if (name.empty())

View File

@ -28,7 +28,6 @@
#include "insets/insettabular.h" #include "insets/insettabular.h"
#include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h" #include "support/tostr.h"
@ -1298,14 +1297,14 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex)
l_getline(is, line); l_getline(is, line);
if (!prefixIs(line, "<lyxtabular ") if (!prefixIs(line, "<lyxtabular ")
&& !prefixIs(line, "<LyXTabular ")) { && !prefixIs(line, "<LyXTabular ")) {
Assert(false); BOOST_ASSERT(false);
return; return;
} }
int version; int version;
if (!getTokenValue(line, "version", version)) if (!getTokenValue(line, "version", version))
return; return;
Assert(version >= 2); BOOST_ASSERT(version >= 2);
int rows_arg; int rows_arg;
if (!getTokenValue(line, "rows", rows_arg)) if (!getTokenValue(line, "rows", rows_arg))
@ -1589,7 +1588,7 @@ int LyXTabular::getLastCellBelow(int cell) const
int LyXTabular::getCellNumber(int row, int column) const int LyXTabular::getCellNumber(int row, int column) const
{ {
Assert(column >= 0 || column < columns_ || row >= 0 || row < rows_); BOOST_ASSERT(column >= 0 || column < columns_ || row >= 0 || row < rows_);
return cell_info[row][column].cellno; return cell_info[row][column].cellno;
} }

View File

@ -62,7 +62,7 @@ void handle_comment(Parser & p)
string const trim(string const & a, char const * p) string const trim(string const & a, char const * p)
{ {
// lyx::Assert(p); // BOOST_ASSERT(p);
if (a.empty() || !*p) if (a.empty() || !*p)
return a; return a;

Some files were not shown because too many files have changed in this diff Show More