On Monday 04 November 2002 10:28 am, Andre Poenitz wrote:
> On Fri, Nov 01, 2002 at 05:03:28PM +0000, Angus Leeming wrote:
> > I won't do that because I'm not at all sure that this code is safe if it
> > receives
> > size = (size_type)-1;
> > Should you not add a test that size is valid? What should you do if it
> > isn't?
>
> Are we still talking about
>
> erase(i);
> insert(i, ar);
> mathcursor->adjust(i, ar.size() - 1);
No, the warning is generated in MathArray::notifyCursorLeaves() immediately
below your snippet:
// glue adjacent font insets of the same kind
for (pos_type i = 0; i + 1 < size(); ++i) {
MathFontInset * p = operator[](i).nucleus()->asFontInset();
MathFontInset const * q = operator[](i + 1)->asFontInset();
if (p && q && p->name() == q->name()) {
p->cell(0).append(q->cell(0));
erase(i + 1);
- mathcursor->adjust(i, -1);
+ mathcursor->adjust(i, npos);
}
}
npos would make that more understandable.
My problem, however, lies with:
void MathCursor::adjust(pos_type from, size_type size)
{
if (cursor().pos_ > from)
cursor().pos_ += size;
if (Anchor_.back().pos_ > from)
Anchor_.back().pos_ += size;
// just to be on the safe side
// theoretically unecessary
normalize();
}
I suspect this method needs
if (size == size_type)-1)
return;
(or npos of course). As it stands it doesn't look as if it can cope with an
invalid size.
Angus