X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathExtern.cpp;h=52fa0cf0fa831fa4913810bb900519f87d009faa;hb=0cba074ecf0e25ede759ee1f817a7cfec06537d6;hp=7fbb4af732fb10fa941cb57d9d01c50d3a0d758b;hpb=c51ebd9bbc01a23babccb7854623888093b3b8fe;p=lyx.git diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index 7fbb4af732..52fa0cf0fa 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -45,6 +45,7 @@ #include "support/lstrings.h" #include "support/TempFile.h" #include "support/textutils.h" +#include "support/unique_ptr.h" #include #include @@ -114,7 +115,7 @@ bool extractScript(MathData & ar, // try to extract an "argument" to some function. // returns position behind the argument MathData::iterator extractArgument(MathData & ar, - MathData::iterator pos, MathData::iterator last, + MathData::iterator pos, MathData::iterator last, ExternalMath kind, bool function = false) { // nothing to get here @@ -210,7 +211,7 @@ void extractMatrices(MathData & ar) continue; if (!arr.front()->asGridInset()) continue; - ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset()), + ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset()), inset->left_, inset->right_)); } @@ -370,7 +371,7 @@ void splitScripts(MathData & ar) // create extra script inset and move superscript over InsetMathScript * p = ar[i].nucleus()->asScriptInset(); - auto_ptr q(new InsetMathScript(buf, true)); + auto q = make_unique(buf, true); swap(q->up(), p->up()); p->removeScript(true); @@ -598,10 +599,10 @@ void extractFunctions(MathData & ar, ExternalMath kind) extractScript(exp, jt, ar.end(), true); // create a proper inset as replacement - auto_ptr p(new InsetMathExFunc(buf, name)); + auto p = make_unique(buf, name); // jt points to the "argument". Get hold of this. - MathData::iterator st = + MathData::iterator st = extractArgument(p->cell(0), jt, ar.end(), kind, true); // replace the function name by a real function inset @@ -683,7 +684,7 @@ void extractIntegrals(MathData & ar, ExternalMath kind) continue; // core ist part from behind the scripts to the 'd' - auto_ptr p(new InsetMathExInt(buf, from_ascii("int"))); + auto p = make_unique(buf, from_ascii("int")); // handle scripts if available if (!testIntSymbol(*it)) { @@ -768,7 +769,7 @@ void extractSums(MathData & ar) continue; // create a proper inset as replacement - auto_ptr p(new InsetMathExInt(buf, from_ascii("sum"))); + auto p = make_unique(buf, from_ascii("sum")); // collect lower bound and summation index InsetMathScript const * sub = ar[i]->asScriptInset(); @@ -856,7 +857,7 @@ void extractDiff(MathData & ar) } // create a proper diff inset - auto_ptr diff(new InsetMathDiff(buf)); + auto diff = make_unique(buf); // collect function, let jt point behind last used item MathData::iterator jt = it + 1; @@ -895,6 +896,10 @@ void extractDiff(MathData & ar) int mult = 1; if (extractNumber(script->up(), mult)) { //lyxerr << "mult: " << mult << endl; + if (mult < 0 || mult > 1000) { + lyxerr << "Cannot differentiate less than 0 or more than 1000 times !" << endl; + continue; + } for (int i = 0; i < mult; ++i) diff->addDer(MathData(buf, dt + 1, st)); } @@ -1000,8 +1005,13 @@ namespace { { // In order to avoid parsing problems with command interpreters // we pass input data through a file - TempFile tempfile("casinput"); - FileName const cas_tmpfile = tempfile.name(); + // Since the CAS is supposed to read the temp file we need + // to unlock it on windows (bug 10262). + unique_ptr tempfile(new TempFile("casinput")); + tempfile->setAutoRemove(false); + FileName const cas_tmpfile = tempfile->name(); + tempfile.reset(); + if (cas_tmpfile.empty()) { lyxerr << "Warning: cannot create temporary file." << endl; @@ -1015,6 +1025,7 @@ namespace { lyxerr << "calling: " << cmd << "\ninput: '" << data << "'" << endl; cmd_ret const ret = runCommand(command); + cas_tmpfile.removeFile(); return ret.second; } @@ -1105,7 +1116,7 @@ namespace { if (tmp.size() < 2) return MathData(); - out = subst(tmp[1], "\\>", string()); + out = subst(subst(tmp[1], "\\>", string()), "{\\it ", "\\mathit{"); lyxerr << "output: '" << out << "'" << endl; // Ugly code that tries to make the result prettier @@ -1380,9 +1391,9 @@ namespace { return res; } -} +} // namespace -} // anon namespace +} // namespace void write(MathData const & dat, WriteStream & wi) {