each failure.
There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:
Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525: // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143: // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83: // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92: // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303: // LASSERT: Why would this fail?
Text.cpp:995: // LASSERT: Is it safe to continue here?
for (; result == WORD_OK;) {
string const word_str = toAspellWord(w1);
int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
- LASSERT(word_ok != -1, /**/);
+ LASSERT(word_ok != -1, return UNKNOWN_WORD);
result = (word_ok) ? WORD_OK : UNKNOWN_WORD;
if (rest.empty())
break;
return result;
string const word_str = toAspellWord(word.word());
int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
- LASSERT(word_ok != -1, /**/);
+ LASSERT(word_ok != -1, return UNKNOWN_WORD);
return (word_ok) ? WORD_OK : UNKNOWN_WORD;
}
string const word = d->toAspellWord(wl.word());
AspellWordList const * sugs =
aspell_speller_suggest(m, word.c_str(), -1);
- LASSERT(sugs != 0, /**/);
+ LASSERT(sugs != 0, return);
AspellStringEnumeration * els = aspell_word_list_elements(sugs);
if (!els || aspell_word_list_empty(sugs))
return;
void AuthorList::record(int id, Author const & a)
{
+ // LASSERT: What should we do here?
LASSERT(unsigned(id) < authors_.size(), /**/);
authors_[id] = a;
Author const & AuthorList::get(int id) const
{
+ // LASSERT: What should we do here?
LASSERT(id < (int)authors_.size() , /**/);
return authors_[id];
}
LYXERR0("ERROR! Couldn't parse `" << format <<"'.");
return format;
}
- LASSERT(rest.size() <= format.size(), /* */);
+ LASSERT(rest.size() <= format.size(),
+ { ifelsepart = ""; return format; });
ifelsepart = format.substr(0, format.size() - rest.size());
- return rest;
+ return rest;
}
// if we're the master buffer, then we should get rid of the list
// of clones
if (!parent()) {
- // if this is not empty, we have leaked something. worse, one of the
- // children still has a reference to this list.
- LASSERT(d->clone_list_->empty(), /* */);
+ // If this is not empty, we have leaked something. Worse, one of the
+ // children still has a reference to this list. But we will try to
+ // continue, rather than shut down.
+ LATTEST(d->clone_list_->empty());
list<CloneList *>::iterator it =
find(cloned_buffers.begin(), cloned_buffers.end(), d->clone_list_);
- LASSERT(it != cloned_buffers.end(), /* */);
- cloned_buffers.erase(it);
+ if (it == cloned_buffers.end()) {
+ // We will leak in this case, but it is safe to continue.
+ LATTEST(false);
+ } else
+ cloned_buffers.erase(it);
delete d->clone_list_;
}
// FIXME Do we really need to do this right before we delete d?
frontend::WorkAreaManager & Buffer::workAreaManager() const
{
- LASSERT(d->wa_, /**/);
+ LBUFERR(d->wa_, _("Unable to find WorkArea for Buffer!"));
return *d->wa_;
}
void Buffer::changeLanguage(Language const * from, Language const * to)
{
- LASSERT(from, /**/);
- LASSERT(to, /**/);
+ LASSERT(from, return);
+ LASSERT(to, return);
for_each(par_iterator_begin(),
par_iterator_end(),
bool Buffer::isExternallyModified(CheckMethod method) const
{
- LASSERT(d->filename.exists(), /**/);
+ LASSERT(d->filename.exists(), return false);
// if method == timestamp, check timestamp before checksum
return (method == checksum_method
|| d->timestamp_ != d->filename.lastModified())
void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
{
+ LBUFERR(!text().paragraphs().empty(), _("Buffer error"));
+
// Use the master text class also for child documents
Buffer const * const master = masterBuffer();
DocumentClass const & textclass = master->params().documentClass();
Buffer & cbuf = const_cast<Buffer &>(*this);
- LASSERT(!text().paragraphs().empty(), /**/);
-
// do the real work
ParIterator parit = cbuf.par_iterator_begin();
updateBuffer(parit, utype);
static bool needEnumCounterReset(ParIterator const & it)
{
Paragraph const & par = *it;
- LASSERT(par.layout().labeltype == LABEL_ENUMERATE, /**/);
+ LASSERT(par.layout().labeltype == LABEL_ENUMERATE, return false);
depth_type const cur_depth = par.getDepth();
ParIterator prev_it = it;
while (prev_it.pit()) {
void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
{
+ // LASSERT: Is it safe to continue here, or should we just return?
LASSERT(parit.pit() == 0, /**/);
// Set the position of the text in the buffer to be able
void BufferList::release(Buffer * buf)
{
- LASSERT(buf, /**/);
+ // We may leak here, but we probably do not need to
+ // shut down.
+ LASSERT(buf, return);
BufferStorage::iterator const it =
find(bstore.begin(), bstore.end(), buf);
if (it != bstore.end()) {
Buffer * tmp = (*it);
- LASSERT(tmp, /**/);
bstore.erase(it);
+ LASSERT(tmp, return);
delete tmp;
}
}
Buffer * BufferList::next(Buffer const * buf) const
{
- LASSERT(buf, /**/);
+ // Something is wrong, but we can probably survive it.
+ LASSERT(buf, return 0);
if (bstore.empty())
return 0;
BufferStorage::const_iterator it =
find(bstore.begin(), bstore.end(), buf);
- LASSERT(it != bstore.end(), /**/);
+ LASSERT(it != bstore.end(), return 0);
++it;
Buffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it;
return nextbuf;
Buffer * BufferList::previous(Buffer const * buf) const
{
- LASSERT(buf, /**/);
+ // Something is wrong, but we can probably survive it.
+ LASSERT(buf, return 0);
if (bstore.empty())
return 0;
BufferStorage::const_iterator it =
find(bstore.begin(), bstore.end(), buf);
- LASSERT(it != bstore.end(), /**/);
+ LASSERT(it != bstore.end(), return 0);
Buffer * previousbuf = (it == bstore.begin()) ? bstore.back() : *(it - 1);
return previousbuf;
BufferParams::Impl *
BufferParams::MemoryTraits::clone(BufferParams::Impl const * ptr)
{
- LASSERT(ptr, /**/);
-
+ LBUFERR(ptr, _("Attempting to clone non-existent BufferParams!"));
return new BufferParams::Impl(*ptr);
}
docstring BufferParams::B_(string const & l10n) const
{
- LASSERT(language, /**/);
+ LASSERT(language, return from_utf8(l10n));
return getMessages(language->code()).get(l10n);
}
Bullet & BufferParams::temp_bullet(lyx::size_type const index)
{
- LASSERT(index < 4, /**/);
+ LASSERT(index < 4, return pimpl_->temp_bullets[0]);
return pimpl_->temp_bullets[index];
}
Bullet const & BufferParams::temp_bullet(lyx::size_type const index) const
{
- LASSERT(index < 4, /**/);
+ LASSERT(index < 4, return pimpl_->temp_bullets[0]);
return pimpl_->temp_bullets[index];
}
Bullet & BufferParams::user_defined_bullet(lyx::size_type const index)
{
- LASSERT(index < 4, /**/);
+ LASSERT(index < 4, return pimpl_->temp_bullets[0]);
return pimpl_->user_defined_bullets[index];
}
Bullet const & BufferParams::user_defined_bullet(lyx::size_type const index) const
{
- LASSERT(index < 4, /**/);
+ LASSERT(index < 4, return pimpl_->temp_bullets[0]);
return pimpl_->user_defined_bullets[index];
}
if (tm.contains(bot_pit)) {
ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
- LASSERT(!pm.rows().empty(), /**/);
+ LBUFERR(!pm.rows().empty(), _(""));
// FIXME: smooth scrolling doesn't work in mathed.
CursorSlice const & cs = dit.innerTextSlice();
int offset = coordOffset(dit).y_;
{
if (d->last_inset_ != inset) {
LYXERR0("Wrong last_inset!");
- LASSERT(false, /**/);
+ LATTEST(false);
}
d->last_inset_ = 0;
}
TextMetrics & BufferView::textMetrics(Text const * t)
{
- LASSERT(t, /**/);
+ LBUFERR(t, _(""));
TextMetricsCache::iterator tmc_it = d->text_metrics_.find(t);
if (tmc_it == d->text_metrics_.end()) {
tmc_it = d->text_metrics_.insert(
bool BufferView::mouseSetCursor(Cursor & cur, bool select)
{
- LASSERT(&cur.bv() == this, /**/);
+ LASSERT(&cur.bv() == this, return false);
if (!select)
// this event will clear selection so we save selection for
void BufferView::insertLyXFile(FileName const & fname)
{
- LASSERT(d->cursor_.inTexted(), /**/);
+ LASSERT(d->cursor_.inTexted(), return);
// Get absolute path of file and add ".lyx"
// to the filename if necessary
CursorSlice const & sl = dit[0];
TextMetrics const & tm = textMetrics(sl.text());
ParagraphMetrics const & pm = tm.parMetrics(sl.pit());
- LASSERT(!pm.rows().empty(), /**/);
+
+ LBUFERR(!pm.rows().empty(), _(""));
y -= pm.rows()[0].ascent();
#if 1
// FIXME: document this mess
void Bullet::testInvariant() const
{
#ifdef ENABLE_ASSERTIONS
- LASSERT(font >= MIN, /**/);
- LASSERT(font < FONTMAX, /**/);
- LASSERT(character >= MIN, /**/);
- LASSERT(character < CHARMAX, /**/);
- LASSERT(size >= MIN, /**/);
- LASSERT(size < SIZEMAX, /**/);
- LASSERT(user_text >= -1, /**/);
- LASSERT(user_text <= 1, /**/);
+ LATTEST(font >= MIN);
+ LATTEST(font < FONTMAX);
+ LATTEST(character >= MIN);
+ LATTEST(character < CHARMAX);
+ LATTEST(size >= MIN);
+ LATTEST(size < SIZEMAX);
+ LATTEST(user_text >= -1);
+ LATTEST(user_text <= 1);
// now some relational/operational tests
if (user_text == 1) {
- LASSERT(font == -1 && (character == -1 && size == -1), /**/);
- // LASSERT(!text.empty(), /**/); // this isn't necessarily an error
+ LATTEST(font == -1 && (character == -1 && size == -1));
+ // LATTEST(!text.empty()); // this isn't necessarily an error
}
// else if (user_text == -1) {
- // LASSERT(!text.empty(), /**/); // this also isn't necessarily an error
+ // LATTEST(!text.empty()); // this also isn't necessarily an error
// }
// else {
// // user_text == 0
- // LASSERT(text.empty(), /**/); // not usually true
+ // LATTEST(text.empty()); // not usually true
// }
#endif
}
RGBColor rgbFromHexName(string const & x11hexname)
{
RGBColor c;
- LASSERT(x11hexname.size() == 7 && x11hexname[0] == '#', /**/);
+ LASSERT(x11hexname.size() == 7 && x11hexname[0] == '#',
+ return c);
c.r = hexstrToInt(x11hexname.substr(1, 2));
c.g = hexstrToInt(x11hexname.substr(3, 2));
c.b = hexstrToInt(x11hexname.substr(5, 2));
if (os[k].empty() && os_r[kk].empty()) {
// No, there is no snake at all, in which case
// the length of the shortest edit script is M+N.
- LASSERT(2 * D - odd_offset_ == M_ + N_, /**/);
+ LATTEST(2 * D - odd_offset_ == M_ + N_);
return NoSnake;
}
pit_type const pit = it.o.pit() - rp.o.from.pit();
pos_type const pos = pit ? it.o.pos() : it.o.pos() - rp.o.from.pos();
inset = pars[pit].getInset(pos);
- LASSERT(inset, /**/);
+ LASSERT(inset, continue);
diffInset(inset, it);
}
}
LYXERR(Debug::FILES, orig_from << ' ' << to_format);
CacheItem * const item = pimpl_->find(orig_from, to_format);
- LASSERT(item, /**/);
+ LASSERT(item, { static const FileName fn; return fn; });
return item->cache_name;
}
}
CacheItem * const item = pimpl_->find(orig_from, to_format);
- LASSERT(item, /**/);
+ LASSERT(item, return false);
Mover const & mover = getMover(to_format);
return mover.copy(item->cache_name, dest,
onlyFileName(dest.absFileName()));
Point::Point(int x, int y)
: x_(x), y_(y)
{
- LASSERT(x > -1000000, /**/);
- LASSERT(x < 1000000, /**/);
- LASSERT(y > -1000000, /**/);
- LASSERT(y < 1000000, /**/);
+ LASSERT(x > -1000000, x = -1000000);
+ LASSERT(x < 1000000, x = 1000000);
+ LASSERT(y > -1000000, y = -1000000);
+ LASSERT(y < 1000000, y = 1000000);
}
it->second.step();
if (utype == OutputUpdate) {
- LASSERT(!counter_stack_.empty(), /* */);
+ LBUFERR(!counter_stack_.empty(), _("Empty counter stack!"));
counter_stack_.pop_back();
counter_stack_.push_back(ctr);
}
void Counters::reset(docstring const & match)
{
- LASSERT(!match.empty(), /**/);
+ LASSERT(!match.empty(), return);
CounterList::iterator it = counterList_.begin();
CounterList::iterator end = counterList_.end();
docstring Counters::currentCounter() const
{
- LASSERT(!counter_stack_.empty(), /* */);
+ LBUFERR(!counter_stack_.empty(), _("Empty counter stack!"));
return counter_stack_.back();
}
#include "TextMetrics.h"
#include "TocBackend.h"
-#include "support/lassert.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/ExceptionMessage.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
#include "insets/InsetTabular.h"
#include "insets/InsetText.h"
bool res = false;
for ( ; cur.depth(); cur.pop()) {
//lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
+ // LASSERT: Is it safe to continue here, or should we return?
LASSERT(cur.idx() <= cur.lastidx(), /**/);
LASSERT(cur.pit() <= cur.lastpit(), /**/);
LASSERT(cur.pos() <= cur.lastpos(), /**/);
for (; depth(); pop(), boundary(false)) {
LYXERR(Debug::DEBUG, "Cursor::dispatch: cmd: "
<< cmd0 << endl << *this);
+ // LASSERT: Is it safe to continue here, or should we return?
LASSERT(pos() <= lastpos(), /**/);
LASSERT(idx() <= lastidx(), /**/);
LASSERT(pit() <= lastpit(), /**/);
BufferView & Cursor::bv() const
{
- LASSERT(bv_, /**/);
+ LBUFERR(bv_, _("Cursor has no BufferView!"));
return *bv_;
}
void Cursor::pop()
{
- LASSERT(depth() >= 1, /**/);
+ LBUFERR(depth() >= 1, _("Attempt to pop empty cursor!"));
pop_back();
}
int Cursor::currentMode()
{
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return Inset::UNDECIDED_MODE);
for (int i = depth() - 1; i >= 0; --i) {
int res = operator[](i).inset().currentMode();
bool locked_mode = operator[](i).inset().lockedMode();
{
CursorSlice const & cs = innerTextSlice();
ParagraphMetrics const & pm = bv().parMetrics(cs.text(), cs.pit());
- LASSERT(!pm.rows().empty(), /**/);
return pm.getRow(pos(), boundary());
}
{
if (!selection())
return top();
- LASSERT(anchor_.depth() >= depth(), /**/);
+ if (anchor_.depth() >= depth()) {
+ // LASSERT: There have been several bugs around this code, that seem
+ // to involve failures to reset the anchor. We can at least not crash
+ // in release mode by resetting it ourselves.
+ LASSERT(false, /* */);
+ DocIterator & di = const_cast<DocIterator &>(anchor_);
+ di = *this;
+ }
CursorSlice normal = anchor_[depth() - 1];
if (depth() < anchor_.depth() && top() <= normal) {
// anchor is behind cursor -> move anchor behind the inset
void Cursor::insert(char_type c)
{
//lyxerr << "Cursor::insert char '" << c << "'" << endl;
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return);
if (inMathed()) {
cap::selClearOrDel(*this);
insert(new InsetMathChar(c));
void Cursor::insert(Inset * inset0)
{
- LASSERT(inset0, /**/);
+ LASSERT(inset0, return);
if (inMathed())
insert(MathAtom(inset0->asInsetMath()));
else {
bool Cursor::upDownInText(bool up, bool & updateNeeded)
{
- LASSERT(text(), /**/);
+ LASSERT(text(), return false);
// where are we?
int xo = 0;
#include "mathed/InsetMath.h"
#include "mathed/MathMacro.h"
+#include "support/ExceptionMessage.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <ostream>
CursorSlice::CursorSlice(Inset & p)
: inset_(&p), idx_(0), pit_(0), pos_(0)
{
- LASSERT(inset_, /**/);
+ LBUFERR(inset_, _("Invalid initialization of CursorSlice!"));
}
pos_type CursorSlice::lastpos() const
{
- LASSERT(inset_, /**/);
+ LBUFERR(inset_, _("Cursor slice not properly initialized!"));
InsetMath const * math = inset_->asInsetMath();
bool paramless_macro = math && math->asMacro() && !math->asMacro()->nargs();
return math ? (paramless_macro ? 0 : cell().size())
CursorSlice::row_type CursorSlice::row() const
{
+ // LASSERT: This should only ever be called from an InsetMath.
+ // Should we crash in release mode, though, or try to continue?
LASSERT(asInsetMath(), /**/);
return asInsetMath()->row(idx_);
}
CursorSlice::col_type CursorSlice::col() const
{
+ // LASSERT: This should only ever be called from an InsetMath.
+ // Should we crash in release mode, though, or try to continue?
LASSERT(asInsetMath(), /**/);
return asInsetMath()->col(idx_);
}
// otherwise move on one cell
//lyxerr << "... next idx" << endl;
- LASSERT(idx_ < nargs(), /**/);
+ LASSERT(idx_ < nargs(), return);
++idx_;
pit_ = 0;
void CursorSlice::forwardIdx()
{
- LASSERT(idx_ < nargs(), /**/);
+ LASSERT(idx_ < nargs(), return);
++idx_;
pit_ = 0;
return;
}
- LASSERT(false, /**/);
+ LATTEST(false);
}
if (p.inset_ != q.inset_) {
LYXERR0("can't compare cursor and anchor in different insets\n"
<< "p: " << p << '\n' << "q: " << q);
- LASSERT(false, /**/);
+ // It should be safe to continue, just registering the error.
+ LASSERT(false, return false);
}
if (p.idx_ != q.idx_)
return p.idx_ < q.idx_;
{
ParagraphList const & pars = text.paragraphs();
- LASSERT(0 <= start && start <= pars[startpit].size(), /**/);
- LASSERT(0 <= end && end <= pars[endpit].size(), /**/);
- LASSERT(startpit != endpit || start <= end, /**/);
+ // In most of these cases, we can try to recover.
+ LASSERT(0 <= start, start = 0);
+ LASSERT(start <= pars[startpit].size(), start = pars[startpit].size());
+ LASSERT(0 <= end, end = 0);
+ LASSERT(end <= pars[endpit].size(), end = pars[endpit].size());
+ LASSERT(startpit != endpit || start <= end, return);
// Clone the paragraphs within the selection.
ParagraphList copy_pars(boost::next(pars.begin(), startpit),
{
errorlist.clear();
- LASSERT(!in.paragraphs().empty(), /**/);
+ LBUFERR(!in.paragraphs().empty(), _(""));
if (oldone == newone)
return;
if (cur.inTexted()) {
Text * text = cur.text();
- LASSERT(text, /**/);
+ LBUFERR(text, _("Invalid cursor!"));
saveSelection(cur);
if (cur.inTexted()) {
Text * text = cur.text();
- LASSERT(text, /**/);
+ LBUFERR(text, _("Invalid cursor!"));
// ok we have a selection. This is always between cur.selBegin()
// and sel_end cursor
{
if (cur.inTexted()) {
Text * text = cur.text();
- LASSERT(text, /**/);
+ LBUFERR(text, _("Invalid cursor!"));
PasteReturnValue prv =
pasteSelectionHelper(cur, parlist, docclass, errorList);
}
// mathed is handled in InsetMathNest/InsetMathGrid
- LASSERT(!cur.inMathed(), /**/);
+ LATTEST(!cur.inMathed());
}
void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
Clipboard::GraphicsType preferedType)
{
- LASSERT(theClipboard().hasGraphicsContents(preferedType), /**/);
+ LASSERT(theClipboard().hasGraphicsContents(preferedType), return);
// get picture from clipboard
FileName filename = theClipboard().getAsGraphics(cur, preferedType);
#include "insets/InsetTabular.h"
#include "support/debug.h"
+#include "support/ExceptionMessage.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
DocIterator dit(buffer);
size_t const n = slices_.size();
for (size_t i = 0 ; i != n; ++i) {
- LASSERT(inset, /**/);
+ LBUFERR(inset, _("Iterator slice not properly initialized!"));
dit.push_back(slices_[i]);
dit.top().inset_ = inset;
if (i + 1 != n)
Inset * DocIterator::realInset() const
{
- LASSERT(inTexted(), /**/);
+ LASSERT(inTexted(), return 0);
// if we are in a tabular, we need the cell
if (inset().lyxCode() == TABULAR_CODE) {
InsetTabular * tabular = inset().asInsetTabular();
Text * DocIterator::text() const
{
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return 0);
return top().text();
}
Paragraph & DocIterator::paragraph() const
{
- if (!inTexted())
+ if (!inTexted()) {
LYXERR0(*this);
- LASSERT(inTexted(), /**/);
+ LBUFERR(false, _("DocIterator::paragraph() called outside Text."));
+ }
return top().paragraph();
}
Paragraph & DocIterator::innerParagraph() const
{
- LASSERT(!empty(), /**/);
+ LBUFERR(!empty(), _("Empty DocIterator."));
return innerTextSlice().paragraph();
}
CursorSlice const & DocIterator::innerTextSlice() const
{
- LASSERT(!empty(), /**/);
+ LBUFERR(!empty(), _(""));
// go up until first non-0 text is hit
// (innermost text is 0 in mathed)
for (int i = depth() - 1; i >= 0; --i)
// This case is in principe not possible. We _must_
// be inside a Text.
- LASSERT(false, /**/);
- static CursorSlice dummy;
- return dummy;
+ LBUFERR(false, _(""));
+ // Squash warning
+ static const CursorSlice c;
+ return c;
}
Text * DocIterator::innerText() const
{
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return 0);
return innerTextSlice().text();
}
size_t const n = slices_.size();
slices_.resize(0);
for (size_t i = 0 ; i < n; ++i) {
- LASSERT(inset, /**/);
+ LBUFERR(inset, _("Improperly initialized DocIterator."));
push_back(dit[i]);
top().inset_ = inset;
if (i + 1 != n)
Encoding const * const ascii = encodings.fromLyXName("ascii");
pair<bool, int> const c = switchEncoding(os.os(), bparams,
runparams, *ascii);
- LASSERT(c.first, /**/);
+ LATTEST(c.first);
count += c.second;
runparams.encoding = ascii;
open_encoding_ = false;
switch (kind_) {
case DEFAULT:
return string();
- break;
- case LENGTH: {
+ case LENGTH:
return len_.asLatexString();
- break;
- }
- default: {
- LASSERT(false, /**/);
- return string();
- }
+ default:
+ LATTEST(false);
+ // fall through in release mode
}
+ return string();
}
case DEFAULT:
// FIXME: replace by correct length
return bv.buffer().params().getIndentation().inPixels(bv);
- //return 0;
- break;
case LENGTH:
return len_.len().inPixels(bv.workWidth());
- break;
default:
- LASSERT(false, /**/);
- return 0;
+ LATTEST(false);
+ // fall through in release mode
}
+ return 0;
}
LayoutFile const & LayoutFileList::operator[](string const & classname) const
{
- LASSERT(haveClass(classname), /**/);
+ LATTEST(haveClass(classname));
+ // safe to continue, since we will make an empty LayoutFile
return *classmap_[classname];
}
LayoutFile & LayoutFileList::operator[](string const & classname)
{
- LASSERT(haveClass(classname), /**/);
+ LATTEST(haveClass(classname));
+ // safe to continue, since we will make an empty LayoutFile
return *classmap_[classname];
}
void LayoutFileList::reset(LayoutFileIndex const & classname)
{
- LASSERT(haveClass(classname), /**/);
+ LATTEST(haveClass(classname));
+ // safe to continue, since we will make an empty LayoutFile
LayoutFile * tc = classmap_[classname];
LayoutFile * tmpl =
new LayoutFile(tc->name(), tc->latexname(), tc->description(),
if (!tc->load(tempLayout.absFileName())) {
// This can only happen if the hardcoded file above is wrong
// or there is some weird filesystem error.
- LASSERT(false, /* */);
+ LATTEST(false); // We will get an empty layout or something.
}
}
string fullName = addName(path, textclass + ".layout");
FileName const layout_file(fullName);
+
if (!layout_file.exists())
return string();
smatch sub;
if (regex_match(line, sub, reg)) {
// returns: whole string, classtype (not used here), class name, description
+ // LASSERT: Why would this fail?
LASSERT(sub.size() == 4, /**/);
// now, create a TextClass with description containing path information
class_name = (sub.str(2) == "" ? textclass : sub.str(2));
pair<map<string, Messages>::iterator, bool> result =
pimpl_->messages_.insert(make_pair(language, Messages(language)));
- LASSERT(result.second, /**/);
+ LATTEST(result.second);
return result.first->second;
}
void LyX::earlyExit(int status)
{
- LASSERT(pimpl_->application_.get(), /**/);
+ LATTEST(pimpl_->application_.get());
// LyX::pimpl_::application_ is not initialised at this
// point so it's safe to just exit after some cleanup.
prepareExit();
bool LyX::loadFiles()
{
- LASSERT(!use_gui, /**/);
+ LATTEST(!use_gui);
bool success = true;
vector<string>::const_iterator it = pimpl_->files_to_load_.begin();
vector<string>::const_iterator end = pimpl_->files_to_load_.end();
void execBatchCommands()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
singleton_->execCommands();
}
FuncStatus getStatus(FuncRequest const & action)
{
- LASSERT(theApp(), /**/);
+ LAPPERR(theApp(), _("Appplication not initialized."));
return theApp()->getStatus(action);
}
void dispatch(FuncRequest const & action)
{
- LASSERT(theApp(), /**/);
+ LAPPERR(theApp(), _("Appplication not initialized."));
return theApp()->dispatch(action);
}
void dispatch(FuncRequest const & action, DispatchResult & dr)
{
- LASSERT(theApp(), /**/);
+ LAPPERR(theApp(), _("Appplication not initialized."));
return theApp()->dispatch(action, dr);
}
vector<string> & theFilesToLoad()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->files_to_load_;
}
BufferList & theBufferList()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->buffer_list_;
}
Server & theServer()
{
// FIXME: this should not be use_gui dependent
- LASSERT(use_gui, /**/);
- LASSERT(singleton_, /**/);
+ LWARNIF(use_gui, _("LyX server can only be used with GUI."));
+ LAPPERR(singleton_, _("Appplication not initialized."));
return *singleton_->pimpl_->lyx_server_.get();
}
ServerSocket & theServerSocket()
{
// FIXME: this should not be use_gui dependent
- LASSERT(use_gui, /**/);
- LASSERT(singleton_, /**/);
+ LWARNIF(use_gui, _("LyX server can only be used with GUI."));
+ LAPPERR(singleton_, _("Appplication not initialized."));
return *singleton_->pimpl_->lyx_socket_.get();
}
KeyMap & theTopLevelKeymap()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->toplevel_keymap_;
}
Converters & theConverters()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->converters_;
}
Converters & theSystemConverters()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->system_converters_;
}
Movers & theMovers()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->movers_;
}
Mover const & getMover(string const & fmt)
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->movers_(fmt);
}
void setMover(string const & fmt, string const & command)
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
singleton_->pimpl_->movers_.set(fmt, command);
}
Movers & theSystemMovers()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->system_movers_;
}
Messages const & getMessages(string const & language)
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->messages(language);
}
Messages const & getGuiMessages()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
// A cache to translate full language name to language code
static string last_language = "auto";
static string code;
Session & theSession()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return *singleton_->pimpl_->session_.get();
}
LaTeXFonts & theLaTeXFonts()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
if (!singleton_->pimpl_->latexfonts_)
singleton_->pimpl_->latexfonts_ = new LaTeXFonts;
return *singleton_->pimpl_->latexfonts_;
CmdDef & theTopLevelCmdDef()
{
- LASSERT(singleton_, /**/);
+ LAPPERR(singleton_, _("Appplication not initialized."));
return singleton_->pimpl_->toplevel_cmddef_;
}
if (ici == lyx_info_map.end()) {
LYXERR0("action: " << action << " is not known.");
- LASSERT(false, /**/);
+ LASSERT(false, return false);
}
return ici->second.attrib & flag;
bool Paragraph::isDeleted(pos_type start, pos_type end) const
{
- LASSERT(start >= 0 && start <= size(), /**/);
- LASSERT(end > start && end <= size() + 1, /**/);
+ LASSERT(start >= 0 && start <= size(), return false);
+ LASSERT(end > start && end <= size() + 1, return false);
return d->changes_.isDeleted(start, end);
}
bool Paragraph::isChanged(pos_type start, pos_type end) const
{
- LASSERT(start >= 0 && start <= size(), /**/);
- LASSERT(end > start && end <= size() + 1, /**/);
+ LASSERT(start >= 0 && start <= size(), return false);
+ LASSERT(end > start && end <= size() + 1, return false);
return d->changes_.isChanged(start, end);
}
void Paragraph::setChange(pos_type pos, Change const & change)
{
- LASSERT(pos >= 0 && pos <= size(), /**/);
+ LASSERT(pos >= 0 && pos <= size(), return);
d->changes_.set(change, pos);
// see comment in setChange(Change const &) above
Change const & Paragraph::lookupChange(pos_type pos) const
{
- LASSERT(pos >= 0 && pos <= size(), /**/);
+ LBUFERR(pos >= 0 && pos <= size(),
+ _("Invalid position given to lookupChange()"));
return d->changes_.lookup(pos);
}
void Paragraph::acceptChanges(pos_type start, pos_type end)
{
- LASSERT(start >= 0 && start <= size(), /**/);
- LASSERT(end > start && end <= size() + 1, /**/);
+ LASSERT(start >= 0 && start <= size(), return);
+ LASSERT(end > start && end <= size() + 1, return);
for (pos_type pos = start; pos < end; ++pos) {
switch (lookupChange(pos).type) {
void Paragraph::rejectChanges(pos_type start, pos_type end)
{
- LASSERT(start >= 0 && start <= size(), /**/);
- LASSERT(end > start && end <= size() + 1, /**/);
+ LASSERT(start >= 0 && start <= size(), return);
+ LASSERT(end > start && end <= size() + 1, return);
for (pos_type pos = start; pos < end; ++pos) {
switch (lookupChange(pos).type) {
void Paragraph::Private::insertChar(pos_type pos, char_type c,
Change const & change)
{
- LASSERT(pos >= 0 && pos <= int(text_.size()), /**/);
+ LASSERT(pos >= 0 && pos <= int(text_.size()), return);
// track change
changes_.insert(change, pos);
bool Paragraph::insertInset(pos_type pos, Inset * inset,
Change const & change)
{
- LASSERT(inset, /**/);
- LASSERT(pos >= 0 && pos <= size(), /**/);
+ LASSERT(inset, return false);
+ LASSERT(pos >= 0 && pos <= size(), return false);
// Paragraph::insertInset() can be used in cut/copy/paste operation where
// d->inset_owner_ is not set yet.
return false;
d->insertChar(pos, META_INSET, change);
- LASSERT(d->text_[pos] == META_INSET, /**/);
+ LASSERT(d->text_[pos] == META_INSET, return false);
// Add a new entry in the insetlist_.
d->insetlist_.insert(inset, pos);
int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
{
- LASSERT(start >= 0 && start <= size(), /**/);
- LASSERT(end >= start && end <= size() + 1, /**/);
+ LASSERT(start >= 0 && start <= size(), return 0);
+ LASSERT(end >= start && end <= size() + 1, return 0);
pos_type i = start;
for (pos_type count = end - start; count; --count) {
unsigned int & column)
{
Inset * inset = owner_->getInset(i);
- LASSERT(inset, /**/);
+ LBUFERR(inset, _(""));
if (style.pass_thru) {
odocstringstream ods;
{
if (pos > size()) {
LYXERR0("pos: " << pos << " size: " << size());
- LASSERT(pos <= size(), /**/);
+ LBUFERR(false, _("Invalid position."));
}
FontList::const_iterator cit = d->fontlist_.fontIterator(pos);
FontSpan Paragraph::fontSpan(pos_type pos) const
{
- LASSERT(pos <= size(), /**/);
+ LBUFERR(pos <= size(), _("Invalid position"));
pos_type start = 0;
FontList::const_iterator cit = d->fontlist_.begin();
}
// This should not happen, but if so, we take no chances.
- // LYXERR0("Paragraph::getEndPosOfFontSpan: This should not happen!");
- return FontSpan(pos, pos);
+ LBUFERR(false, _("Invalid position."));
+ // Squash warning
+ return FontSpan();
}
Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
Font const & outerfont) const
{
- LASSERT(pos >= 0, /**/);
+ LBUFERR(pos >= 0, _("Invalid position."));
Font font = getFontSettings(bparams, pos);
void Paragraph::setFont(pos_type pos, Font const & font)
{
- LASSERT(pos <= size(), /**/);
+ LASSERT(pos <= size(), return);
// First, reduce font against layout/label font
// Update: The setCharFont() routine in text2.cpp already
Inset const & Paragraph::inInset() const
{
- LASSERT(d->inset_owner_, throw ExceptionMessage(BufferException,
- _("Memory problem"), _("Paragraph not properly initialized")));
+ LBUFERR(d->inset_owner_, _("Paragraph not properly initialized"));
return *d->inset_owner_;
}
#include "support/lassert.h"
#include "support/debug.h"
+#include "support/ExceptionMessage.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/textutils.h"
Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
{
- LASSERT(!rows().empty(), /**/);
+ LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
// If boundary is set we should return the row on which
// the character before is inside.
Row const & ParagraphMetrics::getRow(pos_type pos, bool boundary) const
{
- LASSERT(!rows().empty(), /**/);
+ LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
// If boundary is set we should return the row on which
// the character before is inside.
size_t ParagraphMetrics::pos2row(pos_type pos) const
{
- LASSERT(!rows().empty(), /**/);
+ LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
RowList::const_iterator rit = rows_.end();
RowList::const_iterator const begin = rows_.begin();
if (!par_->isHfill(pos))
return false;
- LASSERT(pos >= row.pos() && pos < row.endpos(), /**/);
+ LASSERT(pos >= row.pos() && pos < row.endpos(), return false);
// expand at the end of a row only if there is another hfill on the same row
if (pos == row.endpos() - 1) {
void PrinterParams::testInvariant() const
{
+#ifdef ENABLE_ASSERTIONS
switch (target) {
case PRINTER:
// We can't do this test, because no default printer
// LASSERT(!printer_name.empty(), /**/);
break;
case FILE:
- LASSERT(!file_name.empty(), /**/);
+ LATTEST(!file_name.empty());
break;
default:
- LASSERT(false, /**/);
+ LATTEST(false);
break;
}
+#endif
}
tmp.setInsetOwner(&par.inInset());
tmp.makeSameLayout(par);
- LASSERT(pos <= par.size(), /**/);
+ LASSERT(pos <= par.size(), return);
if (pos < par.size()) {
// move everything behind the break position to the new paragraph
void Text::breakParagraph(Cursor & cur, bool inverse_logic)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
Paragraph & cpar = cur.paragraph();
pit_type cpit = cur.pit();
// same Paragraph one to the right and make a rebreak
void Text::insertChar(Cursor & cur, char_type c)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
cur.recordUndo(INSERT_UNDO);
"beginning of a paragraph. Please read the Tutorial."));
return;
}
+ // LASSERT: Is it safe to continue here?
LASSERT(cur.pos() > 0, /**/);
if ((par.isLineSeparator(cur.pos() - 1) || par.isNewline(cur.pos() - 1))
&& !par.isDeleted(cur.pos() - 1)) {
&& !par.isWordSeparator(cur.pos() - 2)
&& par.isWordSeparator(cur.pos() - 1)) {
// get the word in front of cursor
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
cur.paragraph().updateWords();
}
}
bool Text::cursorForwardOneWord(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pos_type const lastpos = cur.lastpos();
pit_type pit = cur.pit();
else while (pos != lastpos && !par.isWordSeparator(pos))
++pos;
} else {
- LASSERT(pos < lastpos, /**/); // see above
+ LASSERT(pos < lastpos, return false); // see above
if (!par.isWordSeparator(pos))
while (pos != lastpos && !par.isWordSeparator(pos))
++pos;
bool Text::cursorBackwardOneWord(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pit_type pit = cur.pit();
pos_type pos = cur.pos();
bool Text::cursorVisLeftOneWord(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pos_type left_pos, right_pos;
bool left_is_letter, right_is_letter;
bool Text::cursorVisRightOneWord(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pos_type left_pos, right_pos;
bool left_is_letter, right_is_letter;
void Text::selectWord(Cursor & cur, word_location loc)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
CursorSlice from = cur.top();
CursorSlice to = cur.top();
getWord(from, to, loc);
void Text::selectAll(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.lastpos() == 0 && cur.lastpit() == 0)
return;
// If the cursor is at the beginning, make sure the cursor ends there
// selection is currently set
bool Text::selectWordWhenUnderCursor(Cursor & cur, word_location loc)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.selection())
return false;
selectWord(cur, loc);
void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (!cur.selection()) {
bool const changed = cur.paragraph().isChanged(cur.pos());
void Text::deleteWordForward(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.lastpos() == 0)
cursorForward(cur);
else {
void Text::deleteWordBackward(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.lastpos() == 0)
cursorBackward(cur);
else {
// Kill to end of line.
void Text::changeCase(Cursor & cur, TextCase action)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
CursorSlice from;
CursorSlice to;
bool Text::backspacePos0(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.pit() == 0)
return false;
bool Text::backspace(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
bool needsUpdate = false;
if (cur.pos() == 0) {
if (cur.pit() == 0)
// Returns the current font and depth as a message.
docstring Text::currentState(Cursor const & cur) const
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
Buffer & buf = *cur.buffer();
Paragraph const & par = cur.paragraph();
odocstringstream os;
void Text::charsTranspose(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pos_type pos = cur.pos();
bool Text::insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/)
{
- LASSERT(cur.bv().cursor() == cur, /**/);
+ LBUFERR(cur.bv().cursor() == cur, _("Invalid cursor."));
cur.insert(s);
cur.bv().cursor() = cur;
if (!(cur.result().screenUpdate() & Update::Force))
pos_type pos, Font const & font)
{
Inset * const inset = pars_[pit].getInset(pos);
- LASSERT(inset && inset->resetFontEdit(), /**/);
+ LASSERT(inset && inset->resetFontEdit(), return);
CursorSlice::idx_type endidx = inset->nargs();
for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
void Text::setLayout(pit_type start, pit_type end,
docstring const & layout)
{
- LASSERT(start != end, /**/);
+ LASSERT(start != end, return);
Buffer const & buffer = owner_->buffer();
BufferParams const & bp = buffer.params();
// set layout over selection and make a total rebreak of those paragraphs
void Text::setLayout(Cursor & cur, docstring const & layout)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pit_type start = cur.selBegin().pit();
pit_type end = cur.selEnd().pit() + 1;
bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
// this happens when selecting several cells in tabular (bug 2630)
if (cur.selBegin().idx() != cur.selEnd().idx())
return false;
void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
pit_type const beg = cur.selBegin().pit();
pit_type const end = cur.selEnd().pit() + 1;
cur.recordUndoSelection();
bool Text::cursorTop(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
return setCursor(cur, 0, 0);
}
bool Text::cursorBottom(Cursor & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
}
void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
// If the mask is completely neutral, tell user
if (font.fontInfo() == ignore_font && font.language() == ignore_language) {
// Could only happen with user style
docstring Text::getStringToIndex(Cursor const & cur)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
if (cur.selection())
return cur.selectionAsString(false);
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
{
- LASSERT(cur.text(), /**/);
+ LBUFERR(cur.text(), _("Uninitalized cursor."));
//FIXME UNICODE
string const argument = to_utf8(arg);
}
-//FIXME This is a little redundant now, but it's probably worth keeping,
-//especially if we're going to go away from using serialization internally
-//quite so much.
void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
{
- LASSERT(cur.text(), /**/);
+ LBUFERR(cur.text(), _("Uninitalized cursor."));
depth_type priordepth = -1;
Layout priorlayout;
// this really should just insert the inset and not move the cursor.
void Text::insertInset(Cursor & cur, Inset * inset)
{
- LASSERT(this == cur.text(), /**/);
- LASSERT(inset, /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
+ LBUFERR(inset, _("Uninitialized Text."));
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
Change(cur.buffer()->params().trackChanges
? Change::INSERTED : Change::UNCHANGED));
void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
{
- LASSERT(par != int(paragraphs().size()), /**/);
+ LASSERT(par != int(paragraphs().size()), return);
cur.pit() = par;
cur.pos() = pos;
// None of these should happen, but we're scaredy-cats
if (pos < 0) {
- lyxerr << "don't like -1" << endl;
- LASSERT(false, /**/);
+ LYXERR0("Don't like -1!");
+ LATTEST(false);
}
if (pos > para.size()) {
- lyxerr << "don't like 1, pos: " << pos
+ LYXERR0("Don't like 1, pos: " << pos
<< " size: " << para.size()
- << " par: " << par << endl;
- LASSERT(false, /**/);
+ << " par: " << par);
+ LATTEST(false);
}
}
void Text::setCursorIntern(Cursor & cur,
pit_type par, pos_type pos, bool setfont, bool boundary)
{
- LASSERT(this == cur.text(), /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
cur.boundary(boundary);
setCursor(cur.top(), par, pos);
if (setfont)
void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges)
{
- LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), /**/);
+ LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), return);
for (pit_type pit = first; pit <= last; ++pit) {
Paragraph & par = pars_[pit];
#endif
cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
#ifdef ENABLE_ASSERTIONS
- LASSERT(old_pos == cur.pos(), /**/);
+ LATTEST(old_pos == cur.pos());
#endif
cur.nextInset()->edit(cur, true);
// don't do that also for LFUN_MATH_MODE
// at the end?
cur.noScreenUpdate();
- LASSERT(cur.text() == this, /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
CursorSlice const oldTopSlice = cur.top();
bool const oldBoundary = cur.boundary();
bool const oldSelection = cur.selection();
case LFUN_PASTE: {
cur.message(_("Paste"));
- LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), /**/);
+ LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), break);
cap::replaceSelection(cur);
// without argument?
else if (arg == "wmf")
type = Clipboard::WmfGraphicsType;
else
- LASSERT(false, /**/);
+ // We used to assert, but couldn't the argument come from, say, the
+ // minibuffer and just be mistyped?
+ LYXERR0("Unrecognized graphics type: " << arg);
pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"), type);
}
cap::replaceSelection(cur);
cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
checkAndActivateInset(cur, true);
- LASSERT(cur.inMathed(), /**/);
+ LASSERT(cur.inMathed(), break);
cur.dispatch(cmd);
break;
}
bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
- LASSERT(cur.text() == this, /**/);
+ LBUFERR(this == cur.text(), _("Invalid cursor."));
FontInfo const & fontinfo = cur.real_current_font.fontInfo();
bool enable = true;
#include "support/lassert.h"
#include "support/debug.h"
+#include "support/ExceptionMessage.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
Layout const & TextClass::operator[](docstring const & name) const
{
- LASSERT(!name.empty(), /**/);
+ LATTEST(!name.empty());
const_iterator it =
find_if(begin(), end(), LayoutNamesEqual(name));
if (it == end()) {
- lyxerr << "We failed to find the layout '" << to_utf8(name)
- << "' in the layout list. You MUST investigate!"
- << endl;
+ LYXERR0("We failed to find the layout '" << name
+ << "' in the layout list. You MUST investigate!");
for (const_iterator cit = begin(); cit != end(); ++cit)
lyxerr << " " << to_utf8(cit->name()) << endl;
- // we require the name to exist
- LASSERT(false, /**/);
+ // We require the name to exist
+ static const Layout dummy;
+ LASSERT(false, return dummy);
}
return *it;
Layout & TextClass::operator[](docstring const & name)
{
- LASSERT(!name.empty(), /**/);
+ LATTEST(!name.empty());
+ // Safe to continue, given what we do below.
iterator it = find_if(begin(), end(), LayoutNamesEqual(name));
LYXERR0(" " << to_utf8(cit->name()));
// we require the name to exist
- LASSERT(false, /**/);
+ LATTEST(false);
+ // we are here only in release mode
+ layoutlist_.push_back(createBasicLayout(name, true));
+ it = find_if(begin(), end(), LayoutNamesEqual(name));
}
return *it;
if (!readStyle(lex, *defaultLayout)) {
// The only way this happens is because the hardcoded layout above
// is wrong.
- LASSERT(false, /**/);
+ LATTEST(false);
};
return *defaultLayout;
}
#include "support/debug.h"
#include "support/docstring_list.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <cstdlib>
TextMetrics::TextMetrics(BufferView * bv, Text * text)
: bv_(bv), text_(text)
{
- LASSERT(bv_, /**/);
+ LBUFERR(bv_, _("Text metrics error."));
max_width_ = bv_->workWidth();
dim_.wid = max_width_;
dim_.asc = 10;
pair<pit_type, ParagraphMetrics const *> TextMetrics::last() const
{
- LASSERT(!par_metrics_.empty(), /**/);
+ LBUFERR(!par_metrics_.empty(), _("Text metrics error."));
ParMetricsCache::const_reverse_iterator it = par_metrics_.rbegin();
return make_pair(it->first, &it->second);
}
bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
{
- LASSERT(mi.base.textwidth > 0, /**/);
+ LBUFERR(mi.base.textwidth > 0, _("Text metrics error."));
max_width_ = mi.base.textwidth;
// backup old dimension.
Dimension const old_dim = dim_;
Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
{
- LASSERT(pos >= 0, /**/);
+ LASSERT(pos >= 0, { static Font f; return f; });
ParagraphList const & pars = text_->paragraphs();
Paragraph const & par = pars[pit];
// should be.
bv_->buffer().updateBuffer();
parPos = text_->macrocontextPosition();
- LASSERT(!parPos.empty(), /**/);
+ LBUFERR(!parPos.empty(), _("Text metrics error."));
parPos.pit() = pit;
}
Paragraph const & par = text_->getPar(pit);
pos_type last = par.beginOfBody();
- LASSERT(last > 0, /**/);
+ LBUFERR(last > 0, _("Text metrics error."));
// -1 because a label ends with a space that is in the label
--last;
left_side = true;
}
- LASSERT(vc <= end, /**/); // This shouldn't happen.
+ // This shouldn't happen. But we can reset and try to continue.
+ LASSERT(vc <= end, vc = end);
boundary = false;
// upDownInText() while in selection mode.
ParagraphMetrics const & pm = parMetrics(pit);
- LASSERT(row < int(pm.rows().size()), /**/);
+ LBUFERR(row < int(pm.rows().size()), _("Text metrics error."));
bool bound = false;
Row const & r = pm.rows()[row];
return r.pos() + getColumnNearX(pit, r, x, bound);
ParagraphMetrics const & pm = par_metrics_[pit];
int yy = pm.position() - pm.ascent();
- LASSERT(!pm.rows().empty(), /**/);
+ LBUFERR(!pm.rows().empty(), _("Text metrics error."));
RowList::const_iterator rit = pm.rows().begin();
RowList::const_iterator rlast = pm.rows().end();
--rlast;
void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x, int const y)
{
- LASSERT(text_ == cur.text(), /**/);
+ LASSERT(text_ == cur.text(), return);
pit_type const pit = getPitNearY(y);
LASSERT(pit != -1, return);
" pit: " << pit << " yy: " << yy);
int r = 0;
- LASSERT(pm.rows().size(), /**/);
+ LBUFERR(pm.rows().size(), _("Text metrics error."));
for (; r < int(pm.rows().size()) - 1; ++r) {
Row const & row = pm.rows()[r];
if (int(yy + row.height()) > y)
int TextMetrics::cursorX(CursorSlice const & sl,
bool boundary) const
{
- LASSERT(sl.text() == text_, /**/);
+ LASSERT(sl.text() == text_, return 0);
pit_type const pit = sl.pit();
Paragraph const & par = text_->paragraphs()[pit];
ParagraphMetrics const & pm = par_metrics_[pit];
bool TextMetrics::cursorHome(Cursor & cur)
{
- LASSERT(text_ == cur.text(), /**/);
+ LASSERT(text_ == cur.text(), return false);
ParagraphMetrics const & pm = par_metrics_[cur.pit()];
Row const & row = pm.getRow(cur.pos(),cur.boundary());
return text_->setCursor(cur, cur.pit(), row.pos());
bool TextMetrics::cursorEnd(Cursor & cur)
{
- LASSERT(text_ == cur.text(), /**/);
+ LASSERT(text_ == cur.text(), return false);
// if not on the last row of the par, put the cursor before
// the final space exept if I have a spanning inset or one string
// is so long that we force a break.
void TextMetrics::deleteLineForward(Cursor & cur)
{
- LASSERT(text_ == cur.text(), /**/);
+ LASSERT(text_ == cur.text(), return);
if (cur.lastpos() == 0) {
// Paragraph is empty, so we just go forward
text_->cursorForward(cur);
int TextMetrics::leftMargin(int max_width, pit_type pit) const
{
- LASSERT(pit >= 0, /**/);
- LASSERT(pit < int(text_->paragraphs().size()), /**/);
return leftMargin(max_width, pit, text_->paragraphs()[pit].size());
}
{
ParagraphList const & pars = text_->paragraphs();
- LASSERT(pit >= 0, /**/);
- LASSERT(pit < int(pars.size()), /**/);
+ LASSERT(pit >= 0, return 0);
+ LASSERT(pit < int(pars.size()), return 0);
Paragraph const & par = pars[pit];
- LASSERT(pos >= 0, /**/);
- LASSERT(pos <= par.size(), /**/);
+ LASSERT(pos >= 0, return 0);
+ LASSERT(pos <= par.size(), return 0);
Buffer const & buffer = bv_->buffer();
//lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
DocumentClass const & tclass = buffer.params().documentClass();
{
TocList::const_iterator toclist_it = tocs_.find(type);
// Is the type supported?
- LASSERT(toclist_it != tocs_.end(), /**/);
+ // We will try to make the best of it in release mode
+ LASSERT(toclist_it != tocs_.end(), toclist_it = tocs_.begin());
return toclist_it->second.item(dit);
}
#include "insets/Inset.h"
-#include "support/lassert.h"
#include "support/debug.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
#include <algorithm>
#include <deque>
// main Text _is_ the whole document.
// record the relevant paragraphs
Text const * text = cell.text();
- LASSERT(text, /**/);
+ LBUFERR(text, _("Uninitialized cell."));
ParagraphList const & plist = text->paragraphs();
ParagraphList::const_iterator first = plist.begin();
advance(first, first_pit);
CursorData const & cur,
bool isFullBuffer)
{
- LASSERT(first_pit <= cell.lastpit(), /**/);
- LASSERT(last_pit <= cell.lastpit(), /**/);
+ LASSERT(first_pit <= cell.lastpit(), return);
+ LASSERT(last_pit <= cell.lastpit(), return);
doRecordUndo(kind, cell, first_pit, last_pit, cur,
isFullBuffer, undostack_);
//LYXERR0("undo, performing: " << undo);
DocIterator dit = undo.cell.asDocIterator(&buffer_);
if (undo.isFullBuffer) {
- LASSERT(undo.pars, /**/);
+ LBUFERR(undo.pars, _("Undo stack is corrupt!"));
// This is a full document
delete otherstack.top().bparams;
otherstack.top().bparams = new BufferParams(buffer_.params());
// gained by storing just 'a few' paragraphs (most if not
// all math inset cells have just one paragraph!)
//LYXERR0("undo.array: " << *undo.array);
- LASSERT(undo.array, /**/);
+ LBUFERR(undo.array, _("Undo stack is corrupt!"));
dit.cell().swap(*undo.array);
delete undo.array;
undo.array = 0;
} else {
// Some finer machinery is needed here.
Text * text = dit.text();
- LASSERT(text, /**/);
- LASSERT(undo.pars, /**/);
+ LBUFERR(text, _("Invalid cursor."));
+ LBUFERR(undo.pars, _("Undo stack is corrupt!"));
ParagraphList & plist = text->paragraphs();
// remove new stuff between first and last
delete undo.pars;
undo.pars = 0;
}
- LASSERT(undo.pars == 0, /**/);
- LASSERT(undo.array == 0, /**/);
+
+ // We'll clean up in release mode.
+ LASSERT(undo.pars == 0, undo.pars = 0);
+ LASSERT(undo.array == 0, undo.array = 0);
if (!undo.cur_before.empty())
cur = undo.cur_before;
: "\\vspace{" + len_.asLatexString() + '}';
default:
- LASSERT(false, /**/);
- return string();
+ LATTEST(false);
+ // fall through in release mode
}
+ return string();
}
return len_.len().inPixels(bv.workWidth());
default:
- LASSERT(false, /**/);
- return 0;
+ LATTEST(false);
+ // fall through in release mode
}
+ return 0;
}
docstring const & WordList::word(size_t idx) const
{
Impl::Words::const_iterator it = d->words_.find_summed_weight(idx);
- LASSERT(it != d->words_.end(), /**/);
+ LASSERT(it != d->words_.end(), { static docstring dummy; return dummy; });
// We use the key() method here, and not something like it->first
// because the btree only returns (iterator-) temporary value pairs.
#include "insets/Inset.h"
#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <QLabel>
Buffer const & Dialog::buffer() const
{
- LASSERT(lyxview_->currentBufferView(), /**/);
+ LAPPERR(lyxview_->currentBufferView(),
+ _("Dialog has no associated Buffer!"));
return lyxview_->currentBufferView()->buffer();
}
Buffer const & Dialog::documentBuffer() const
{
- LASSERT(lyxview_->documentBufferView(), /**/);
+ LAPPERR(lyxview_->currentBufferView(),
+ _("Dialog has no associated Buffer!"));
return lyxview_->documentBufferView()->buffer();
}
}
-/** Switch p_buf to point to next document buffer.
+/** Switch buf to point to next document buffer.
**
** Return true if restarted from master-document buffer.
**/
LYXERR(Debug::FIND, "children.size()=" << children.size());
ListOfBuffers::const_iterator it =
find(children.begin(), children.end(), buf);
- LASSERT(it != children.end(), /**/);
+ LASSERT(it != children.end(), return false);
++it;
if (it == children.end()) {
buf = *children.begin();
LYXERR(Debug::FIND, "children.size()=" << children.size());
ListOfBuffers::const_iterator it =
find(children.begin(), children.end(), buf);
- LASSERT(it != children.end(), /**/)
+ LASSERT(it != children.end(), return false)
if (it == children.begin()) {
it = children.end();
--it;
else if (AllManualsRB->isChecked())
scope = FindAndReplaceOptions::S_ALL_MANUALS;
else
- LASSERT(false, /**/);
+ LATTEST(false);
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
<< "find_buf_name=" << find_buf_name
<< ", casesensitiv=" << casesensitive
{
PngMap const * const begin = sorted_png_map;
PngMap const * const end = begin + nr_sorted_png_map;
- LASSERT(sorted(begin, end), /**/);
+ LATTEST(sorted(begin, end));
PngMap const * const it = find_if(begin, end, CompareKey(name));
return;
BookmarksSection::Bookmark const & bm =
theSession().bookmarks().bookmark(idx);
- LASSERT(!bm.filename.empty(), /**/);
+ LASSERT(!bm.filename.empty(), return);
string const file = bm.filename.absFileName();
// if the file is not opened, open it.
if (!theBufferList().exists(bm.filename)) {
void GuiApplication::unregisterView(GuiView * gv)
{
- LASSERT(d->views_[gv->id()] == gv, /**/);
+ LAPPERR(d->views_[gv->id()] == gv, _("Application error."));
d->views_.remove(gv->id());
if (current_view_ == gv)
current_view_ = 0;
GuiView & GuiApplication::view(int id) const
{
- LASSERT(d->views_.contains(id), /**/);
+ LAPPERR(d->views_.contains(id), _("Application error.") /**/);
return *d->views_.value(id);
}
frontend::FontLoader & theFontLoader()
{
- LASSERT(frontend::guiApp, /**/);
+ LAPPERR(frontend::guiApp, _("No Gui Application."));
return frontend::guiApp->fontLoader();
}
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
{
- LASSERT(frontend::guiApp, /**/);
+ LAPPERR(frontend::guiApp, _("No Gui Application."));
return frontend::guiApp->fontLoader().metrics(f);
}
frontend::Clipboard & theClipboard()
{
- LASSERT(frontend::guiApp, /**/);
+ LAPPERR(frontend::guiApp, _("No Gui Application."));
return frontend::guiApp->clipboard();
}
frontend::Selection & theSelection()
{
- LASSERT(frontend::guiApp, /**/);
+ LAPPERR(frontend::guiApp, _("No Gui Application."));
return frontend::guiApp->selection();
}
types.push_back(Clipboard::PngGraphicsType);
if (hasGraphicsContents(Clipboard::JpegGraphicsType))
types.push_back(Clipboard::JpegGraphicsType);
-
- LASSERT(!types.empty(), /**/);
-
+
+ LASSERT(!types.empty(), return FileName());
+
// select prefered type if AnyGraphicsType was passed
if (type == Clipboard::AnyGraphicsType)
type = types.front();
else if (type == JpegGraphicsType)
image.save(toqstr(filename.absFileName()), "JPEG");
else
- LASSERT(false, /**/);
+ LATTEST(false);
return filename;
}
case LinkBackGraphicsType: mime = pdfMimeType(); break;
case EmfGraphicsType: mime = emfMimeType(); break;
case WmfGraphicsType: mime = wmfMimeType(); break;
- default: LASSERT(false, /**/);
+ default: LASSERT(false, return FileName());
}
// get data
ds << pdfLen; // big endian by default
#else
// only non-Mac this should never happen
- LASSERT(false, /**/);
+ LATTEST(false);
#endif // Q_WS_MACX
}
case EmfGraphicsType: mime = emfMimeType(); break;
case WmfGraphicsType: mime = wmfMimeType(); break;
case PdfGraphicsType: mime = pdfMimeType(); break;
- default: LASSERT(false, /**/);
+ default: LASSERT(false, return false);
}
return cache_.hasFormat(mime);
i = n;
else
i = l;
- LASSERT(i <= n, /**/);
+ // we can try to recover
+ LASSERT(i <= n, i = 0);
}
// select the first if none was found
#include "support/convert.h"
#include "support/debug.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/Systemcall.h"
#include "support/Package.h"
static GuiFontInfo * fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE];
-/// Get font info (font + metrics) for the given LyX font.
+// Get font info (font + metrics) for the given LyX font.
// if not cached, create it.
GuiFontInfo & fontinfo(FontInfo const & f)
{
- LASSERT(f.family() < NUM_FAMILIES, /**/);
- LASSERT(f.series() < NUM_SERIES, /**/);
- LASSERT(f.realShape() < NUM_SHAPE, /**/);
- LASSERT(f.size() < NUM_SIZE, /**/);
+ // LASSERT: Is there anything we might do here besides crash?
+ LBUFERR(f.family() < NUM_FAMILIES, _("Font lookup error."));
+ LBUFERR(f.series() < NUM_SERIES, _("Font lookup error."));
+ LBUFERR(f.realShape() < NUM_SHAPE, _("Font lookup error."));
+ LBUFERR(f.size() < NUM_SIZE, _("Font lookup error."));
// fi is a reference to the pointer type (GuiFontInfo *) in the
// fontinfo_ table.
GuiFontInfo * & fi =
**/
inline QChar const ucs4_to_qchar(char_type const ucs4)
{
- LASSERT(is_utf16(ucs4), /**/);
+ LATTEST(is_utf16(ucs4));
return QChar(static_cast<unsigned short>(ucs4));
}
} // anon namespace
}
// If we assert here, it's because we're trying to set an
// unrecognized role.
- LASSERT(false, return false);
- return false; // silence the warning
+ LATTEST(false);
+ return false;
}
return 0;
// UTF16 has a maximum of two characters.
- LASSERT(text_.size() <= 2, /**/);
+ LASSERT(text_.size() <= 2, return 0);
if (lyxerr.debugging() && text_.size() > 1) {
// We don't know yet how well support the full ucs4 range.
void GuiPainter::leaveMonochromeMode()
{
- LASSERT(!monochrome_min_.empty(), /**/);
+ LASSERT(!monochrome_min_.empty(), return);
monochrome_min_.pop();
monochrome_max_.pop();
}
// It is not a tabbed work area (i.e., the search work area), so it
// should be deleted by other means.
- LASSERT(found_twa, /* */);
+ LASSERT(found_twa, return);
if (d.current_work_area_ == 0) {
if (d.splitter_->count() != 0) {
string s = fromqstr(filter);
size_t pos = s.find(" (*.");
- LASSERT(pos != string::npos, /**/);
+ LATTEST(pos != string::npos);
string fmt_prettyname = s.substr(0, pos);
string fmt_name;
fname.set(fromqstr(result.second));
void GuiView::dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr)
{
BufferView * bv = currentBufferView();
- LASSERT(bv, /**/);
+ LASSERT(bv, return);
// Let the current BufferView dispatch its own actions.
bv->dispatch(cmd, dr);
case LITERATE:
return qt_("Literate Source");
}
- LASSERT(false, /**/);
+ LATTEST(false);
return QString();
}
return 0;
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(currentWidget());
- LASSERT(wa, /**/);
+ LATTEST(wa);
return wa;
}
{
while (count()) {
GuiWorkArea * wa = workArea(0);
- LASSERT(wa, /**/);
+ LASSERT(wa, return);
removeTab(0);
delete wa;
}
bool TabWorkArea::setCurrentWorkArea(GuiWorkArea * work_area)
{
- LASSERT(work_area, /**/);
+ LASSERT(work_area, return false);
int index = indexOf(work_area);
if (index == -1)
return false;
wa = currentWorkArea();
else {
wa = workArea(clicked_tab_);
- LASSERT(wa, /**/);
+ LASSERT(wa, return);
}
wa->view().closeWorkArea(wa);
}
wa = currentWorkArea();
else {
wa = workArea(clicked_tab_);
- LASSERT(wa, /**/);
+ LASSERT(wa, return);
}
wa->view().hideWorkArea(wa);
}
wa = currentWorkArea();
else {
wa = workArea(index);
- LASSERT(wa, /**/);
+ LASSERT(wa, return);
}
wa->view().closeWorkArea(wa);
}
layout_->filter();
for (int i = 0; i < f.length(); ++i) {
int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
- LASSERT(p != -1, /**/);
+ LASSERT(p != -1, continue);
if (lastp == p - 1 && lastp != -1) {
// remove ")" and append "x)"
r = r.left(r.length() - 4) + s[p] + "</u>";
// We do not call our implementation of showPopup because that
// would reset the filter again. This is only needed if the user clicks
// on the QComboBox.
- LASSERT(!inShowPopup_, /**/);
+ LATTEST(!inShowPopup_);
inShowPopup_ = true;
p->QComboBox::showPopup();
inShowPopup_ = false;
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
// the hack in the item delegate to make space for the headers.
- LASSERT(!d->inShowPopup_, /**/);
+ LATTEST(!d->inShowPopup_);
d->inShowPopup_ = true;
QComboBox::showPopup();
d->inShowPopup_ = false;
: kind_(kind), label_(label), submenuname_(submenu),
tooltip_(tooltip), optional_(optional)
{
- LASSERT(kind == Submenu || kind == Help || kind == Info, /**/);
+ LATTEST(kind == Submenu || kind == Help || kind == Info);
}
MenuItem(Kind kind,
action = LFUN_BUFFER_EXPORT;
break;
default:
- LASSERT(false, /* */);
+ LATTEST(false);
return;
}
sort(formats.begin(), formats.end(), Format::formatSorter);
continue;
break;
default:
- LASSERT(false, /* */);
+ // we already asserted earlier in this case
+ // LATTEST(false);
continue;
}
if (!shortcut.empty())
{
const_iterator cit = find_if(menulist_.begin(), menulist_.end(),
MenuNamesEqual(name));
- if (cit == menulist_.end())
+ if (cit == menulist_.end()) {
LYXERR0("No submenu named " << name);
- LASSERT(cit != menulist_.end(), /**/);
+ LASSERT(false, { static const MenuDefinition m; return m; });
+ }
return (*cit);
}
{
iterator it = find_if(menulist_.begin(), menulist_.end(),
MenuNamesEqual(name));
- if (it == menulist_.end())
+ if (it == menulist_.end()) {
LYXERR0("No submenu named " << name);
- LASSERT(it != menulist_.end(), /**/);
+ LASSERT(false, { static MenuDefinition m; return m; });
+ }
return (*it);
}
FormatList const & formats = Cache::get().loadableFormats();
// There must be a format to load from.
- LASSERT(!formats.empty(), /**/);
+ LASSERT(!formats.empty(), return string());
// Use the standard converter if we don't know the format to load
// from.
string const & to_format,
ostream & script)
{
- LASSERT(from_format != to_format, /**/);
+ LASSERT(from_format != to_format, return);
LYXERR(Debug::GRAPHICS, "build_script ... ");
typedef Graph::EdgePath EdgePath;
case TO_END:
return;
-
- default:
- lex.printError("external::Template::readTemplate: "
- "Wrong tag: $$Token");
- LASSERT(false, /**/);
- break;
}
}
}
LYXERR0("Inset: " << this << " LyX Code: " << lyxCode()
<< " name: " << iname);
s << "LyX Code: " << lyxCode() << " name: " << iname;
- LASSERT(false, /**/);
+ LATTEST(false);
throw ExceptionMessage(BufferException,
from_ascii("Inset::buffer_ member not initialized!"), s.str());
}
namespace lyx {
/// Get information for \p code and command \p cmdName.
-/// Returns 0 if the combination is not known. [FIXME: 0?]
/// Don't call this without first making sure the command name is
/// acceptable to the inset.
static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
case TOC_CODE:
return InsetTOC::findInfo(cmdName);
default:
- LASSERT(false, /**/);
+ LATTEST(false);
+ // fall through in release mode
}
- static ParamInfo pi;
- return pi; // to silence the warning
+ static const ParamInfo pi;
+ return pi;
}
ParamInfo::ParamData const &
ParamInfo::operator[](std::string const & name) const
{
- LASSERT(hasParam(name), /**/);
const_iterator it = begin();
const_iterator last = end();
for (; it != last; ++it) {
if (it->name() == name)
return *it;
}
- return *it; // silence warning
+ LATTEST(false);
+ // we will try to continue in release mode
+ static const ParamData pd("asdfghjkl", LYX_INTERNAL);
+ return pd;
}
case TOC_CODE:
return InsetTOC::defaultCommand();
default:
- LASSERT(false, /**/);
+ LATTEST(false);
+ // fall through in release mode
}
- return string(); // silence the warning
+ return string();
}
return InsetRef::isCompatibleCommand(s);
case TOC_CODE:
return InsetTOC::isCompatibleCommand(s);
- default:
- LASSERT(false, /**/);
+ default:
+ LATTEST(false);
+ // fall through in release mode
}
- return false; // silence the warning
+ return false;
}
bool InsetCommandParams::writeEmptyOptional(ParamInfo::const_iterator ci) const
{
- if (!ci->isOptional()) {
- LASSERT(false, /**/);
- }
+ LASSERT(ci->isOptional(), return false);
+
++ci; // we want to start with the next one
ParamInfo::const_iterator end = info_.end();
for (; ci != end; ++ci) {
ParamInfo::const_iterator it =
find_if(info_.begin(), info_.end(),
not1(mem_fun_ref(&ParamInfo::ParamData::isOptional)));
- if (it == info_.end()) {
- LASSERT(false, return docstring());
- }
+ LASSERT(it != info_.end(), return docstring());
return (*this)[it->name()];
}
docstring const & InsetCommandParams::operator[](string const & name) const
{
- static const docstring dummy; //so we don't return a ref to temporary
+ static const docstring dummy;
LASSERT(info_.hasParam(name), return dummy);
ParamMap::const_iterator data = params_.find(name);
if (data == params_.end() || data->second.empty())
docstring & InsetCommandParams::operator[](string const & name)
{
- LASSERT(info_.hasParam(name), /**/);
+ LATTEST(info_.hasParam(name));
+ // this will add the name in release mode
return params_[name];
}
return;
RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
- LASSERT(ptr, /**/);
+ LASSERT(ptr, return);
ptr->removePreview(*buffer);
add_preview_and_start_loading(*ptr, *this, *buffer);
temp = listings_label_;
break;
case NONE:
- LASSERT(false, /**/);
+ LASSERT(false, temp = buffer().B_("Unknown"));
+ break;
}
temp += ": ";
void InsetInclude::validate(LaTeXFeatures & features) const
{
- string incfile = to_utf8(params()["filename"]);
- string writefile;
-
- LASSERT(&buffer() == &features.buffer(), /**/);
+ LATTEST(&buffer() == &features.buffer());
+ string incfile = to_utf8(params()["filename"]);
string const included_file =
includedFileName(buffer(), params()).absFileName();
+ string writefile;
if (isLyXFileName(included_file))
writefile = changeExtension(included_file, ".sgml");
else
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
{
- LASSERT(mi.base.bv, /**/);
+ LBUFERR(mi.base.bv, _("Text metrics error."));
bool use_preview = false;
if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
{
- LASSERT(pi.base.bv, /**/);
+ LBUFERR(pi.base.bv, _("Painter has no BufferView!"));
bool use_preview = false;
if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
params.math = true;
else {
params.math = false;
- LASSERT(name == "space", /**/);
+ // we can try to read this even if the name is wrong
+ LATTEST(name == "space");
}
// There are cases, such as when we are called via getStatus() from
string const & command = getCmdName();
if (command != "tableofcontents" && command != "lstlistoflistings") {
LYXERR0("TOC type " << command << " not yet implemented.");
- LASSERT(false, /* */);
- return docstring();
+ LASSERT(false, return docstring());
}
Toc const & toc = buffer().tocBackend().toc(cmd2type(command));
l_getline(is, line);
if (!prefixIs(line, "<lyxtabular ") && !prefixIs(line, "<Tabular ")) {
- LASSERT(false, /**/);
- return;
+ LASSERT(false, return);
}
int version;
if (!getTokenValue(line, "version", version))
return;
- LASSERT(version >= 2, /**/);
+ LATTEST(version >= 2);
int rows_arg;
if (!getTokenValue(line, "rows", rows_arg))
Tabular::idx_type Tabular::cellIndex(row_type row, col_type column) const
{
- LASSERT(column != npos && column < ncols()
- && row != npos && row < nrows(), /**/);
+ LASSERT(column != npos && column < ncols(), column = 0);
+ LASSERT(row != npos && row < nrows(), row = 0);
return cell_info[row][column].cellno;
}
int Tabular::rowAscent(row_type row) const
{
- LASSERT(row < nrows(), /**/);
+ LASSERT(row < nrows(), row = 0);
return row_info[row].ascent;
}
int Tabular::rowDescent(row_type row) const
{
- LASSERT(row < nrows(), /**/);
+ LASSERT(row < nrows(), row = 0);
return row_info[row].descent;
}
bool Tabular::isPartOfMultiColumn(row_type row, col_type column) const
{
- LASSERT(row < nrows(), /**/);
- LASSERT(column < ncols(), /**/);
+ LASSERT(row < nrows(), return false);
+ LASSERT(column < ncols(), return false);
return cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN;
}
bool Tabular::isPartOfMultiRow(row_type row, col_type column) const
{
- LASSERT(row < nrows(), /**/);
- LASSERT(column < ncols(), /**/);
+ LASSERT(row < nrows(), return false);
+ LASSERT(column < ncols(), return false);
return cell_info[row][column].multirow == CELL_PART_OF_MULTIROW;
}
{
//lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
// mi.base.textwidth << "\n";
- if (!mi.base.bv) {
- LYXERR0("need bv");
- LASSERT(false, /**/);
- }
+ LBUFERR(mi.base.bv, _("Text metrics error."));
for (row_type r = 0; r < tabular.nrows(); ++r) {
int maxasc = 0;
bool InsetTabular::isRightToLeft(Cursor & cur) const
{
- LASSERT(cur.depth() > 1, /**/);
+ // LASSERT: It might be better to abandon this Buffer.
+ LASSERT(cur.depth() > 1, return false);
Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
pos_type const parentpos = cur[cur.depth() - 2].pos();
return parentpar.getFontSettings(buffer().params(),
void InsetText::clear()
{
ParagraphList & pars = paragraphs();
- LASSERT(!pars.empty(), /**/);
+ LBUFERR(!pars.empty(), _("Buffer corrupt!"));
// This is a gross hack...
Layout const & old_layout = pars.begin()->layout();
// find text inset in old cursor
Cursor insetCur = old;
int scriptSlice = insetCur.find(this);
- LASSERT(scriptSlice != -1, /**/);
+ // we can try to continue here. returning true means
+ // the cursor is "now" invalid. which it was.
+ LASSERT(scriptSlice != -1, return true);
insetCur.cutOff(scriptSlice);
- LASSERT(&insetCur.inset() == this, /**/);
+ LASSERT(&insetCur.inset() == this, return true);
// update the old paragraph's words
insetCur.paragraph().updateWords();
bool InsetText::completionSupported(Cursor const & cur) const
{
- //LASSERT(&cur.bv().cursor().inset() != this, return false);
+ //LASSERT(&cur.bv().cursor().inset() == this, return false);
return text_.completionSupported(cur);
}
void InsetVSpace::read(Lexer & lex)
{
- LASSERT(lex.isOK(), /**/);
+ LASSERT(lex.isOK(), return);
string vsp;
lex >> vsp;
if (lex)
docstring const statusMessage(BufferView const * bv, string const & snippet)
{
- LASSERT(bv, /**/);
+ LASSERT(bv, return docstring());
Buffer const & buffer = bv->buffer();
graphics::PreviewLoader const * loader = buffer.loader();
void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
{
- LASSERT(mi.base.bv, /**/);
+ LBUFERR(mi.base.bv, _("Text metrics error."));
graphics::PreviewImage const * const pimage =
getPreviewImage(mi.base.bv->buffer());
void RenderPreview::draw(PainterInfo & pi, int x, int y) const
{
- LASSERT(pi.base.bv, /**/);
+ LBUFERR(pi.base.bv, _("Painter has no BufferView!"));
graphics::PreviewImage const * const pimage =
getPreviewImage(pi.base.bv->buffer());
cap::replaceSelectionWithString(cur, replacestr);
if (forward) {
cur.pos() += replacestr.length();
- LASSERT(cur.pos() <= cur.lastpos(), /* */);
+ LASSERT(cur.pos() <= cur.lastpos(),
+ cur.pos() = cur.lastpos());
}
if (findnext)
findOne(bv, searchstr, case_sens, whole, forward, false);
LYXERR(Debug::FIND, " with cur.lastpost=" << cur.lastpos() << ", cur.lastrow="
<< cur.lastrow() << ", cur.lastcol=" << cur.lastcol());
Buffer const & buf = *cur.buffer();
- LASSERT(buf.params().isLatex(), /* */);
+ LBUFERR(buf.params().isLatex(), _("Buffer type mismatch."));
TexRow texrow;
odocstringstream ods;
cur.forwardPos();
} while (cur && cur.depth() > d && match(cur) > 0);
cur = old_cur;
- LASSERT(match(cur) > 0, /* */);
+ LASSERT(match(cur) > 0, return 0);
LYXERR(Debug::FIND, "Ok");
// Compute the match length
docstring stringifyFromForSearch(FindAndReplaceOptions const & opt,
DocIterator const & cur, int len)
{
- LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(), /* */);
+ LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(),
+ return docstring());
if (!opt.ignoreformat)
return latexifyFromCursor(cur, len);
else
<< ", sel_len: " << sel_len << endl);
if (sel_len == 0)
return;
- LASSERT(sel_len > 0, /**/);
+ LASSERT(sel_len > 0, return);
if (!matchAdv(sel_beg, sel_len))
return;
string lyx = oss.str();
Buffer repl_buffer("", false);
repl_buffer.setUnnamed(true);
- LASSERT(repl_buffer.readString(lyx), /**/);
+ LASSERT(repl_buffer.readString(lyx), return);
if (opt.keep_case && sel_len >= 2) {
if (cur.inTexted()) {
if (firstUppercase(cur))
OutputParams const &, size_t) const
{
// all math plain text output shall take place in InsetMathHull
- LASSERT(false, /**/);
+ LATTEST(false);
return 0;
}
docstring & special = colinfo_[cur.col()].special_;
if (!special.empty()) {
docstring::size_type i = special.rfind('|');
- LASSERT(i != docstring::npos, /**/);
+ LASSERT(i != docstring::npos, break);
special.erase(i, 1);
}
}
docstring & special = colinfo_[cur.col()+1].special_;
if (!special.empty()) {
docstring::size_type i = special.find('|');
- LASSERT(i != docstring::npos, /**/);
+ LASSERT(i != docstring::npos, break);
special.erase(i, 1);
}
}
docstring InsetMathHull::label(row_type row) const
{
- LASSERT(row < nrows(), /**/);
+ LASSERT(row < nrows(), return docstring());
if (InsetLabel * il = label_[row])
return il->screenLabel();
return docstring();
void InsetMathHull::splitTo2Cols()
{
- LASSERT(ncols() == 1, /**/);
+ LASSERT(ncols() == 1, return);
InsetMathGrid::addCol(1);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
void InsetMathHull::splitTo3Cols()
{
- LASSERT(ncols() < 3, /**/);
+ LASSERT(ncols() < 3, return);
if (ncols() < 2)
splitTo2Cols();
InsetMathGrid::addCol(2);
void InsetMathHull::check() const
{
- LASSERT(numbered_.size() == nrows(), /**/);
- LASSERT(numbers_.size() == nrows(), /**/);
- LASSERT(label_.size() == nrows(), /**/);
+ LATTEST(numbered_.size() == nrows());
+ LATTEST(numbers_.size() == nrows());
+ LATTEST(label_.size() == nrows());
}
// to touch all (math)inset's draw() methods. Right now, we'll store
// absolute value, and make them here relative, only to make them
// absolute again when actually drawing the cursor. What a mess.
- LASSERT(&sl.inset() == this, /**/);
+ LASSERT(&sl.inset() == this, return);
MathData const & ar = sl.cell();
CoordCache const & coord_cache = bv.coordCache();
if (!coord_cache.getArrays().has(&ar)) {
bool InsetMathNest::idxNext(Cursor & cur) const
{
- LASSERT(&cur.inset() == this, /**/);
+ LASSERT(&cur.inset() == this, return false);
if (cur.idx() == cur.lastidx())
return false;
++cur.idx();
bool InsetMathNest::idxPrev(Cursor & cur) const
{
- LASSERT(&cur.inset() == this, /**/);
+ LASSERT(&cur.inset() == this, return false);
if (cur.idx() == 0)
return false;
--cur.idx();
bool InsetMathNest::idxFirst(Cursor & cur) const
{
- LASSERT(&cur.inset() == this, /**/);
+ LASSERT(&cur.inset() == this, return false);
if (nargs() == 0)
return false;
cur.idx() = 0;
bool InsetMathNest::idxLast(Cursor & cur) const
{
- LASSERT(&cur.inset() == this, /**/);
+ LASSERT(&cur.inset() == this, return false);
if (nargs() == 0)
return false;
cur.idx() = cur.lastidx();
cur.backspace();
cur.niceInsert(MathAtom(new InsetMathComment(buf)));
} else if (c == '#') {
- LASSERT(cur.activeMacro(), /**/);
+ LASSERT(cur.activeMacro(), return false);
cur.activeMacro()->setName(name + docstring(1, c));
} else {
cur.backspace();
#include "MathSupport.h"
#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lassert.h"
InsetMathScript::InsetMathScript(Buffer * buf, MathAtom const & at, bool up)
: InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
{
- LASSERT(nargs() >= 1, /**/);
+ LATTEST(nargs() >= 1);
cell(0).push_back(at);
}
{
if (nargs() == 3)
return cell(2);
- LASSERT(nargs() > 1, /**/);
+ LBUFERR(nargs() > 1, _("Invalid number of math cells."));
return cell(1);
}
{
if (nargs() == 3)
return cell(2);
- LASSERT(nargs() > 1, /**/);
+ LBUFERR(nargs() > 1, _("Invalid number of math cells."));
return cell(1);
}
MathData const & InsetMathScript::up() const
{
- LASSERT(nargs() > 1, /**/);
+ LBUFERR(nargs() > 1, _("Invalid number of math cells."));
return cell(1);
}
MathData & InsetMathScript::up()
{
- LASSERT(nargs() > 1, /**/);
+ LBUFERR(nargs() > 1, _("Invalid number of math cells."));
return cell(1);
}
int InsetMathScript::dx0(BufferView const & bv) const
{
- LASSERT(hasDown(), /**/);
+ LASSERT(hasDown(), return 0);
Dimension const dim = dimension(bv);
return hasLimits() ? (dim.wid - down().dimension(bv).width()) / 2 : nwid(bv);
}
int InsetMathScript::dx1(BufferView const & bv) const
{
- LASSERT(hasUp(), /**/);
+ LASSERT(hasUp(), return 0);
Dimension const dim = dimension(bv);
return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(&bv);
}
return (cell_1_is_up_ == up) ? 1 : 0;
if (nargs() == 3)
return up ? 1 : 2;
- LASSERT(false, /**/);
- // Silence compiler
- return 0;
+ LASSERT(false, return 0);
}
InsetSpaceParams InsetMathSpace::params() const
{
- LASSERT(space_info[space_].visible, /**/);
InsetSpaceParams isp(true);
+ LASSERT(space_info[space_].visible, return isp);
isp.kind = space_info[space_].kind;
isp.length = GlueLength(length_);
return isp;
else if (name == "textbackslash")
char_ = '\\';
else
- LASSERT(false, /**/);
+ LASSERT(false, char_ = '?');
} else
char_ = name.at(0);
}
}
-void InsetMathString::mathmlize(MathStream & /*os*/) const
+void InsetMathString::mathmlize(MathStream &) const
{
// useless, no doubt, but we should not be here
- LASSERT(false, /* */);
+ LATTEST(false);
}
#include "Text.h"
#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <sstream>
void MacroData::unlock() const
{
--lockCount_;
- LASSERT(lockCount_ >= 0, /**/);
+ LASSERT(lockCount_ >= 0, lockCount_ = 0);
}
if (queried_)
return;
- LASSERT(buffer_ != 0, /**/);
+ LBUFERR(buffer_, _("Corrupt macro data!"));
// Try to fix position DocIterator. Should not do anything in theory.
pos_.fixIfBroken();
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <boost/next_prior.hpp>
MathAtom & MathData::operator[](pos_type pos)
{
- LASSERT(pos < size(), /**/);
+ LBUFERR(pos < size(), _("Invalid MathData."));
return base_type::operator[](pos);
}
MathAtom const & MathData::operator[](pos_type pos) const
{
- LASSERT(pos < size(), /**/);
+ LBUFERR(pos < size(), _("Invalid MathData."));
return base_type::operator[](pos);
}
void MathData::insert(size_type pos, MathData const & ar)
{
- LASSERT(pos <= size(), /**/);
+ LBUFERR(pos < size(), _("Invalid MathData."));
base_type::insert(begin() + pos, ar.begin(), ar.end());
}
InsetMath * inset = operator[](i).nucleus();
if (inset->asScriptInset())
inset = inset->asScriptInset()->nuc()[0].nucleus();
- LASSERT(inset->asMacro(), /**/);
+ LASSERT(inset->asMacro(), continue);
inset->asMacro()->updateRepresentation(cur, mc, utype);
}
}
#include "frontends/Painter.h"
#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include "support/textutils.h"
&& editing_[mi.base.bv]) {
// Macro will be edited in a old-style list mode here:
- LASSERT(macro_ != 0, /**/);
+ LBUFERR(macro_, _("Text metrics error."));
Dimension fontDim;
FontInfo labelFont = sane_font;
math_font_max_dim(labelFont, fontDim.asc, fontDim.des);
dim.wid += 2;
metricsMarkers2(dim);
} else {
- LASSERT(macro_ != 0, /**/);
+ LBUFERR(macro_, _("Text metrics error."));
// calculate metrics, hoping that all cells are seen
macro_->lock();
void MathMacro::removeArgument(Inset::pos_type pos) {
if (displayMode_ == DISPLAY_NORMAL) {
- LASSERT(size_t(pos) < cells_.size(), /**/);
+ LASSERT(size_t(pos) < cells_.size(), return);
cells_.erase(cells_.begin() + pos);
if (size_t(pos) < attachedArgsNum_)
--attachedArgsNum_;
void MathMacro::insertArgument(Inset::pos_type pos) {
if (displayMode_ == DISPLAY_NORMAL) {
- LASSERT(size_t(pos) <= cells_.size(), /**/);
+ LASSERT(size_t(pos) <= cells_.size(), return);
cells_.insert(cells_.begin() + pos, MathData());
if (size_t(pos) < attachedArgsNum_)
++attachedArgsNum_;
void MathMacro::detachArguments(vector<MathData> & args, bool strip)
{
- LASSERT(displayMode_ == DISPLAY_NORMAL, /**/);
+ LASSERT(displayMode_ == DISPLAY_NORMAL, return);
args = cells_;
// strip off empty cells, but not more than arity-attachedArgsNum_
void MathMacro::attachArguments(vector<MathData> const & args, size_t arity, int optionals)
{
- LASSERT(displayMode_ == DISPLAY_NORMAL, /**/);
+ LASSERT(displayMode_ == DISPLAY_NORMAL, return);
cells_ = args;
attachedArgsNum_ = args.size();
cells_.resize(arity);
// The macro name was changed
Cursor inset_cursor = old;
int macroSlice = inset_cursor.find(this);
- LASSERT(macroSlice != -1, /**/);
+ // returning true means the cursor is "now" invalid,
+ // which it was.
+ LASSERT(macroSlice != -1, return true);
inset_cursor.cutOff(macroSlice);
inset_cursor.recordUndoInset();
inset_cursor.pop();
}
// normal mode
- LASSERT(macro_, /**/);
+ // we should be ok to continue even if this fails.
+ LATTEST(macro_);
// optional arguments make macros fragile
if (optionals_ > 0 && os.fragile())
for (; sit != end; ++sit) {
InsetMathHull * inset_hull =
sit->nextInset()->asInsetMath()->asHullInset();
- LASSERT(inset_hull, /**/);
+ LBUFERR(inset_hull, _("Error loading macro previews."));
inset_hull->reloadPreview(*sit);
}
cur.screenUpdateFlags(Update::Force);
odocstream & os,
OutputParams const & runparams)
{
+ LASSERT(runparams.par_begin <= runparams.par_end,
+ { os << "<!-- Docbook Output Error -->\n"; return; });
+
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator pend = paragraphs.end();
- LASSERT(runparams.par_begin <= runparams.par_end, /**/);
// if only part of the paragraphs will be outputed
if (runparams.par_begin != runparams.par_end) {
par = boost::next(paragraphs.begin(), runparams.par_begin);
OutputParams const & runparams,
string const & everypar)
{
+ LASSERT(runparams.par_begin <= runparams.par_end,
+ { os << "% LaTeX Output Error\n"; return; } );
+
BufferParams const & bparams = buf.params();
bool const maintext = text.isMainText();
}
ParagraphList const & paragraphs = text.paragraphs();
- LASSERT(runparams.par_begin <= runparams.par_end, /**/);
if (runparams.par_begin == runparams.par_end) {
// The full doc will be exported but it is easier to just rely on
// One is that we are still in the environment in which we
// started---which we will be if the depth is the same.
if (par->params().depth() == origdepth) {
- LASSERT(bstyle == style, /* */);
+ LATTEST(bstyle == style);
if (lastlay != 0) {
closeItemTag(xs, *lastlay);
lastlay = 0;
}
pit_type bpit = runparams.par_begin;
pit_type const epit = runparams.par_end;
- LASSERT(bpit < epit, /* */);
+ LASSERT(bpit < epit,
+ { xs << XHTMLStream::ESCAPE_NONE << "<!-- XHTML output error! -->\n"; return; });
OutputParams ourparams = runparams;
ParagraphList::const_iterator const pend =
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
//row_.dump();
- LASSERT(pit >= 0, /**/);
- LASSERT(pit < int(text.paragraphs().size()), /**/);
+ LBUFERR(pit >= 0, _("Unable to initialize row painter!"));
+ LBUFERR(pit < int(text.paragraphs().size()),
+ _("Unable to initialize row painter!"));
}
: d(abs_filename.empty() ? new Private : new Private(abs_filename))
{
//LYXERR(Debug::FILES, "FileName(" << abs_filename << ')');
- LASSERT(empty() || isAbsolute(d->name), /**/);
+ LATTEST(empty() || isAbsolute(d->name));
}
d->fi.setFile(toqstr(name));
d->name = fromqstr(d->fi.absoluteFilePath());
//LYXERR(Debug::FILES, "FileName::set(" << name << ')');
- LASSERT(empty() || isAbsolute(d->name), /**/);
+ LATTEST(empty() || isAbsolute(d->name));
}
d->fi.setFile(QDir(rhs.d->fi.absoluteFilePath()), toqstr(suffix));
d->name = fromqstr(d->fi.absoluteFilePath());
//LYXERR(Debug::FILES, "FileName::set(" << d->name << ')');
- LASSERT(empty() || isAbsolute(d->name), /**/);
+ LATTEST(empty() || isAbsolute(d->name));
}
// FIXME: gettext sometimes "forgets" the ucs4_codeset we set
// in init(), which leads to severe message corruption (#7371)
// We set it again here unconditionally. A real fix must be found!
- LASSERT(bind_textdomain_codeset(PACKAGE, ucs4_codeset), /**/);
+ LATTEST(bind_textdomain_codeset(PACKAGE, ucs4_codeset));
char const * m_c = m.c_str();
char const * trans_c = gettext(m_c);
pair<TranslationCache::iterator, bool> result =
cache_.insert(make_pair(m, trans));
- LASSERT(result.second, /**/);
+ LASSERT(result.second, return from_utf8(m));
return result.first->second;
}
Package const & package()
{
- LASSERT(initialised_, /**/);
+ LAPPERR(initialised_, _("Package not initialized."));
return package_;
}
Timeout & Timeout::setTimeout(unsigned int msec)
{
// Can't have a timeout of zero!
- LASSERT(msec, /**/);
+ LASSERT(msec, msec = 1000);
timeout_ms = msec;
return *this;
/// Find the mapping for the first argument
T2 const & find(T1 const & first) const
{
- LASSERT(!map.empty(), /**/);
+ LASSERT(!map.empty(), return default_t2);
const_iterator it = map.begin();
const_iterator end = map.end();
for (; it != end; ++it)
/// Find the mapping for the second argument
T1 const & find(T2 const & second) const
{
- LASSERT(!map.empty(), /**/);
+ LASSERT(!map.empty(), return default_t1);
const_iterator it = map.begin();
const_iterator end = map.end();
for (; it != end; ++it)
char_type *d = &s[0];
while (--n >= 0) {
d[n] = ascii[n];
- LASSERT(static_cast<unsigned char>(ascii[n]) < 0x80, /**/);
+ LATTEST(static_cast<unsigned char>(ascii[n]) < 0x80);
}
}
return s;
{
int const len = ascii.length();
for (int i = 0; i < len; ++i)
- LASSERT(static_cast<unsigned char>(ascii[i]) < 0x80, /**/);
+ LATTEST(static_cast<unsigned char>(ascii[i]) < 0x80);
return docstring(ascii.begin(), ascii.end());
}
string ascii;
ascii.resize(len);
for (int i = 0; i < len; ++i) {
- LASSERT(ucs4[i] < 0x80, /**/);
+ LATTEST(ucs4[i] < 0x80);
ascii[i] = static_cast<char>(ucs4[i]);
}
return ascii;
lyx::docstring::const_iterator it = l.begin();
lyx::docstring::const_iterator end = l.end();
for (; it != end; ++it, ++r) {
- LASSERT(static_cast<unsigned char>(*r) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(*r) < 0x80, return false);
if (!*r)
return false;
if (*it != static_cast<lyx::docstring::value_type>(*r))
{
lyx::docstring s(l);
for (char const * c = r; *c; ++c) {
- LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(*c) < 0x80, return l);
s.push_back(*c);
}
return s;
{
lyx::docstring s;
for (char const * c = l; *c; ++c) {
- LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(*c) < 0x80, return r);
s.push_back(*c);
}
s += r;
lyx::docstring operator+(lyx::docstring const & l, char r)
{
- LASSERT(static_cast<unsigned char>(r) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(r) < 0x80, return l);
docstring s = l;
s += docstring::value_type(r);
return s;
lyx::docstring operator+(char l, lyx::docstring const & r)
{
- LASSERT(static_cast<unsigned char>(l) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(l) < 0x80, return r);
return lyx::docstring::value_type(l) + r;
}
lyx::docstring & operator+=(lyx::docstring & l, char const * r)
{
for (char const * c = r; *c; ++c) {
- LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(*c) < 0x80, return l);
l.push_back(*c);
}
return l;
lyx::docstring & operator+=(lyx::docstring & l, char r)
{
- LASSERT(static_cast<unsigned char>(r) < 0x80, /**/);
+ LASSERT(static_cast<unsigned char>(r) < 0x80, return l);
l.push_back(r);
return l;
}
*/
inline char_type qchar_to_ucs4(QChar const & qchar)
{
- LASSERT(is_utf16(static_cast<char_type>(qchar.unicode())), /**/);
+ LASSERT(is_utf16(static_cast<char_type>(qchar.unicode())), return '?');
return static_cast<char_type>(qchar.unicode());
}
*/
inline QChar const ucs4_to_qchar(char_type const ucs4)
{
- LASSERT(is_utf16(ucs4), /**/);
+ LASSERT(is_utf16(ucs4), return QChar('?'));
return QChar(static_cast<unsigned short>(ucs4));
}
char lowercase(char c)
{
- LASSERT(isASCII(c), /**/);
+ LASSERT(isASCII(c), return '?');
return char(tolower(c));
}
char uppercase(char c)
{
- LASSERT(isASCII(c), /**/);
+ LASSERT(isASCII(c), return '?');
return char(toupper(c));
}
String const subst_string(String const & a,
String const & oldstr, String const & newstr)
{
- LASSERT(!oldstr.empty(), /**/);
+ LASSERT(!oldstr.empty(), return a);
String lstr = a;
size_t i = 0;
size_t const olen = oldstr.length();
docstring const subst_string(docstring const & a,
docstring const & oldstr, docstring const & newstr)
{
- LASSERT(!oldstr.empty(), /**/);
+ LASSERT(!oldstr.empty(), return a);
docstring lstr = a;
size_t i = 0;
size_t const olen = oldstr.length();
docstring const trim(docstring const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
string const trim(string const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
string const rtrim(string const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
docstring const rtrim(docstring const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
string const ltrim(string const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
size_t l = a.find_first_not_of(p);
docstring const ltrim(docstring const & a, char const * p)
{
- LASSERT(p, /**/);
+ LASSERT(p, return a);
if (a.empty() || !*p)
return a;
size_t l = a.find_first_not_of(from_ascii(p));
// encode bigger values. Test for 2^24 because we
// can encode that with the 6 hex digits that are
// needed for 21 bits anyway.
- LASSERT(c < (1 << 24), /**/);
+ LASSERT(c < (1 << 24), continue);
enc += '=';
enc += hexdigit[(c>>20) & 15];
enc += hexdigit[(c>>16) & 15];
template<>
docstring bformat(docstring const & fmt, int arg1)
{
- LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, long arg1)
{
- LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, unsigned int arg1)
{
- LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$d")));
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, docstring arg1)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
docstring const str = subst(fmt, from_ascii("%1$s"), arg1);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, char * arg1)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
docstring const str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
return subst(str, from_ascii("%%"), from_ascii("%"));
}
template<>
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
+ LATTEST(contains(fmt, from_ascii("%2$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
return subst(str, from_ascii("%%"), from_ascii("%"));
template<>
docstring bformat(docstring const & fmt, docstring arg1, int arg2)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$d")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
+ LATTEST(contains(fmt, from_ascii("%2$d")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
return subst(str, from_ascii("%%"), from_ascii("%"));
template<>
docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
+ LATTEST(contains(fmt, from_ascii("%2$s")));
docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
str = subst(fmt, from_ascii("%2$s"), arg2);
return subst(str, from_ascii("%%"), from_ascii("%"));
template<>
docstring bformat(docstring const & fmt, int arg1, int arg2)
{
- LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$d")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$d")));
+ LATTEST(contains(fmt, from_ascii("%2$d")));
docstring str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
return subst(str, from_ascii("%%"), from_ascii("%"));
template<>
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%3$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
+ LATTEST(contains(fmt, from_ascii("%2$s")));
+ LATTEST(contains(fmt, from_ascii("%3$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
str = subst(str, from_ascii("%3$s"), arg3);
docstring bformat(docstring const & fmt,
docstring arg1, docstring arg2, docstring arg3, docstring arg4)
{
- LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%3$s")), /**/);
- LASSERT(contains(fmt, from_ascii("%4$s")), /**/);
+ LATTEST(contains(fmt, from_ascii("%1$s")));
+ LATTEST(contains(fmt, from_ascii("%2$s")));
+ LATTEST(contains(fmt, from_ascii("%3$s")));
+ LATTEST(contains(fmt, from_ascii("%4$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
str = subst(str, from_ascii("%3$s"), arg3);
string utf8_argv(int i)
{
- LASSERT(i < argc_, /**/);
+ LASSERT(i < argc_, return "");
return to_utf8(from_local8bit(argv_[i]));
}
string utf8_argv(int i)
{
- LASSERT(i < argc_, /**/);
+ LASSERT(i < argc_, return "");
return to_utf8(from_local8bit(argv_[i]));
}
wchar_t ** envp = 0;
int newmode = 0;
__wgetmainargs(&argc_, &argv_, &envp, -1, &newmode);
- LASSERT(argc == argc_, /**/);
+ LATTEST(argc == argc_);
// If Cygwin is detected, query the cygdrive prefix.
// The cygdrive prefix is needed for translating windows style paths
string utf8_argv(int i)
{
- LASSERT(i < argc_, /**/);
+ LASSERT(i < argc_, return "");
return fromqstr(QString::fromWCharArray(argv_[i]));
}
long_path.resize(result);
result = GetLongPathNameW((wchar_t *) short_path.utf16(),
&long_path[0], long_path.size());
- LASSERT(result <= long_path.size(), /**/);
+ LATTEST(result <= long_path.size());
}
return (result == 0) ? short_path : QString::fromWCharArray(&long_path[0]);
short_path.resize(result);
result = GetShortPathNameW((wchar_t *) long_path.utf16(),
&short_path[0], short_path.size());
- LASSERT(result <= short_path.size(), /**/);
+ LATTEST(result <= short_path.size());
}
return (result == 0) ? long_path : QString::fromWCharArray(&short_path[0]);
id = CSIDL_APPDATA;
break;
default:
- LASSERT(false, /**/);
+ LASSERT(false, return string());
}
HRESULT const result = (folder_path_func_)(0, id, 0,
SHGFP_TYPE_CURRENT,
return from_local8bit(name);
#else
struct passwd * pw = getpwuid(geteuid());
- LASSERT(pw, /**/);
+ LASSERT(pw, return docstring());
const string gecos = pw->pw_gecos;
const size_t pos = gecos.find(",");