summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/IDN/UTF8Validator.h
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/IDN/UTF8Validator.h')
-rw-r--r--Swiften/IDN/UTF8Validator.h98
1 files changed, 49 insertions, 49 deletions
diff --git a/Swiften/IDN/UTF8Validator.h b/Swiften/IDN/UTF8Validator.h
index 5df8769..d912ef9 100644
--- a/Swiften/IDN/UTF8Validator.h
+++ b/Swiften/IDN/UTF8Validator.h
@@ -13,55 +13,55 @@ namespace Swift {
// UTF-8 validation based on the description in https://tools.ietf.org/html/rfc3629#section-3 .
template <typename CharType>
bool UTF8IsValid(const CharType* data, size_t length) {
- bool isValid = true;
- const CharType* current = data;
- const CharType* end = data + length;
- while (isValid && (current < end)) {
- // one byte sequences
- if ((*current & 0x80) == 0x0) {
- current++;
- continue;
- }
- // longer byte sequences
- else {
- // two byte sequences
- if ((*current & 0xE0) == 0xC0) {
- current++;
- if ( (current < end) && ((*current & 0xC0) == 0x80) ) {
- current++;
- continue;
- }
- }
- // three byte sequences
- else if ((*current & 0xF0) == 0xE0) {
- current++;
- if ( ((current + 1) < end) && ((*current & 0xC0) == 0x80) ) {
- current++;
- if ((*current & 0xC0) == 0x80) {
- current++;
- continue;
- }
- }
- }
- // four byte sequences
- else if ((*current & 0xF8) == 0xF0) {
- current++;
- if ( ((current + 2) < end) && ((*current & 0xC0) == 0x80) ) {
- current++;
- if ((*current & 0xC0) == 0x80) {
- current++;
- if ((*current & 0xC0) == 0x80) {
- current++;
- continue;
- }
- }
- }
- }
- // invalid sequences
- isValid = false;
- }
- }
- return isValid;
+ bool isValid = true;
+ const CharType* current = data;
+ const CharType* end = data + length;
+ while (isValid && (current < end)) {
+ // one byte sequences
+ if ((*current & 0x80) == 0x0) {
+ current++;
+ continue;
+ }
+ // longer byte sequences
+ else {
+ // two byte sequences
+ if ((*current & 0xE0) == 0xC0) {
+ current++;
+ if ( (current < end) && ((*current & 0xC0) == 0x80) ) {
+ current++;
+ continue;
+ }
+ }
+ // three byte sequences
+ else if ((*current & 0xF0) == 0xE0) {
+ current++;
+ if ( ((current + 1) < end) && ((*current & 0xC0) == 0x80) ) {
+ current++;
+ if ((*current & 0xC0) == 0x80) {
+ current++;
+ continue;
+ }
+ }
+ }
+ // four byte sequences
+ else if ((*current & 0xF8) == 0xF0) {
+ current++;
+ if ( ((current + 2) < end) && ((*current & 0xC0) == 0x80) ) {
+ current++;
+ if ((*current & 0xC0) == 0x80) {
+ current++;
+ if ((*current & 0xC0) == 0x80) {
+ current++;
+ continue;
+ }
+ }
+ }
+ }
+ // invalid sequences
+ isValid = false;
+ }
+ }
+ return isValid;
}
}