Switch away from 'bool' type (ABI change)
This type doesn't bring anything over an int and requires some special handling (e.g. including the right headers). Just drop it and use int, C programmers will understand!
This commit is contained in:
parent
1f62468379
commit
dc60dcb2e6
|
@ -8,9 +8,8 @@
|
|||
#ifndef HEADER_LIBUTF8
|
||||
#define HEADER_LIBUTF8
|
||||
|
||||
// standard includes, or includes needed for type declarations
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
/* standard includes, or includes needed for type declarations */
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/* libutf8/src/libutf8/010_forward.h
|
||||
*
|
||||
* (c)2006-2009, Laurence Withers, <l@lwithers.me.uk>.
|
||||
* 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
|
||||
*/
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue