summaryrefslogtreecommitdiff
path: root/vendor/utfcpp/utf8/checked.h
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-04-25 00:50:19 +0100
committerPeter Powell <petpow@saberuk.com>2019-04-25 19:24:35 +0100
commitc13d0744fee3b1411d238d45ad66eef8b104f72e (patch)
tree04b7e41578a3c1d5d7d36eda6628409b218dca3b /vendor/utfcpp/utf8/checked.h
parentf2712eaf0c191575a55576217a88e4a7af3b8865 (diff)
Update vendored utfcpp library to commit ad27c7d5e0.
Diffstat (limited to 'vendor/utfcpp/utf8/checked.h')
-rw-r--r--vendor/utfcpp/utf8/checked.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/vendor/utfcpp/utf8/checked.h b/vendor/utfcpp/utf8/checked.h
index 2aef5838d..c31861e0a 100644
--- a/vendor/utfcpp/utf8/checked.h
+++ b/vendor/utfcpp/utf8/checked.h
@@ -107,7 +107,9 @@ namespace utf8
*out++ = *it;
break;
case internal::NOT_ENOUGH_ROOM:
- throw not_enough_room();
+ out = utf8::append (replacement, out);
+ start = end;
+ break;
case internal::INVALID_LEAD:
out = utf8::append (replacement, out);
++start;
@@ -174,23 +176,19 @@ namespace utf8
return utf8::peek_next(it, end);
}
- /// Deprecated in versions that include "prior"
- template <typename octet_iterator>
- uint32_t previous(octet_iterator& it, octet_iterator pass_start)
- {
- octet_iterator end = it;
- while (utf8::internal::is_trail(*(--it)))
- if (it == pass_start)
- throw invalid_utf8(*it); // error - no lead byte in the sequence
- octet_iterator temp = it;
- return utf8::next(temp, end);
- }
-
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n, octet_iterator end)
{
- for (distance_type i = 0; i < n; ++i)
- utf8::next(it, end);
+ const distance_type zero(0);
+ if (n < zero) {
+ // backward
+ for (distance_type i = n; i < zero; ++i)
+ utf8::prior(it, end);
+ } else {
+ // forward
+ for (distance_type i = zero; i < n; ++i)
+ utf8::next(it, end);
+ }
}
template <typename octet_iterator>
@@ -324,4 +322,3 @@ namespace utf8
#endif //header guard
-