aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib/CharacterCategory.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-04-21 16:18:38 +1000
committerNeil <nyamatongwe@gmail.com>2018-04-21 16:18:38 +1000
commitad920ffd5c74a25c3328f4cbec0afea0b13d5f0f (patch)
tree823adf0e12880ef9572b120724169ec9b03bdb9a /lexlib/CharacterCategory.cxx
parent66ee3c782885d6aec534ec949acabd6f08085a9e (diff)
downloadscintilla-mirror-ad920ffd5c74a25c3328f4cbec0afea0b13d5f0f.tar.gz
Backport: Safety improvements for character code - drop reinterpret_cast, ensure more
variables are initialized, specify noexcept when safe. Backport of changeset 6727:8f4de063e95c.
Diffstat (limited to 'lexlib/CharacterCategory.cxx')
-rw-r--r--lexlib/CharacterCategory.cxx5
1 files changed, 2 insertions, 3 deletions
diff --git a/lexlib/CharacterCategory.cxx b/lexlib/CharacterCategory.cxx
index 92ad49fb0..1595a7192 100644
--- a/lexlib/CharacterCategory.cxx
+++ b/lexlib/CharacterCategory.cxx
@@ -8,8 +8,8 @@
// The License.txt file describes the conditions under which this software may be distributed.
#include <algorithm>
+#include <iterator>
-#include "StringCopy.h"
#include "CharacterCategory.h"
namespace Scintilla {
@@ -3679,7 +3679,6 @@ const int catRanges[] = {
const int maxUnicode = 0x10ffff;
const int maskCategory = 0x1F;
-const int nRanges = ELEMENTS(catRanges);
}
@@ -3698,7 +3697,7 @@ CharacterCategory CategoriseCharacter(int character) {
if (character < 0 || character > maxUnicode)
return ccCn;
const int baseValue = character * (maskCategory+1) + maskCategory;
- const int *placeAfter = std::lower_bound(catRanges, catRanges+nRanges, baseValue);
+ const int *placeAfter = std::lower_bound(catRanges, std::end(catRanges), baseValue);
return static_cast<CharacterCategory>(*(placeAfter-1) & maskCategory);
}