Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Liao committed Apr 12, 2024
1 parent c9244e7 commit 122a291
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 31 deletions.
1 change: 0 additions & 1 deletion 3rdparty/utf8/checked.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,3 @@ namespace utf8
#endif // C++ 11 or later

#endif //header guard

28 changes: 13 additions & 15 deletions 3rdparty/utf8/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ namespace internal
inline bool is_overlong_sequence(utfchar32_t cp, int length)
{
if (cp < 0x80) {
if (length != 1)
if (length != 1)
return true;
}
else if (cp < 0x800) {
if (length != 2)
if (length != 2)
return true;
}
else if (cp < 0x10000) {
if (length != 3)
if (length != 3)
return true;
}
return false;
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace internal
template <typename octet_iterator>
utf_error get_sequence_2(octet_iterator& it, octet_iterator end, utfchar32_t& code_point)
{
if (it == end)
if (it == end)
return NOT_ENOUGH_ROOM;

code_point = utf8::internal::mask8(*it);
Expand All @@ -206,7 +206,7 @@ namespace internal
{
if (it == end)
return NOT_ENOUGH_ROOM;

code_point = utf8::internal::mask8(*it);

UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace internal
else
err = OVERLONG_SEQUENCE;
}
else
else
err = INVALID_CODE_POINT;
}

Expand Down Expand Up @@ -329,11 +329,11 @@ namespace internal
if (is_trail_surrogate(second_word)) {
code_point = (first_word << 10) + second_word + SURROGATE_OFFSET;
return UTF8_OK;
} else
err = INCOMPLETE_SEQUENCE;
} else
err = INCOMPLETE_SEQUENCE;

} else {
err = INVALID_LEAD;
err = INVALID_LEAD;
}
}
// error branch
Expand Down Expand Up @@ -365,7 +365,7 @@ namespace internal
}
return result;
}

// One of the following overloads will be invoked from the API calls

// A simple (but dangerous) case: the caller appends byte(s) to a char array
Expand Down Expand Up @@ -444,7 +444,7 @@ namespace internal
inline const char* find_invalid(const char* str)
{
const char* end = str + std::strlen(str);
return find_invalid(str, end);
return find_invalid(str, end);
}

inline std::size_t find_invalid(const std::string& s)
Expand Down Expand Up @@ -484,9 +484,7 @@ namespace internal
inline bool starts_with_bom(const std::string& s)
{
return starts_with_bom(s.begin(), s.end());
}
}
} // namespace utf8

#endif // header guard


1 change: 0 additions & 1 deletion 3rdparty/utf8/cpp11.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@ namespace utf8
} // namespace utf8

#endif // header guard

3 changes: 1 addition & 2 deletions 3rdparty/utf8/cpp17.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ namespace utf8
{
return starts_with_bom(s.begin(), s.end());
}

} // namespace utf8

#endif // header guard

3 changes: 1 addition & 2 deletions 3rdparty/utf8/cpp20.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ namespace utf8
{
return starts_with_bom(s.begin(), s.end());
}

} // namespace utf8

#endif // header guard

19 changes: 9 additions & 10 deletions 3rdparty/utf8/unchecked.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ namespace utf8
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:
++it;
++it;
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
++it;
cp += (*it) & 0x3f;
break;
case 4:
++it;
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
++it;
cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
++it;
cp += (*it) & 0x3f;
cp += (*it) & 0x3f;
break;
}
++it;
Expand Down Expand Up @@ -173,7 +173,7 @@ namespace utf8
distance(octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
for (dist = 0; first < last; ++dist)
utf8::unchecked::next(first);
return dist;
}
Expand Down Expand Up @@ -247,15 +247,15 @@ namespace utf8
octet_iterator temp = it;
return utf8::unchecked::next(temp);
}
bool operator == (const iterator& rhs) const
{
bool operator == (const iterator& rhs) const
{
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
iterator& operator ++ ()
{
::std::advance(it, utf8::internal::sequence_length(it));
return *this;
Expand All @@ -265,7 +265,7 @@ namespace utf8
iterator temp = *this;
::std::advance(it, utf8::internal::sequence_length(it));
return temp;
}
}
iterator& operator -- ()
{
utf8::unchecked::prior(it);
Expand All @@ -280,8 +280,7 @@ namespace utf8
}; // class iterator

} // namespace utf8::unchecked
} // namespace utf8
} // namespace utf8


#endif // header guard

0 comments on commit 122a291

Please sign in to comment.