mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-29 01:24:52 +03:00
utf8: replace InvalidBytePolicy::Throw with InvalidBytePolicy::Assert
This commit is contained in:
parent
c1387dc592
commit
df400f90ab
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include "unicode.hh"
|
#include "unicode.hh"
|
||||||
|
#include "assert.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
@ -79,14 +80,12 @@ bool is_character_start(Iterator it)
|
|||||||
return (*it & 0xC0) != 0x80;
|
return (*it & 0xC0) != 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct invalid_utf8_sequence{};
|
|
||||||
|
|
||||||
namespace InvalidBytePolicy
|
namespace InvalidBytePolicy
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Throw
|
struct Assert
|
||||||
{
|
{
|
||||||
Codepoint operator()(char byte) const { throw invalid_utf8_sequence{}; }
|
Codepoint operator()(char byte) const { assert(false); return byte; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pass
|
struct Pass
|
||||||
@ -98,7 +97,7 @@ struct Pass
|
|||||||
|
|
||||||
// returns the codepoint of the character whose first byte
|
// returns the codepoint of the character whose first byte
|
||||||
// is pointed by it
|
// is pointed by it
|
||||||
template<typename InvalidPolicy = InvalidBytePolicy::Throw,
|
template<typename InvalidPolicy = InvalidBytePolicy::Assert,
|
||||||
typename Iterator>
|
typename Iterator>
|
||||||
Codepoint codepoint(Iterator it)
|
Codepoint codepoint(Iterator it)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace utf8
|
|||||||
// adapter for an iterator on bytes which permits to iterate
|
// adapter for an iterator on bytes which permits to iterate
|
||||||
// on unicode codepoints instead.
|
// on unicode codepoints instead.
|
||||||
template<typename Iterator,
|
template<typename Iterator,
|
||||||
typename InvalidPolicy = InvalidBytePolicy::Throw>
|
typename InvalidPolicy = InvalidBytePolicy::Assert>
|
||||||
class utf8_iterator
|
class utf8_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user