commit e3c3719643c46819aa586346a313d514c5903898
Author: Enrico Forestieri <[email protected]>
Date: Mon Oct 31 15:23:20 2016 +0100
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 5a61a8b..d23855c 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -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()) {
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 06a55bf..4a94e03 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 4b0e538..c0f3e87 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)