From e3c3719643c46819aa586346a313d514c5903898 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 31 Oct 2016 15:23:20 +0100 Subject: [PATCH] Don't print useless messages while parsing math macros 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 | 2 +- src/mathed/MathMacro.cpp | 3 ++- src/mathed/MathParser.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp index 5a61a8ba58..d23855c511 100644 --- a/src/mathed/MacroTable.cpp +++ b/src/mathed/MacroTable.cpp @@ -71,7 +71,7 @@ bool MacroData::expand(vector const & args, MathData & to) const InsetMathSqrt inset(const_cast(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()) { diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 06a55bf703..4a94e03189 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -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); } diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 4b0e5386c6..c0f3e87e60 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -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) -- 2.39.2