Fix parsing formulas with not canonical math symbols.

This commit is contained in:
Roman Telezhynskyi 2021-06-11 15:30:06 +03:00
parent 40619c22ef
commit 5672e616af
2 changed files with 33 additions and 5 deletions

View File

@ -1,5 +1,6 @@
# Valentina 0.7.48 (unreleased) # Valentina 0.7.48 (unreleased)
- [smart-pattern/valentina#129] Incorrect behavior of empty arc and elliptical arc. - [smart-pattern/valentina#129] Incorrect behavior of empty arc and elliptical arc.
- Parsing formulas with not canonical math symbols.
# Version 0.7.47 May 13, 2021 # Version 0.7.47 May 13, 2021
- [smart-pattern/valentina#118] Incorrect seam allowance. - [smart-pattern/valentina#118] Incorrect seam allowance.

View File

@ -80,17 +80,44 @@ void QmuFormulaBase::InitCharSets()
Q_UNUSED(decimalPoint) Q_UNUSED(decimalPoint)
Q_UNUSED(groupSeparator) Q_UNUSED(groupSeparator)
// Together with localized symbols, we always must include canonical symbols
auto AddNotCanonical = [](QString &chars, const QChar &c, const QChar &canonical)
{
if (c != canonical)
{
chars += c;
}
};
// Defining identifier character sets // Defining identifier character sets
const QString nameChars = QString() + sign0 + sign1 + sign2 + sign3 + sign4 + sign5 + sign6 + sign7 + sign8 + QString nameChars = QStringLiteral("0123456789\\_@#'") + symbolsStr;
sign9 + QStringLiteral("\\_@#'") + symbolsStr;
AddNotCanonical(nameChars, sign0, '0');
AddNotCanonical(nameChars, sign1, '1');
AddNotCanonical(nameChars, sign2, '2');
AddNotCanonical(nameChars, sign3, '3');
AddNotCanonical(nameChars, sign4, '4');
AddNotCanonical(nameChars, sign5, '5');
AddNotCanonical(nameChars, sign6, '6');
AddNotCanonical(nameChars, sign7, '7');
AddNotCanonical(nameChars, sign8, '8');
AddNotCanonical(nameChars, sign9, '9');
DefineNameChars(nameChars); DefineNameChars(nameChars);
const QString opChars = QStringLiteral("*^/?<>=!$%&|~'_"); const QString opChars = QStringLiteral("+-*^/?<>=!$%&|~'_");
QString oprtChars = symbolsStr + opChars;
AddNotCanonical(oprtChars, positiveSign, '+');
AddNotCanonical(oprtChars, negativeSign, '-');
const QString oprtChars = symbolsStr + positiveSign + negativeSign + opChars;
DefineOprtChars(oprtChars); DefineOprtChars(oprtChars);
const QString infixOprtChars = QString() + positiveSign + negativeSign + opChars; QString infixOprtChars = opChars;
AddNotCanonical(infixOprtChars, positiveSign, '+');
AddNotCanonical(infixOprtChars, negativeSign, '-');
DefineInfixOprtChars(infixOprtChars); DefineInfixOprtChars(infixOprtChars);
} }