From f997928d57242b829bacfd0a5974e857d6c9c86c Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sat, 13 Oct 2007 15:48:22 +0000 Subject: [PATCH] Off-by-one error addCol() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20947 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathGrid.cpp | 4 ++-- src/mathed/InsetMathHull.cpp | 4 ++-- src/mathed/MathParser.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 26319250ec..5d36b3d5d2 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -743,9 +743,9 @@ void InsetMathGrid::addCol(col_type newcol) for (row_type row = 0; row < nr; ++row) for (col_type col = 0; col < nc; ++col) { - new_cells[row * (nc + 1) + col + (col > newcol)] + new_cells[row * (nc + 1) + col + (col >= newcol)] = cells_[row * nc + col]; - new_cellinfo[row * (nc + 1) + col + (col > newcol)] + new_cellinfo[row * (nc + 1) + col + (col >= newcol)] = cellinfo_[row * nc + col]; } swap(cells_, new_cells); diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 2f86f0cf81..fb48a99e42 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -709,7 +709,7 @@ void InsetMathHull::splitTo3Cols() BOOST_ASSERT(ncols() < 3); if (ncols() < 2) splitTo2Cols(); - InsetMathGrid::addCol(1); + InsetMathGrid::addCol(2); for (row_type row = 0; row < nrows(); ++row) { idx_type const i = 3 * row + 1; if (cell(i).size()) { @@ -731,7 +731,7 @@ void InsetMathHull::changeCols(col_type cols) else { splitTo3Cols(); while (ncols() < cols) - InsetMathGrid::addCol(ncols() - 1); + InsetMathGrid::addCol(ncols()); } return; } diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 0c8ee7765a..fc707e5a9f 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -150,7 +150,7 @@ bool addCol(InsetMathGrid & grid, InsetMathGrid::col_type & cellcol) ++cellcol; if (cellcol == grid.ncols()) { //lyxerr << "adding column " << cellcol << endl; - grid.addCol(cellcol - 1); + grid.addCol(cellcol); if (cellcol == grid.ncols()) { // We can't add a column to this grid, so let's // append the content of this cell to the previous