From 47c094313ab711b785e41a08e55350e1d447fa04 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 27 Nov 2025 08:45:01 +1100 Subject: Feature [feature-requests:#1564]. Ensure DCBS fold map initialized and folding produces sensible values when DBCS lead byte followed by non trail byte. --- src/DBCS.h | 2 +- win32/ScintillaWin.cxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DBCS.h b/src/DBCS.h index 96d282446..ccd71536a 100644 --- a/src/DBCS.h +++ b/src/DBCS.h @@ -37,7 +37,7 @@ constexpr uint16_t DBCSIndex(char ch1, char ch2) noexcept { } struct DBCSPair { - char chars[2]; + char chars[2]{}; }; using FoldMap = std::array; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index fbec35f76..392e0b86c 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -2813,10 +2813,10 @@ void CreateFoldMap(int codePage, FoldMap *foldingMap) { if (DBCSIsLeadByte(codePage, ch1)) { for (unsigned char byte2 = highByteLast; byte2 >= minTrailByte; byte2--) { const char ch2 = byte2; + const DBCSPair pair{ ch1, ch2 }; + const uint16_t index = DBCSIndex(ch1, ch2); + (*foldingMap)[index] = pair; if (DBCSIsTrailByte(codePage, ch2)) { - const DBCSPair pair{ ch1, ch2 }; - const uint16_t index = DBCSIndex(ch1, ch2); - (*foldingMap)[index] = pair; const std::string_view svBytes(pair.chars, 2); const int lenUni = WideCharLenFromMultiByte(codePage, svBytes); if (lenUni == 1) { -- cgit v1.2.3