From b59d7f44d6a9acdfca0ebe927f3ae99dbcff1578 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 7 Apr 2009 17:41:25 +0000 Subject: [PATCH] Introduce a helper function and use it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29145 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathNest.cpp | 2 +- src/mathed/MathFactory.cpp | 6 ++++++ src/mathed/MathFactory.h | 5 +++++ src/mathed/MathParser.cpp | 9 ++++----- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 826e152c71..203977fd39 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1598,7 +1598,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type c) cur.niceInsert(createInsetMath("sim")); return true; } - if (c >= 0x80 && !Encodings::isMathAlpha(c)) { + if (!isAsciiOrMathAlpha(c)) { MathAtom at = createInsetMath("text"); at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c))); cur.niceInsert(at); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 84bc7d33b9..4f02543014 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -505,4 +505,10 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar) } +bool isAsciiOrMathAlpha(char_type c) +{ + return c < 0x80 || Encodings::isMathAlpha(c); +} + + } // namespace lyx diff --git a/src/mathed/MathFactory.h b/src/mathed/MathFactory.h index fbc130cda1..fbe2cb59c4 100644 --- a/src/mathed/MathFactory.h +++ b/src/mathed/MathFactory.h @@ -33,6 +33,11 @@ MathAtom createInsetMath(char const * const); */ bool createInsetMath_fromDialogStr(docstring const &, MathData &); +/** Tells whether the argument is an ascii character or is marked as + * mathalpha in the unicodesymbols file. + */ +bool isAsciiOrMathAlpha(char_type); + typedef std::map MathWordList; MathWordList const & mathedWordList(); diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 45b14819f6..30cd008ad8 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -909,17 +909,16 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, else if (t.cat() == catOther) { char_type c = t.character(); - if (c < 0x80 || mode_ & Parse::VERBATIM + if (isAsciiOrMathAlpha(c) + || mode_ & Parse::VERBATIM || !(mode_ & Parse::USETEXT) - || mode == InsetMath::TEXT_MODE - || Encodings::isMathAlpha(c)) { + || mode == InsetMath::TEXT_MODE) { cell->push_back(MathAtom(new InsetMathChar(c))); } else { MathAtom at = createInsetMath("text"); at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c))); while (nextToken().cat() == catOther - && nextToken().character() >= 0x80 - && !Encodings::isMathAlpha(nextToken().character())) { + && !isAsciiOrMathAlpha(nextToken().character())) { c = getToken().character(); at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c))); }