]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_extern.C
Make Helge happy: no more crash on arrow up/down in math macro
[lyx.git] / src / mathed / math_extern.C
index ab7e39c904e03d219b88a6e8d6c12663fc536bed..17d5b095cbfecdb7462774e9d45ded23cc414f2e 100644 (file)
 #include "math_stringinset.h"
 #include "math_symbolinset.h"
 #include "math_parser.h"
-#include "support/std_sstream.h"
 #include "debug.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
 #include <algorithm>
+#include <sstream>
 
 using lyx::support::cmd_ret;
 using lyx::support::getVectorFromString;
@@ -51,6 +51,8 @@ using std::auto_ptr;
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
+using std::swap;
+using std::vector;
 
 
 ostream & operator<<(ostream & os, MathArray const & ar)
@@ -146,7 +148,7 @@ string charSequence
 void extractStrings(MathArray & ar)
 {
        //lyxerr << "\nStrings from: " << ar << endl;
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                if (!ar[i]->asCharInset())
                        continue;
                string s = charSequence(ar.begin() + i, ar.end());
@@ -161,7 +163,7 @@ void extractMatrices(MathArray & ar)
 {
        //lyxerr << "\nMatrices from: " << ar << endl;
        // first pass for explicitly delimited stuff
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                if (!ar[i]->asDelimInset())
                        continue;
                MathArray const & arr = ar[i]->asDelimInset()->cell(0);
@@ -173,7 +175,7 @@ void extractMatrices(MathArray & ar)
        }
 
        // second pass for AMS "pmatrix" etc
-       for (MathArray::size_type i = 0; i < ar.size(); ++i)
+       for (size_t i = 0; i < ar.size(); ++i)
                if (ar[i]->asAMSArrayInset())
                        ar[i] = MathAtom(new MathMatrixInset(*(ar[i]->asGridInset())));
        //lyxerr << "\nMatrices to: " << ar << endl;
@@ -198,7 +200,7 @@ bool extractString(MathAtom const & at, string & str)
 // convert this inset somehow to a number
 bool extractNumber(MathArray const & ar, int & i)
 {
-       istringstream is(charSequence(ar.begin(), ar.end()).c_str());
+       istringstream is(charSequence(ar.begin(), ar.end()));
        is >> i;
        return is;
 }
@@ -206,7 +208,7 @@ bool extractNumber(MathArray const & ar, int & i)
 
 bool extractNumber(MathArray const & ar, double & d)
 {
-       istringstream is(charSequence(ar.begin(), ar.end()).c_str());
+       istringstream is(charSequence(ar.begin(), ar.end()));
        is >> d;
        return is;
 }
@@ -249,7 +251,7 @@ void replaceNested(
 {
        // use indices rather than iterators for the loop  because we are going
        // to modify the array.
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                // check whether this is the begin of the sequence
                if (!testOpen(ar[i]))
                        continue;
@@ -276,7 +278,7 @@ void replaceNested(
 void splitScripts(MathArray & ar)
 {
        //lyxerr << "\nScripts from: " << ar << endl;
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                // is this script inset?
                if (!ar[i]->asScriptInset())
                        continue;
@@ -290,7 +292,7 @@ void splitScripts(MathArray & ar)
                // create extra script inset and move superscript over
                MathScriptInset * p = ar[i].nucleus()->asScriptInset();
                auto_ptr<MathScriptInset> q(new MathScriptInset(true));
-               std::swap(q->up(), p->up());
+               swap(q->up(), p->up());
                p->removeScript(true);
 
                // insert new inset behind
@@ -308,7 +310,7 @@ void splitScripts(MathArray & ar)
 void extractExps(MathArray & ar)
 {
        //lyxerr << "\nExps from: " << ar << endl;
-       for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
+       for (size_t i = 0; i + 1 < ar.size(); ++i) {
                // is this 'e'?
                if (ar[i]->getChar() != 'e')
                        continue;
@@ -371,7 +373,7 @@ string digitSequence
 void extractNumbers(MathArray & ar)
 {
        //lyxerr << "\nNumbers from: " << ar << endl;
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                if (!ar[i]->asCharInset())
                        continue;
                if (!isDigitOrSimilar(ar[i]->asCharInset()->getChar()))
@@ -433,7 +435,7 @@ void extractFunctions(MathArray & ar)
                return;
 
        //lyxerr << "\nFunctions from: " << ar << endl;
-       for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
+       for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
                MathArray::iterator jt = it + 1;
 
@@ -524,7 +526,7 @@ void extractIntegrals(MathArray & ar)
                return;
 
        //lyxerr << "\nIntegrals from: " << ar << endl;
-       for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
+       for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
                // search 'd'
@@ -596,7 +598,7 @@ void extractSums(MathArray & ar)
                return;
 
        //lyxerr << "\nSums from: " << ar << endl;
-       for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
+       for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
                // is this a sum name?
@@ -668,7 +670,7 @@ bool testDiffFrac(MathAtom const & at)
 void extractDiff(MathArray & ar)
 {
        //lyxerr << "\nDiffs from: " << ar << endl;
-       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+       for (size_t i = 0; i < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
                // is this a "differential fraction"?
@@ -758,7 +760,7 @@ void extractLims(MathArray & ar)
                return;
 
        //lyxerr << "\nLimits from: " << ar << endl;
-       for (MathArray::size_type i = 0; i + 2 < ar.size(); ++i) {
+       for (size_t i = 0; i + 2 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
                // is this a limit function?
@@ -961,7 +963,7 @@ namespace {
                                break;
 
                        // search line with "Incorrect syntax"
-                       istringstream is(out.c_str());
+                       istringstream is(out);
                        string line;
                        while (is) {
                                getline(is, line);
@@ -982,7 +984,7 @@ namespace {
                        expr.insert(pos,  "*");
                }
 
-               std::vector<string> tmp = getVectorFromString(out, "$$");
+               vector<string> tmp = getVectorFromString(out, "$$");
                if (tmp.size() < 2)
                        return MathArray();
 
@@ -1078,7 +1080,7 @@ namespace {
                        string out = captureOutput("mint -i 1 -S -s -q -q", expr + ';');
                        if (out.empty())
                                break; // expression syntax is ok
-                       istringstream is(out.c_str());
+                       istringstream is(out);
                        string line;
                        getline(is, line);
                        if (line.find("on line") != 0)
@@ -1132,7 +1134,7 @@ namespace {
                                break;
 
                        // search line with single caret
-                       istringstream is(out.c_str());
+                       istringstream is(out);
                        string line;
                        while (is) {
                                getline(is, line);