// 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
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_));
}
auto p = make_unique<InsetMathExFunc>(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
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));
}
{
// 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> 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;
lyxerr << "calling: " << cmd
<< "\ninput: '" << data << "'" << endl;
cmd_ret const ret = runCommand(command);
+ cas_tmpfile.removeFile();
return ret.second;
}
return res;
}
-}
+} // namespace
-} // anon namespace
+} // namespace
void write(MathData const & dat, WriteStream & wi)
{
void writeString(docstring const & s, WriteStream & os)
{
- if (!os.latex() || os.lockedMode()) {
+ if (!os.latex()) {
os << (os.asciiOnly() ? escape(s) : s);
return;
}
+ if (os.lockedMode()) {
+ bool space;
+ docstring cmd;
+ for (char_type c : s) {
+ try {
+ Encodings::latexMathChar(c, true, os.encoding(), cmd, space);
+ os << cmd;
+ os.pendingSpace(space);
+ } catch (EncodingException const & e) {
+ switch (os.output()) {
+ case WriteStream::wsDryrun: {
+ os << "<" << _("LyX Warning: ")
+ << _("uncodable character") << " '";
+ os << docstring(1, e.failed_char);
+ os << "'>";
+ break;
+ }
+ case WriteStream::wsPreview: {
+ // indicate the encoding error by a boxed '?'
+ os << "{\\fboxsep=1pt\\fbox{?}}";
+ LYXERR0("Uncodable character" << " '"
+ << docstring(1, e.failed_char)
+ << "'");
+ break;
+ }
+ case WriteStream::wsDefault:
+ default:
+ // throw again
+ throw(e);
+ }
+ }
+ }
+ return;
+ }
+
docstring::const_iterator cit = s.begin();
docstring::const_iterator end = s.end();