]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathGrid.cpp
Only set buffer if it is not null.
[lyx.git] / src / mathed / InsetMathGrid.cpp
index ef6b2652135673c10a0ea4c7a6729e27997b3b46..783e374f624492c6c8e5e9bd51b49117c2abea97 100644 (file)
@@ -281,9 +281,9 @@ void InsetMathGrid::setHorizontalAlignments(docstring const & hh)
 InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh)
 {
        col_type col = 0;
-       for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
-               if (*it == 'c' || *it == 'l' || *it == 'r'||
-                   *it == 'p' || *it == 'm' || *it == 'b')
+       for (char_type const c : hh)
+               if (c == 'c' || c == 'l' || c == 'r'||
+                   c == 'p' || c == 'm' || c == 'b')
                        ++col;
        // let's have at least one column, even if we did not recognize its
        // alignment
@@ -1215,7 +1215,7 @@ void InsetMathGrid::mathmlize(MathStream & ms) const
 
 // FIXME XHTML
 // We need to do something about alignment here.
-void InsetMathGrid::htmlize(HtmlStream & os, string attrib) const
+void InsetMathGrid::htmlize(HtmlStream & os, string const & attrib) const
 {
        bool const havetable = nrows() > 1 || ncols() > 1;
        if (!havetable) {
@@ -1634,9 +1634,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                        for (row_type r = 0; r < numrows; ++r) {
                                for (col_type c = 0; c < numcols; ++c) {
                                        idx_type i = index(r + startrow, c + startcol);
-                                       pos_type ipos = cur.pos() > pos_type(cell(i).size())
-                                                       ? pos_type(cell(i).size())
-                                                       : cur.pos();
+                                       pos_type const ipos = min(cur.pos(), pos_type(cell(i).size()));
                                        cell(i).insert(ipos, grid.cell(grid.index(r, c)));
                                }
                                if (hline_enabled)