aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-03-13 09:03:15 +1100
committerNeil <nyamatongwe@gmail.com>2020-03-13 09:03:15 +1100
commit3d4fafdd662a2ac7267afdaef44bad54302ebe50 (patch)
tree29831fd53d1d0fdb6dff8e0a6bc9d47dc4b75d27
parent62e9baae3f94f4bdc1c1741f056ccbd7e48421e6 (diff)
downloadscintilla-mirror-3d4fafdd662a2ac7267afdaef44bad54302ebe50.tar.gz
Backport: Using constexpr in UniConversion and CaseConvert.
Backport of changeset 8004:7052c60ce1b2.
-rw-r--r--src/CaseConvert.cxx2
-rw-r--r--src/CaseConvert.h2
-rw-r--r--src/UniConversion.h8
-rw-r--r--win32/ScintillaWin.cxx2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx
index 9ecf3e2e8..26104f33d 100644
--- a/src/CaseConvert.cxx
+++ b/src/CaseConvert.cxx
@@ -716,7 +716,7 @@ void SetupConversions(enum CaseConversion conversion) {
const char *sComplex = complexCaseConversions;
while (*sComplex) {
// Longest ligature is 3 character so 5 for safety
- const size_t lenUTF8 = 5*UTF8MaxBytes+1;
+ constexpr size_t lenUTF8 = 5*UTF8MaxBytes+1;
unsigned char originUTF8[lenUTF8]{};
char foldedUTF8[lenUTF8]{};
char lowerUTF8[lenUTF8]{};
diff --git a/src/CaseConvert.h b/src/CaseConvert.h
index cdd089710..e3057c841 100644
--- a/src/CaseConvert.h
+++ b/src/CaseConvert.h
@@ -31,7 +31,7 @@ const char *CaseConvert(int character, enum CaseConversion conversion);
// When performing CaseConvertString, the converted value may be up to 3 times longer than the input.
// Ligatures are often decomposed into multiple characters and long cases include:
// ΐ "\xce\x90" folds to ΐ "\xce\xb9\xcc\x88\xcc\x81"
-const int maxExpansionCaseConversion=3;
+constexpr size_t maxExpansionCaseConversion = 3;
// Converts a mixed case string using a particular conversion.
// Result may be a different length to input and the length is the return value.
diff --git a/src/UniConversion.h b/src/UniConversion.h
index e8e98df5f..979075f5a 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -10,9 +10,9 @@
namespace Scintilla {
-const int UTF8MaxBytes = 4;
+constexpr int UTF8MaxBytes = 4;
-const int unicodeReplacementChar = 0xFFFD;
+constexpr int unicodeReplacementChar = 0xFFFD;
size_t UTF8Length(const wchar_t *uptr, size_t tlen) noexcept;
void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len);
@@ -60,13 +60,13 @@ int UTF8DrawBytes(const unsigned char *us, int len) noexcept;
// Line separator is U+2028 \xe2\x80\xa8
// Paragraph separator is U+2029 \xe2\x80\xa9
-const int UTF8SeparatorLength = 3;
+constexpr int UTF8SeparatorLength = 3;
inline bool UTF8IsSeparator(const unsigned char *us) noexcept {
return (us[0] == 0xe2) && (us[1] == 0x80) && ((us[2] == 0xa8) || (us[2] == 0xa9));
}
// NEL is U+0085 \xc2\x85
-const int UTF8NELLength = 2;
+constexpr int UTF8NELLength = 2;
inline bool UTF8IsNEL(const unsigned char *us) noexcept {
return (us[0] == 0xc2) && (us[1] == 0x85);
}
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index be4c59d4e..ae4ee839e 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1031,7 +1031,7 @@ void ScintillaWin::EscapeHanja() {
// ImmEscapeW() may overwrite uniChar[] with a null terminated string.
// So enlarge it enough to Maximum 4 as in UTF-8.
- unsigned int const safeLength = UTF8MaxBytes+1;
+ constexpr size_t safeLength = UTF8MaxBytes + 1;
std::string oneChar(safeLength, '\0');
pdoc->GetCharRange(&oneChar[0], currentPos, oneCharLen);