]> git.lyx.org Git - features.git/commitdiff
Don't print useless messages while parsing math macros
authorEnrico Forestieri <forenr@lyx.org>
Mon, 31 Oct 2016 14:23:20 +0000 (15:23 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 31 Oct 2016 14:23:20 +0000 (15:23 +0100)
Math macros can be displayed on screen by providing a different
representation than the one used for latex output. This representation
is actually used by lyx even while it is being updated. This leads to
printing useless error messages on the terminal. For example, a macro
parameter has to be entered as \#1 and, if the macro is already used in
a math inset, lyx prints on terminal the error message "Math parse error:
missing token after \\" as soon as one hits the \ key, followed by
"MathMacroArgument::MathMacroArgument: wrong Argument id: -48" as soon as
one hits the # key. So, this is not a useful information and simply
clutters the terminal output. On the other hand, the input is sanitized
even if one stops input after hitting either \ or #, so that no further
messages are issued. Hence, those error messages are simply pointless.

src/mathed/MacroTable.cpp
src/mathed/MathMacro.cpp
src/mathed/MathParser.cpp

index 5a61a8ba581176b382a64e9bb13e6ef2d1d973b6..d23855c511f5bd3fadd26661f81fc2d0b97a9abf 100644 (file)
@@ -71,7 +71,7 @@ bool MacroData::expand(vector<MathData> const & args, MathData & to) const
        InsetMathSqrt inset(const_cast<Buffer *>(buffer_));
 
        docstring const & definition(display_.empty() ? definition_ : display_);
-       asArray(definition, inset.cell(0));
+       asArray(definition, inset.cell(0), Parse::QUIET);
        //lyxerr << "MathData::expand: args: " << args << endl;
        //LYXERR0("MathData::expand: ar: " << inset.cell(0));
        for (DocIterator it = doc_iterator_begin(buffer_, &inset); it; it.forwardChar()) {
index 06a55bf7036d391756f80417f045d6e57e52d092..4a94e0318961caa66f1740be36267c382deb5744 100644 (file)
@@ -539,7 +539,8 @@ void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
        }
        // get definition for list edit mode
        docstring const & display = d->macro_->display();
-       asArray(display.empty() ? d->macro_->definition() : display, d->definition_);
+       asArray(display.empty() ? d->macro_->definition() : display,
+               d->definition_, Parse::QUIET);
 }
 
 
index 4b0e5386c602caa4eaf7e44b699dbda44d82044a..c0f3e87e606ca810aad0d3c11150c2f28d4de95e 100644 (file)
@@ -930,7 +930,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
 
                else if (t.cat() == catParameter) {
                        Token const & n = getToken();
-                       cell->push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
+                       if (n.character())
+                               cell->push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
                }
 
                else if (t.cat() == catActive)