From e597fc7ae4bcf294ba48f2bb2f649d72ece9a0be Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 1 Oct 2001 12:10:32 +0000 Subject: [PATCH] fix the size of some variables to avoid compaq cxx warnings git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2826 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 12 ++++++++++ src/mathed/formula.C | 4 ++-- src/mathed/math_cursor.C | 49 +++++++++++++++++++------------------- src/mathed/math_cursor.h | 4 ++-- src/mathed/math_fracbase.C | 12 ++++++---- src/mathed/math_fracbase.h | 8 +++---- 6 files changed, 53 insertions(+), 36 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 76da000337..213091f596 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,15 @@ +2001-10-01 Jean-Marc Lasgouttes + + * math_cursor.C: + * formula.C (localDispatch): fix a few of local variable sizes + + * math_fracbase.C: change parameter types to match MathInset + +2001-09-27 Jean-Marc Lasgouttes + + * math_cursor.C: fix type mismatches with what was declared in + math_cursor.h. + 2001-09-28 Dekel Tsur * math_matrixinset.C (header_write): Add \n after \begin{align} diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 7bcefdd8ea..1a66a3663c 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -201,7 +201,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, //lyxerr << "toggling line number\n"; if (display()) { bv->lockedInsetStoreUndo(Undo::INSERT); - int row = mathcursor->row(); + MathCursor::row_type row = mathcursor->row(); bool old = par_->numbered(row); bv->owner()->message(old ? _("No number") : _("Number")); par_->numbered(row, !old); @@ -214,7 +214,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, { bv->lockedInsetStoreUndo(Undo::INSERT); - int row = mathcursor->row(); + MathCursor::row_type row = mathcursor->row(); string old_label = par_->label(row); string new_label = arg; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 4558c55a38..a9ae33e68b 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -76,7 +76,7 @@ struct Selection if (i1.idx_ == i2.idx_) i1.cell().erase(i1.pos_, i2.pos_); else { - std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); + std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); for (unsigned i = 0; i < indices.size(); ++i) i1.cell(indices[i]).erase(); } @@ -371,7 +371,7 @@ void MathCursor::setPos(int x, int y) MathXArray const & ar = par()->xcell(i); int x1 = x - ar.xo(); int y1 = y - ar.yo(); - int c = ar.x2pos(x1); + MathXArray::size_type c = ar.x2pos(x1); int xx = abs(x1 - ar.pos2x(c)); int yy = abs(y1); //lyxerr << "idx: " << i << " xx: " << xx << " yy: " << yy @@ -753,7 +753,7 @@ void MathCursor::drawSelection(Painter & pain) const int y2 = c.yo() + c.descent(); pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); } else { - std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); + std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); for (unsigned i = 0; i < indices.size(); ++i) { MathXArray & c = i1.xcell(indices[i]); int x1 = c.xo(); @@ -782,7 +782,8 @@ void MathCursor::handleFont(MathTextCodes t) getSelection(i1, i2); if (i1.idx_ == i2.idx_) { MathArray & ar = i1.cell(); - for (unsigned int pos = i1.pos_; pos != i2.pos_; ++pos) { + for (MathInset::pos_type pos = i1.pos_; + pos != i2.pos_; ++pos) { MathInset * p = ar.at(pos)->nucleus(); if (p) p->handleFont(t); @@ -833,25 +834,25 @@ InsetFormulaBase const * MathCursor::formula() } -unsigned int MathCursor::idx() const +MathCursor::idx_type MathCursor::idx() const { return cursor().idx_; } -unsigned int & MathCursor::idx() +MathCursor::idx_type & MathCursor::idx() { return cursor().idx_; } -unsigned int MathCursor::pos() const +MathCursor::pos_type MathCursor::pos() const { return cursor().pos_; } -unsigned int & MathCursor::pos() +MathCursor::pos_type & MathCursor::pos() { return cursor().pos_; } @@ -869,7 +870,7 @@ bool MathCursor::selection() const } -MathArrayInset * MathCursor::enclosingArray(unsigned int & idx) const +MathArrayInset * MathCursor::enclosingArray(MathCursor::idx_type & idx) const { for (int i = Cursor_.size() - 1; i >= 0; --i) { if (Cursor_[i].par_->isArray()) { @@ -924,19 +925,19 @@ void MathCursor::normalize() const } -unsigned int MathCursor::size() const +MathCursor::size_type MathCursor::size() const { return array().size(); } -unsigned int MathCursor::col() const +MathCursor::col_type MathCursor::col() const { return par()->col(idx()); } -unsigned int MathCursor::row() const +MathCursor::row_type MathCursor::row() const { return par()->row(idx()); } @@ -1067,10 +1068,10 @@ void MathCursor::breakLine() p->addRow(row()); // split line - const unsigned int r = row(); - for (unsigned int c = col() + 1; c < p->ncols(); ++c) { - const unsigned int i1 = p->index(r, c); - const unsigned int i2 = p->index(r + 1, c); + const row_type r = row(); + for (col_type c = col() + 1; c < p->ncols(); ++c) { + const MathMatrixInset::idx_type i1 = p->index(r, c); + const MathMatrixInset::idx_type i2 = p->index(r + 1, c); lyxerr << "swapping cells " << i1 << " and " << i2 << "\n"; p->cell(i1).swap(p->cell(i2)); } @@ -1084,17 +1085,17 @@ void MathCursor::breakLine() char MathCursor::valign() const { - unsigned int idx; + idx_type idx; MathArrayInset * p = enclosingArray(idx); - return p ? p->valign() : 0; + return p ? p->valign() : '\0'; } char MathCursor::halign() const { - unsigned int idx; + idx_type idx; MathArrayInset * p = enclosingArray(idx); - return p ? p->halign(idx % p->ncols()) : 0; + return p ? p->halign(idx % p->ncols()) : '\0'; } @@ -1123,13 +1124,13 @@ MathCursorPos const & MathCursor::cursor() const } -unsigned int MathCursor::cellXOffset() const +int MathCursor::cellXOffset() const { return par()->cellXOffset(idx()); } -unsigned int MathCursor::cellYOffset() const +int MathCursor::cellYOffset() const { return par()->cellYOffset(idx()); } @@ -1425,7 +1426,7 @@ bool operator<(MathCursorPos const & ti, MathCursorPos const & it) } -MathArray & MathCursorPos::cell(unsigned int idx) const +MathArray & MathCursorPos::cell(MathCursor::idx_type idx) const { return par_->cell(idx); } @@ -1437,7 +1438,7 @@ MathArray & MathCursorPos::cell() const } -MathXArray & MathCursorPos::xcell(unsigned int idx) const +MathXArray & MathCursorPos::xcell(MathCursor::idx_type idx) const { return par_->xcell(idx); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 25501ba05e..7137547ad5 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -277,9 +277,9 @@ private: /// write access to cursor cell index idx_type & idx(); /// x-offset of current cell relative to par xo - idx_type cellXOffset() const; + int cellXOffset() const; /// y-offset of current cell relative to par yo - idx_type cellYOffset() const; + int cellYOffset() const; /// current x position relative to par xo int xpos() const; /// current y position relative to par yo diff --git a/src/mathed/math_fracbase.C b/src/mathed/math_fracbase.C index e52a841fcc..aa17ea7e82 100644 --- a/src/mathed/math_fracbase.C +++ b/src/mathed/math_fracbase.C @@ -10,19 +10,22 @@ MathFracbaseInset::MathFracbaseInset() {} -bool MathFracbaseInset::idxRight(int &, int &) const +bool MathFracbaseInset::idxRight(MathInset::idx_type &, + MathInset::pos_type &) const { return false; } -bool MathFracbaseInset::idxLeft(int &, int &) const +bool MathFracbaseInset::idxLeft(MathInset::idx_type &, + MathInset::pos_type &) const { return false; } -bool MathFracbaseInset::idxUp(int & idx, int &) const +bool MathFracbaseInset::idxUp(MathInset::idx_type & idx, + MathInset::pos_type &) const { if (idx == 0) return false; @@ -31,7 +34,8 @@ bool MathFracbaseInset::idxUp(int & idx, int &) const } -bool MathFracbaseInset::idxDown(int & idx, int &) const +bool MathFracbaseInset::idxDown(MathInset::idx_type & idx, + MathInset::pos_type &) const { if (idx == 1) return false; diff --git a/src/mathed/math_fracbase.h b/src/mathed/math_fracbase.h index 1236c8a698..08f05017d5 100644 --- a/src/mathed/math_fracbase.h +++ b/src/mathed/math_fracbase.h @@ -13,13 +13,13 @@ public: /// MathFracbaseInset(); /// - bool idxUp(int &, int &) const; + bool idxUp(MathInset::idx_type &, MathInset::pos_type &) const; /// - bool idxDown(int &, int &) const; + bool idxDown(MathInset::idx_type &, MathInset::pos_type &) const; /// - bool idxLeft(int &, int &) const; + bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const; /// - bool idxRight(int &, int &) const; + bool idxRight(MathInset::idx_type &, MathInset::pos_type &) const; }; #endif -- 2.39.2