From 3455e3b3f980c480d53e3408af6b492741627edf Mon Sep 17 00:00:00 2001 From: zufuliu Date: Tue, 13 Oct 2020 23:14:40 +0800 Subject: [PATCH] Improve mark occurrences by using case sensitive match for ASCII text without letters, issue #236. --- src/Edit.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Edit.c b/src/Edit.c index 58c9774026..25b299a801 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5629,6 +5629,21 @@ void EditMarkAll_ClearEx(int findFlag, Sci_Position iSelCount, LPCSTR pszText) { } BOOL EditMarkAll_Start(BOOL bChanged, int findFlag, Sci_Position iSelCount, LPCSTR pszText) { + // use case sensitive match for ASCII text without letters. + if (!(findFlag & (SCFIND_REGEXP | SCFIND_MATCHCASE))) { + int sensitive = SCFIND_MATCHCASE; + const uint8_t *ptr = (const uint8_t *)pszText; + uint8_t ch; + while ((ch = *ptr++) != 0) { + ch |= 0x20; + if ((ch & 0x80) != 0 || (ch >= 'a' && ch <= 'z')) { + sensitive = 0; + break; + } + } + findFlag |= sensitive; + } + if (!bChanged && (findFlag == editMarkAllStatus.findFlag && iSelCount == editMarkAllStatus.iSelCount // _stricmp() is not safe for DBCS string.