Use wide character function for categorizing codepoints

Previously we used the is... rather than isw...
These functions were not supporting non ascii characters correctly
This commit is contained in:
Maxime Coste 2014-01-05 15:14:58 +00:00
parent 1e6fbf548b
commit aadbd390c7
3 changed files with 5 additions and 4 deletions

View File

@ -404,7 +404,7 @@ void expand_unprintable(const Context& context, DisplayBuffer& display_buffer)
end = buffer.iterator_at(atom_it->end()); it != end; ++it) end = buffer.iterator_at(atom_it->end()); it != end; ++it)
{ {
Codepoint cp = *it; Codepoint cp = *it;
if (cp != '\n' and iscntrl((int)cp)) if (cp != '\n' and not iswprint(cp))
{ {
std::ostringstream oss; std::ostringstream oss;
oss << "U+" << std::hex << cp; oss << "U+" << std::hex << cp;

View File

@ -375,7 +375,7 @@ void view_commands(Context& context, int param)
void replace_with_char(Context& context, int) void replace_with_char(Context& context, int)
{ {
on_next_key_with_autoinfo(context, [](Key key, Context& context) { on_next_key_with_autoinfo(context, [](Key key, Context& context) {
if (not isprint(key.key)) if (not iswprint(key.key))
return; return;
ScopedEdition edition(context); ScopedEdition edition(context);
Buffer& buffer = context.buffer(); Buffer& buffer = context.buffer();

View File

@ -3,6 +3,7 @@
#include <cstdint> #include <cstdint>
#include <ctype.h> #include <ctype.h>
#include <wctype.h>
namespace Kakoune namespace Kakoune
{ {
@ -29,13 +30,13 @@ enum WordType { Word, WORD };
template<WordType word_type = Word> template<WordType word_type = Word>
inline bool is_word(Codepoint c) inline bool is_word(Codepoint c)
{ {
return c == '_' or isalnum(c); return c == '_' or iswalnum(c);
} }
template<> template<>
inline bool is_word<WORD>(Codepoint c) inline bool is_word<WORD>(Codepoint c)
{ {
return !is_blank(c) and !is_eol(c); return not is_blank(c) and not is_eol(c);
} }
inline bool is_punctuation(Codepoint c) inline bool is_punctuation(Codepoint c)