From d05d7fbd132b6a8060b3f0fa3a7a56cfaa0c41e0 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 21 Apr 2018 16:18:38 +1000 Subject: Safety improvements for character code - drop reinterpret_cast, ensure more variables are initialized, specify noexcept when safe. --- lexlib/CharacterCategory.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lexlib') 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 +#include -#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(*(placeAfter-1) & maskCategory); } -- cgit v1.2.3