From 27d993e500726fb661959880174cf5d87f7b8eae Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 5 Mar 2023 18:08:08 +0800 Subject: [PATCH] - fix: Hex number with 'f' in not is not correctly colored. --- NEWS.md | 1 + libs/qsynedit/qsynedit/syntaxer/cpp.cpp | 44 ++++++++++++++++++++----- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 87aba894..5853d344 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ Red Panda C++ Version 2.17 - enhancement: Add "address" in the memory view's mouse tip. - enhancement: Show mousetip for numbers in the GNU assembly file. - enhancement: Open offline gnu as/x86 assembly manual if exists. + - fix: Hex number with 'f' in not is not correctly colored. Red Panda C++ Version 2.16 diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp index 4ee426bd..6b39fd83 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp @@ -684,14 +684,18 @@ void CppSyntaxer::numberProc() if (mTokenId != TokenId::Number) { return; } + mRun++; break; case '.': - if (mTokenId != TokenId::Octal) { + if (mTokenId == TokenId::Number) { mTokenId = TokenId::Float; + } else if (mTokenId == TokenId::Hex) { + mTokenId = TokenId::HexFloat; } else { mTokenId = TokenId::Unknown; return; } + mRun++; break; case '0': case '1': @@ -701,38 +705,60 @@ void CppSyntaxer::numberProc() case '5': case '6': case '7': + mRun++; + break; case '8': case '9': + if (mTokenId == TokenId::Octal) + return; + else { + mRun++; + break; + } case 'a': case 'b': case 'c': case 'd': + case 'f': case 'A': case 'B': case 'C': case 'D': + case 'F': + if (mTokenId != TokenId::Hex + && mTokenId != TokenId::HexFloat) + return; + else { + mRun++; + break; + } + mRun++; break; case 'e': case 'E': - if (mTokenId==TokenId::Number) { + if (mTokenId==TokenId::Number || mTokenId == TokenId::Float) { mTokenId = TokenId::Float; mRun++; if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator mRun++; - break; - } + } else if (mTokenId==TokenId::Octal) { + return; + } else + mRun++; break; case 'p': case 'P': - mTokenId = TokenId::Float; - mRun++; - if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator + if (mTokenId==TokenId::Hex || mTokenId==TokenId::HexFloat) { + mTokenId = TokenId::HexFloat; mRun++; - break; + if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator + mRun++; + break; + } else + return; default: return; } - mRun+=1; } }