]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathExtern.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / MathExtern.cpp
index 2d7fd9d39d890ab4055dc114b0465c8dc4a00e57..c42da422e4845582529c6a40e2b2db86ecd27459 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -16,7 +16,6 @@
 
 #include "MathExtern.h"
 
-#include "debug.h"
 #include "InsetMathArray.h"
 #include "InsetMathChar.h"
 #include "InsetMathDelim.h"
 #include "MathParser.h"
 #include "MathStream.h"
 
+#include "support/debug.h"
 #include "support/docstream.h"
+#include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 
 #include <algorithm>
 #include <sstream>
 #include <fstream>
+#include <memory>
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
-using support::cmd_ret;
-using support::getVectorFromString;
-using support::libFileSearch;
-using support::runCommand;
-using support::FileName;
-using support::quoteName;
-using support::tempName;
-using support::subst;
-
-using std::auto_ptr;
-using std::endl;
-using std::find_if;
-using std::istringstream;
-using std::ostream;
-using std::swap;
-using std::string;
-using std::vector;
-
 static char const * function_names[] = {
        "arccos", "arcsin", "arctan", "arg", "bmod",
        "cos", "cosh", "cot", "coth", "csc", "deg",
@@ -369,7 +354,7 @@ void splitScripts(MathData & ar)
 
                // create extra script inset and move superscript over
                InsetMathScript * p = ar[i].nucleus()->asScriptInset();
-               std::auto_ptr<InsetMathScript> q(new InsetMathScript(true));
+               auto_ptr<InsetMathScript> q(new InsetMathScript(true));
                swap(q->up(), p->up());
                p->removeScript(true);
 
@@ -571,7 +556,7 @@ void extractFunctions(MathData & ar)
                extractScript(exp, jt, ar.end(), true);
 
                // create a proper inset as replacement
-               std::auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(name));
+               auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(name));
 
                // jt points to the "argument". Get hold of this.
                MathData::iterator st = extractArgument(p->cell(0), jt, ar.end(), true);
@@ -823,7 +808,7 @@ void extractDiff(MathData & ar)
                }
 
                // create a proper diff inset
-               std::auto_ptr<InsetMathDiff> diff(new InsetMathDiff);
+               auto_ptr<InsetMathDiff> diff(new InsetMathDiff);
 
                // collect function, let jt point behind last used item
                MathData::iterator jt = it + 1;
@@ -1032,20 +1017,20 @@ void mathmlize(MathData const & dat, MathStream & os)
 
 namespace {
 
-       std::string captureOutput(std::string const & cmd, std::string const & data)
+       string captureOutput(string const & cmd, string const & data)
        {
                // In order to avoid parsing problems with command interpreters
                // we pass input data through a file
-               FileName const cas_tmpfile(tempName(FileName(), "casinput"));
+               FileName const cas_tmpfile = FileName::tempName("casinput");
                if (cas_tmpfile.empty()) {
                        lyxerr << "Warning: cannot create temporary file."
                               << endl;
-                       return std::string();
+                       return string();
                }
-               std::ofstream os(cas_tmpfile.toFilesystemEncoding().c_str());
+               ofstream os(cas_tmpfile.toFilesystemEncoding().c_str());
                os << data << endl;
                os.close();
-               std::string command =  cmd + " < "
+               string command =  cmd + " < "
                        + quoteName(cas_tmpfile.toFilesystemEncoding());
                lyxerr << "calling: " << cmd
                       << "\ninput: '" << data << "'" << endl;
@@ -1054,7 +1039,7 @@ namespace {
                return ret.second;
        }
 
-       size_t get_matching_brace(std::string const & str, size_t i)
+       size_t get_matching_brace(string const & str, size_t i)
        {
                int count = 1;
                size_t n = str.size();
@@ -1072,7 +1057,7 @@ namespace {
                return npos;
        }
 
-       size_t get_matching_brace_back(std::string const & str, size_t i)
+       size_t get_matching_brace_back(string const & str, size_t i)
        {
                int count = 1;
                while (i > 0) {
@@ -1097,7 +1082,7 @@ namespace {
                docstring expr = os.str();
                docstring const header = from_ascii("simpsum:true;");
 
-               std::string out;
+               string out;
                for (int i = 0; i < 100; ++i) { // at most 100 attempts
                        // try to fix missing '*' the hard way
                        //
@@ -1117,7 +1102,7 @@ namespace {
 
                        // search line with "Incorrect syntax"
                        istringstream is(out);
-                       std::string line;
+                       string line;
                        while (is) {
                                getline(is, line);
                                if (line.find("Incorrect syntax") != npos)
@@ -1137,11 +1122,11 @@ namespace {
                        expr.insert(pos, from_ascii("*"));
                }
 
-               vector<std::string> tmp = getVectorFromString(out, "$$");
+               vector<string> tmp = getVectorFromString(out, "$$");
                if (tmp.size() < 2)
                        return MathData();
 
-               out = subst(tmp[1], "\\>", std::string());
+               out = subst(tmp[1], "\\>", string());
                lyxerr << "output: '" << out << "'" << endl;
 
                // Ugly code that tries to make the result prettier
@@ -1151,10 +1136,10 @@ namespace {
                        size_t k = get_matching_brace(out, j + 1);
                        k = get_matching_brace(out, k + 1);
                        k = get_matching_brace(out, k + 1);
-                       std::string mid = out.substr(i + 13, j - i - 13);
+                       string mid = out.substr(i + 13, j - i - 13);
                        if (mid.find("\\over") != npos)
                                mid = '{' + mid + '}';
-                       out = out.substr(0,i)
+                       out = out.substr(0, i)
                                + mid
                                + out.substr(k + 1);
                        //lyxerr << "output: " << out << endl;
@@ -1170,10 +1155,10 @@ namespace {
                        size_t k = get_matching_brace(out, i + 5);
                        if (k == npos || k + 1 == out.size())
                                break;
-                       out = out.substr(0,j - 1)
+                       out = out.substr(0, j - 1)
                                + "\\frac"
-                               + out.substr(j,i - j)
-                               + out.substr(i + 5,k - i - 4)
+                               + out.substr(j, i - j)
+                               + out.substr(i + 5, k - i - 4)
                                + out.substr(k + 2);
                        //lyxerr << "output: " << out << endl;
                        i = out.find("\\over", i + 4);
@@ -1186,7 +1171,7 @@ namespace {
 
        MathData pipeThroughMaple(docstring const & extra, MathData const & ar)
        {
-               std::string header = "readlib(latex):\n";
+               string header = "readlib(latex):\n";
 
                // remove the \\it for variable names
                //"#`latex/csname_font` := `\\it `:"
@@ -1214,11 +1199,11 @@ namespace {
                //"#`latex/latex/symbol` "
                //      " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
 
-               std::string trailer = "quit;";
+               string trailer = "quit;";
                odocstringstream os;
                MapleStream ms(os);
                ms << ar;
-               std::string expr = to_utf8(os.str());
+               string expr = to_utf8(os.str());
                lyxerr << "ar: '" << ar << "'\n"
                       << "ms: '" << expr << "'" << endl;
 
@@ -1443,7 +1428,7 @@ MathData pipeThroughExtern(string const & lang, docstring const & extra,
        string data = to_utf8(os.str());
 
        // search external script
-       support::FileName const file = libFileSearch("mathed", "extern_" + lang);
+       FileName const file = libFileSearch("mathed", "extern_" + lang);
        if (file.empty()) {
                lyxerr << "converter to '" << lang << "' not found" << endl;
                return MathData();