mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Remove the ill-considered StringRef::numberOfCharacters
It never counted characters, only codepoints. If you think these are interchangeable, you should not touch non-ascii text.
This commit is contained in:
		| @@ -17,12 +17,6 @@ | ||||
| #include <cstring> | ||||
| #include <cstdint> | ||||
|  | ||||
| namespace { | ||||
|     const uint32_t byte_2_lead = 0xC0; | ||||
|     const uint32_t byte_3_lead = 0xE0; | ||||
|     const uint32_t byte_4_lead = 0xF0; | ||||
| } | ||||
|  | ||||
| namespace Catch { | ||||
|     StringRef::StringRef( char const* rawChars ) noexcept | ||||
|     : StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) ) | ||||
| @@ -82,22 +76,6 @@ namespace Catch { | ||||
|         return m_start[index]; | ||||
|     } | ||||
|  | ||||
|     auto StringRef::numberOfCharacters() const noexcept -> size_type { | ||||
|         size_type noChars = m_size; | ||||
|         // Make adjustments for uft encodings | ||||
|         for( size_type i=0; i < m_size; ++i ) { | ||||
|             char c = m_start[i]; | ||||
|             if( ( c & byte_2_lead ) == byte_2_lead ) { | ||||
|                 noChars--; | ||||
|                 if (( c & byte_3_lead ) == byte_3_lead ) | ||||
|                     noChars--; | ||||
|                 if( ( c & byte_4_lead ) == byte_4_lead ) | ||||
|                     noChars--; | ||||
|             } | ||||
|         } | ||||
|         return noChars; | ||||
|     } | ||||
|  | ||||
|     auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { | ||||
|         std::string str; | ||||
|         str.reserve( lhs.size() + rhs.size() ); | ||||
|   | ||||
| @@ -96,7 +96,6 @@ namespace Catch { | ||||
|             return m_size; | ||||
|         } | ||||
|  | ||||
|         auto numberOfCharacters() const noexcept -> size_type; | ||||
|         auto c_str() const -> char const*; | ||||
|  | ||||
|     public: // substrings and searches | ||||
|   | ||||
| @@ -321,8 +321,7 @@ public: | ||||
|  | ||||
|     friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { | ||||
|         auto colStr = tp.m_oss.str(); | ||||
|         // This takes account of utf8 encodings | ||||
|         auto strSize = Catch::StringRef(colStr).numberOfCharacters(); | ||||
|         const auto strSize = colStr.size(); | ||||
|         tp.m_oss.str(""); | ||||
|         tp.open(); | ||||
|         if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský