diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CaseConvert.cxx | 14 | 
1 files changed, 9 insertions, 5 deletions
| diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx index 8f5a25aa4..6228f89d3 100644 --- a/src/CaseConvert.cxx +++ b/src/CaseConvert.cxx @@ -8,6 +8,7 @@  // Copyright 2013 by Neil Hodgson <neilh@scintilla.org>  // The License.txt file describes the conditions under which this software may be distributed. +#include <cassert>  #include <cstring>  #include <stdexcept> @@ -16,7 +17,6 @@  #include <vector>  #include <algorithm> -#include "StringCopy.h"  #include "CaseConvert.h"  #include "UniConversion.h" @@ -572,8 +572,12 @@ class CaseConverter : public ICaseConverter {  	struct CharacterConversion {  		int character;  		ConversionString conversion; -		CharacterConversion(int character_=0, const char *conversion_="") noexcept : character(character_) { -			StringCopy(conversion.conversion, conversion_); +		CharacterConversion() noexcept : character(0) { +			// Empty case: NUL -> "". +		} +		CharacterConversion(int character_, std::string_view conversion_) noexcept : character(character_) { +			assert(conversion_.length() <= maxConversionLength); +			std::copy(std::begin(conversion_), std::end(conversion_), conversion.conversion);  		}  		bool operator<(const CharacterConversion &other) const noexcept {  			return character < other.character; @@ -685,7 +689,7 @@ void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {  void SetupConversions(enum CaseConversion conversion) {  	// First initialize for the symmetric ranges -	for (size_t i=0; i<ELEMENTS(symmetricCaseConversionRanges);) { +	for (size_t i=0; i<std::size(symmetricCaseConversionRanges);) {  		const int lower = symmetricCaseConversionRanges[i++];  		const int upper = symmetricCaseConversionRanges[i++];  		const int length = symmetricCaseConversionRanges[i++]; @@ -695,7 +699,7 @@ void SetupConversions(enum CaseConversion conversion) {  		}  	}  	// Add the symmetric singletons -	for (size_t i=0; i<ELEMENTS(symmetricCaseConversions);) { +	for (size_t i=0; i<std::size(symmetricCaseConversions);) {  		const int lower = symmetricCaseConversions[i++];  		const int upper = symmetricCaseConversions[i++];  		AddSymmetric(conversion, lower, upper); | 
