diff --git a/src/libutf8/000_TopHeader.h b/src/libutf8/000_TopHeader.h index f05ab62..3edca33 100644 --- a/src/libutf8/000_TopHeader.h +++ b/src/libutf8/000_TopHeader.h @@ -8,9 +8,8 @@ #ifndef HEADER_LIBUTF8 #define HEADER_LIBUTF8 -// standard includes, or includes needed for type declarations -#include -#include +/* standard includes, or includes needed for type declarations */ +#include #ifdef __cplusplus extern "C" { diff --git a/src/libutf8/010_forward.h b/src/libutf8/010_forward.h deleted file mode 100644 index a64a7fe..0000000 --- a/src/libutf8/010_forward.h +++ /dev/null @@ -1,20 +0,0 @@ -/* libutf8/src/libutf8/010_forward.h - * - * (c)2006-2009, Laurence Withers, . - * Released under the GNU GPLv3. See file COPYING or - * http://www.gnu.org/copyleft/gpl.html for details. -*/ - -// This file simply contains forward declarations of all libutf8 -// classes, to facilitate header ordering, etc. - -// encode_state.h -struct utf8_encode_state; - -// decode_state.h -struct utf8_decode_state; - -/* options for text editors -kate: replace-trailing-space-save true; space-indent true; tab-width 4; -vim: expandtab:ts=4:sw=4:syntax=c.doxygen -*/ diff --git a/src/libutf8/100_ctype.c b/src/libutf8/100_ctype.c index 24016d4..7b15428 100644 --- a/src/libutf8/100_ctype.c +++ b/src/libutf8/100_ctype.c @@ -5,7 +5,7 @@ * http://www.gnu.org/copyleft/gpl.html for details. */ -bool utf8_isascii(wchar_t ch) +int utf8_isascii(wchar_t ch) { return !(ch & ~0x7F); } @@ -28,7 +28,7 @@ bool utf8_isascii(wchar_t ch) 3000 ; White_Space # Zs IDEOGRAPHIC SPACE */ -bool utf8_isspace(wchar_t ch) +int utf8_isspace(wchar_t ch) { return((ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 @@ -46,7 +46,7 @@ bool utf8_isspace(wchar_t ch) -bool utf8_isvalid(wchar_t ch) +int utf8_isvalid(wchar_t ch) { return !(ch & (~((wchar_t)0x7FFFFFFF))) && (ch < 0xD800 || ch > 0xDFFF) && (ch != 0xFFFE) && (ch != 0xFFFF); } diff --git a/src/libutf8/100_ctype.h b/src/libutf8/100_ctype.h index 487f13a..f72d233 100644 --- a/src/libutf8/100_ctype.h +++ b/src/libutf8/100_ctype.h @@ -18,11 +18,11 @@ This module contains functions for character classification. These are basically -/// Returns \c true if \a ch can be represented in ASCII. -bool utf8_isascii(wchar_t ch); +/*! \biref Returns \c true if \a ch can be represented in ASCII. */ +int utf8_isascii(wchar_t ch); -/// Returns \c true if \a ch is whitespace. -bool utf8_isspace(wchar_t ch); +/*! \brief Returns \c true if \a ch is whitespace. */ +int utf8_isspace(wchar_t ch); /*! \brief Returns \c true if \a ch is a valid UCS-4 character. @@ -36,7 +36,7 @@ character. Valid characters lie in the range 0–0x7FFFFFFF but exclude: \li the invalid code points U+FFFE and U+FFFF */ -bool utf8_isvalid(wchar_t ch); +int utf8_isvalid(wchar_t ch); diff --git a/src/libutf8/400_decode_state.c b/src/libutf8/400_decode_state.c index 50a64ed..15d331a 100644 --- a/src/libutf8/400_decode_state.c +++ b/src/libutf8/400_decode_state.c @@ -42,7 +42,7 @@ loop: case utf8_state_none: if(!in && ctx->rd_remain < 0) { *wr = 0; - ctx->complete = true; + ctx->complete = 1; ++ctx->byte_offset; return ctx; } @@ -51,7 +51,7 @@ loop: ++ctx->written; --avail; ++ctx->char_offset; - ctx->complete = true; + ctx->complete = 1; if(in == 0x0A) { ++ctx->line; ctx->col = 0; @@ -61,7 +61,7 @@ loop: ctx->state = utf8_state_none; break; } - ctx->complete = false; + ctx->complete = 0; if((in & 0xE0) == 0xC0) { ctx->minch = 0x80; ctx->state = utf8_state_multibyte1; @@ -118,7 +118,7 @@ loop: ++ctx->written; --avail; ++ctx->char_offset; - ctx->complete = true; + ctx->complete = 1; if(ctx->statech == 0x0A || ctx->statech == 0x2028) { ++ctx->line; ctx->col = 0; diff --git a/src/libutf8/400_decode_state.h b/src/libutf8/400_decode_state.h index d69930c..edae42d 100644 --- a/src/libutf8/400_decode_state.h +++ b/src/libutf8/400_decode_state.h @@ -20,6 +20,11 @@ character, or simply skipping the illegal byte sequence. +/* opaque type */ +struct utf8_decode_state; + + + /*! \brief Types of decoder error. These are the types of error that can be encountered by the decoder. This allows slightly more @@ -114,7 +119,7 @@ these variables aren't perfect, as they can be affected by errors and limitation */ struct utf8_decode_state { /// \c false if we are part-way through a multi-byte character. - bool complete; + int complete; /// Data to read (current read position). const char* rd; diff --git a/src/libutf8/500_encode_state.c b/src/libutf8/500_encode_state.c index e9cda50..9dbc938 100644 --- a/src/libutf8/500_encode_state.c +++ b/src/libutf8/500_encode_state.c @@ -11,7 +11,7 @@ struct utf8_encode_state* utf8_encoder(struct utf8_encode_state* state) char* endp = wr + state->wr_size - 1; wchar_t ch; enum utf8_encode_error_action error_action; - bool reencoding; + int reencoding; if(!state || !state->rd || !state->wr || state->wr_size < 7) { errno = EINVAL; @@ -23,7 +23,7 @@ struct utf8_encode_state* utf8_encoder(struct utf8_encode_state* state) ch = *state->rd; if(!ch && state->rd_remain < 0) break; - reencoding = false; + reencoding = 0; reencode: ret = utf8_encode_char(wr, endp - wr, ch); if(!ret) { @@ -39,7 +39,7 @@ struct utf8_encode_state* utf8_encoder(struct utf8_encode_state* state) return 0; case utf8_encode_error_action_replace: - reencoding = true; + reencoding = 1; goto reencode; case utf8_encode_error_action_skip: diff --git a/src/libutf8/500_encode_state.h b/src/libutf8/500_encode_state.h index c47108f..7d2c85c 100644 --- a/src/libutf8/500_encode_state.h +++ b/src/libutf8/500_encode_state.h @@ -21,6 +21,11 @@ character. +/* opaque type */ +struct utf8_encode_state; + + + /*! \brief Action to be taken after error callback. These are the possible actions that can be undertaken after a stateful encoding operation has