Fix for [3167987]: prior moves it before start
git-svn-id: http://svn.code.sf.net/p/utfcpp/code@116 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
parent
7fcdf850d9
commit
045624abd7
2 changed files with 22 additions and 18 deletions
|
@ -162,12 +162,16 @@ namespace utf8
|
||||||
template <typename octet_iterator>
|
template <typename octet_iterator>
|
||||||
uint32_t prior(octet_iterator& it, octet_iterator start)
|
uint32_t prior(octet_iterator& it, octet_iterator start)
|
||||||
{
|
{
|
||||||
|
// can't do much if it == start
|
||||||
|
if (it == start)
|
||||||
|
throw not_enough_room();
|
||||||
|
|
||||||
octet_iterator end = it;
|
octet_iterator end = it;
|
||||||
|
// Go back until we hit either a lead octet or start
|
||||||
while (internal::is_trail(*(--it)))
|
while (internal::is_trail(*(--it)))
|
||||||
if (it < start)
|
if (it == start)
|
||||||
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
||||||
octet_iterator temp = it;
|
return peek_next(it, end);
|
||||||
return next(temp, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated in versions that include "prior"
|
/// Deprecated in versions that include "prior"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue