From: Martin Vermeer Date: Wed, 4 Feb 2004 12:24:01 +0000 (+0000) Subject: Workaround for gcc 2.95 pointer compare bug X-Git-Tag: 1.6.10~15530 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=302a00b035d825ac038970d7bf768ada9d278be9;p=features.git Workaround for gcc 2.95 pointer compare bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8402 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index c00d227cfc..c56c9595e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,8 @@ +2004-02-04 Martin Vermeer + + * cursor.[Ch]: workaround gcc 2.95 pointer comparison bug + 2004-02-04 André Pönitz * BufferView.[Ch] (insertInset): diff --git a/src/cursor.C b/src/cursor.C index 244329093a..02c83938ac 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -860,7 +860,7 @@ bool LCursor::openable(MathAtom const & t) // we can't move into anything new during selection if (depth() == anchor_.size()) return false; - if (t.nucleus() != anchor_[depth()].inset()) + if (!ptr_cmp(t.nucleus(), anchor_[depth()].inset())) return false; return true; diff --git a/src/cursor.h b/src/cursor.h index 0951333da9..baff406852 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -33,6 +33,17 @@ class PainterInfo; class MathUnknownInset; class MathGridInset; + +// only needed for gcc 2.95, remove when support terminated + + +template +bool ptr_cmp(A const * a, B const * b) +{ +return a == b; +} + + // this is used for traversing math insets typedef std::vector CursorBase; /// move on one step diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 9192fa70fd..f8619979ab 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2004-02-04 Martin Vermeer + + * math_nestinset.C: workaround gcc 2.95 pointer comparison bug, + reverse below + 2004-02-03 Martin Vermeer * math_nestinset.C: use const_cast to get to compile for stlport diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index ac815f1d68..f5096870ad 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -72,7 +72,7 @@ MathArray const & MathNestInset::cell(idx_type i) const void MathNestInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); MathArray const & ar = cur.cell(); x = ar.xo() + ar.pos2x(cur.pos()); y = ar.yo(); @@ -99,7 +99,7 @@ void MathNestInset::metrics(MetricsInfo const & mi) const bool MathNestInset::idxNext(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (cur.idx() == cur.lastidx()) return false; ++cur.idx(); @@ -116,7 +116,7 @@ bool MathNestInset::idxRight(LCursor & cur) const bool MathNestInset::idxPrev(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (cur.idx() == 0) return false; --cur.idx(); @@ -133,7 +133,7 @@ bool MathNestInset::idxLeft(LCursor & cur) const bool MathNestInset::idxFirst(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (nargs() == 0) return false; cur.idx() = 0; @@ -144,7 +144,7 @@ bool MathNestInset::idxFirst(LCursor & cur) const bool MathNestInset::idxLast(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (nargs() == 0) return false; cur.idx() = cur.lastidx(); @@ -155,7 +155,7 @@ bool MathNestInset::idxLast(LCursor & cur) const bool MathNestInset::idxHome(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (cur.pos() == 0) return false; cur.pos() = 0; @@ -165,7 +165,7 @@ bool MathNestInset::idxHome(LCursor & cur) const bool MathNestInset::idxEnd(LCursor & cur) const { - BOOST_ASSERT(cur.inset() == const_cast(this)); + BOOST_ASSERT(ptr_cmp(cur.inset(), this)); if (cur.lastpos() == cur.lastpos()) return false; cur.pos() = cur.lastpos(); @@ -202,7 +202,7 @@ void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const LCursor & cur = pi.base.bv->cursor(); if (!cur.selection()) return; - if (cur.inset() != const_cast(this)) + if (!ptr_cmp(cur.inset(), this)) return; CursorSlice & s1 = cur.selBegin(); CursorSlice & s2 = cur.selEnd();