Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_stringref.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2018-02-05 10:04:18 +0100
committerMartin Hořeňovský2018-02-05 10:04:59 +0100
commitba6d33fb8c74cf1a453368c07f59145a0b0d429c (patch)
tree6524bfa26d0695517956439d27e820d0dfb21e82 /include/internal/catch_stringref.cpp
parent4be81d3588a6d00a89302bb181c6b0de33f13065 (diff)
downloadcatch3-ba6d33fb8c74cf1a453368c07f59145a0b0d429c.tar.gz
Enable -Wpedantic, fix unconditional use of C++14 extension
Diffstat (limited to 'include/internal/catch_stringref.cpp')
-rw-r--r--include/internal/catch_stringref.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp
index bac8b1d8..b0b2f8e1 100644
--- a/include/internal/catch_stringref.cpp
+++ b/include/internal/catch_stringref.cpp
@@ -15,6 +15,13 @@
#include <ostream>
#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
@@ -79,13 +86,12 @@ namespace Catch {
// Make adjustments for uft encodings
for( size_type i=0; i < m_size; ++i ) {
char c = m_start[i];
- if( ( c & 0b11000000 ) == 0b11000000 ) {
- if( ( c & 0b11100000 ) == 0b11000000 )
+ 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--;
- else if( ( c & 0b11110000 ) == 0b11100000 )
- noChars-=2;
- else if( ( c & 0b11111000 ) == 0b11110000 )
- noChars-=3;
}
}
return noChars;