aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Semke <alexander.semke@web.de>2016-11-13 10:52:27 (GMT)
committerAlexander Semke <alexander.semke@web.de>2016-11-13 10:52:27 (GMT)
commit0659bcf5e4b6d6da278e3894057d3bde873c6ea5 (patch)
tree7c20fc300c0f1a1bfd78c4f1e73ac9caf901ad15
parent0dd2b9672369ebda020993fb2f583fe6c3c6f865 (diff)
Correctly parse multi-valued function definitions in maxima variable model.
BUG: 363915 FIXED-IN: 16.12
-rw-r--r--src/backends/maxima/maximavariablemodel.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/backends/maxima/maximavariablemodel.cpp b/src/backends/maxima/maximavariablemodel.cpp
index a87ebb4..8aea6ea 100644
--- a/src/backends/maxima/maximavariablemodel.cpp
+++ b/src/backends/maxima/maximavariablemodel.cpp
@@ -92,12 +92,30 @@ QList<Cantor::DefaultVariableModel::Variable> parse(MaximaExpression* expr)
if(namesString.isEmpty())
return QList<Cantor::DefaultVariableModel::Variable>();
- QStringList variableNames=namesString.split(QLatin1Char(','));
-
- QString valuesString=text.mid(nameIndex+1).trimmed();
-
- QStringList variableValues=valuesString.split(QLatin1String("\"-cantor-value-separator-\""));
- bool hasValues=variableValues.isEmpty();
+ QStringList variableNames;
+ QString valuesString;
+ bool hasValues = false;
+ QStringList variableValues;
+ if ( namesString.contains(QLatin1Char(')')) )
+ {
+ //function definition(s): e.g
+ //text = "[f1(x),f2(x,y),f3(x,y,z)]\n$DONE"
+ //nameString = f1(x),f2(x,y),f3(x,y,z)
+ //variableString = "\n$DONE"
+ variableNames = namesString.split(QLatin1String("),"));
+ }
+ else
+ {
+ //variable definition(s): e.g.
+ //text = "[a,b]\n1\n\"-cantor-value-separator-\"\n2\n\"-cantor-value-separator-\"\n($A $B)"
+ //nameString = "[a,b]"
+ //variableString = "\n1\n\"-cantor-value-separator-\"\n2\n\"-cantor-value-separator-\"\n($A $B)"
+ variableNames = namesString.split(QLatin1Char(','));
+ valuesString = text.mid(nameIndex+1).trimmed();
+ valuesString = valuesString.remove(QLatin1String("\n")); //lists with many elements have line breaks, remove them
+ variableValues = valuesString.split(QLatin1String("\"-cantor-value-separator-\""));
+ hasValues = variableValues.isEmpty();
+ }
qDebug()<<variableNames;
qDebug()<<"string: "<<valuesString;