From 968f980b13de114230474af4a4b68d210d971430 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sun, 15 Sep 2019 23:31:32 +0200 Subject: [PATCH] Make code more obvious - use propoer parenthesis - do not store in variable something we do not use Spotted by cppcheck. --- src/mathed/MathParser.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index da272bfc8d..ee60353046 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -622,7 +622,7 @@ void Parser::tokenize(istream & is) void Parser::tokenize(docstring const & buffer) { - idocstringstream is(mode_ & Parse::VERBATIM + idocstringstream is((mode_ & Parse::VERBATIM) ? escapeSpecialChars(buffer, mode_ & Parse::TEXTMODE) : buffer, ios::in | ios::binary); @@ -744,8 +744,9 @@ docstring Parser::parse_verbatim_option() skipSpaces(); docstring res; if (nextToken().character() == '[') { - Token t = getToken(); - for (t = getToken(); t.character() != ']' && good(); t = getToken()) { + // eat [ + getToken(); + for (Token t = getToken(); t.character() != ']' && good(); t = getToken()) { if (t.cat() == catBegin) { putback(); res += '{' + parse_verbatim_item() + '}'; @@ -762,8 +763,9 @@ docstring Parser::parse_verbatim_item() skipSpaces(); docstring res; if (nextToken().cat() == catBegin) { - Token t = getToken(); - for (t = getToken(); t.cat() != catEnd && good(); t = getToken()) { + // eat catBegin + getToken(); + for (Token t = getToken(); t.cat() != catEnd && good(); t = getToken()) { if (t.cat() == catBegin) { putback(); res += '{' + parse_verbatim_item() + '}'; @@ -1985,7 +1987,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, BufferParams::package_off; bool const is_user_macro = no_mhchem || - (buf && (mode_ & Parse::TRACKMACRO + (buf && ((mode_ & Parse::TRACKMACRO) ? buf->usermacros.count(t.cs()) != 0 : buf->getMacro(t.cs(), false) != 0)); @@ -2157,7 +2159,7 @@ char const * latexkeys::MathMLtype() const bool mathed_parse_cell(MathData & ar, docstring const & str, Parse::flags f) { - return Parser(str, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ? + return Parser(str, f, ar.buffer()).parse(ar, 0, (f & Parse::TEXTMODE) ? InsetMath::TEXT_MODE : InsetMath::MATH_MODE); } @@ -2186,7 +2188,7 @@ bool mathed_parse_normal(Buffer * buf, MathAtom & t, Lexer & lex, bool mathed_parse_normal(InsetMathGrid & grid, docstring const & str, Parse::flags f) { - return Parser(str, f, &grid.buffer()).parse1(grid, 0, f & Parse::TEXTMODE ? + return Parser(str, f, &grid.buffer()).parse1(grid, 0, (f & Parse::TEXTMODE) ? InsetMath::TEXT_MODE : InsetMath::MATH_MODE, false); } -- 2.39.5