another attempt to port the robust parser to MacOS

This commit is contained in:
kr.angelov
2012-05-16 15:18:44 +00:00
parent eb380dfb80
commit bd8046f23d
15 changed files with 21 additions and 32 deletions

View File

@@ -171,7 +171,7 @@ gu_malloc_init(GuPool* pool, size_t size, const void* init)
#ifdef GU_HAVE_STATEMENT_EXPRESSIONS
#ifdef HAVE_STATEMENT_EXPRESSIONS
#define gu_new_i(pool, type, ...) \
({ \
type *gu_new_p_ = gu_new(type, pool); \
@@ -179,12 +179,12 @@ gu_malloc_init(GuPool* pool, size_t size, const void* init)
sizeof(type)); \
gu_new_p_; \
})
#else // GU_HAVE_STATEMENT_EXPRESSIONS
#else // HAVE_STATEMENT_EXPRESSIONS
#define gu_new_i(pool, type, ...) \
((type*)gu_malloc_init_aligned((pool), sizeof(type), \
gu_alignof(type), \
&(type){ __VA_ARGS__ }))
#endif // GU_HAVE_STATEMENT_EXPRESSIONS
#endif // HAVE_STATEMENT_EXPRESSIONS
/** @def gu_new_i(pool, type, ...)
*

View File

@@ -304,6 +304,7 @@ gu_buf_out(GuBuf* buf, GuPool* pool)
bout->stream.output = gu_buf_out_output;
bout->stream.begin_buf = gu_buf_outbuf_begin;
bout->stream.end_buf = gu_buf_outbuf_end;
bout->stream.flush = NULL;
bout->buf = buf;
return gu_new_out(&bout->stream, pool);
}

View File

@@ -195,7 +195,7 @@ gu_format_string(GuPool* pool, const char* fmt, ...)
GuString
gu_str_string(const char* str, GuPool* pool)
{
#ifdef GU_CHAR_ASCII
#ifdef CHAR_ASCII
return gu_utf8_string((const uint8_t*) str, strlen(str), pool);
#else
GuPool* tmp_pool = gu_local_pool();

View File

@@ -1,7 +1,7 @@
#ifndef GU_SYSDEPS_H_
#define GU_SYSDEPS_H_
#include <guconfig.h>
#include <config.h>
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# define GU_GNUC
@@ -9,7 +9,6 @@
#ifdef GU_GNUC
# define GU_ALIGNOF __alignof
# define GU_HAVE_STATEMENT_EXPRESSIONS
# define GU_GNUC_ATTR(x) __attribute__(( x ))
# if defined(__OPTIMIZE_SIZE__)
# define GU_OPTIMIZE_SIZE

View File

@@ -1,11 +1,11 @@
#include <gu/ucs.h>
#include <gu/assert.h>
#include <guconfig.h>
#include <config.h>
GU_DEFINE_TYPE(GuUCSExn, abstract, _);
#ifdef GU_CHAR_ASCII
#ifdef CHAR_ASCII
bool
gu_char_is_valid(char c)
@@ -36,7 +36,7 @@ gu_ucs_char(GuUCS uc, GuExn* err)
return 0;
}
#else // defined(GU_CHAR_ASCII)
#else // defined(CHAR_ASCII)
static const char gu_ucs_ascii[128] =
"\0\0\0\0\0\0\0\a\b\t\n\v\f\r\0\0"

View File

@@ -29,7 +29,7 @@ inline GuUCS
gu_char_ucs(char c)
{
gu_require(gu_char_is_valid(c));
#ifdef GU_CHAR_ASCII
#ifdef CHAR_ASCII
GuUCS u = (GuUCS) c;
#else
extern const uint8_t gu_ucs_ascii_reverse_[CHAR_MAX];

View File

@@ -1,6 +1,6 @@
#include <gu/assert.h>
#include <gu/utf8.h>
#include <guconfig.h>
#include <config.h>
GuUCS
gu_utf8_decode(const uint8_t** src_inout)
@@ -180,7 +180,7 @@ gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err)
}
#ifndef GU_CHAR_ASCII
#ifndef CHAR_ASCII
void gu_str_out_utf8_(const char* str, GuOut* out, GuExn* err)
{

View File

@@ -21,7 +21,7 @@ gu_in_utf8(GuIn* in, GuExn* err)
inline char
gu_in_utf8_char(GuIn* in, GuExn* err)
{
#ifdef GU_CHAR_ASCII
#ifdef CHAR_ASCII
int i = gu_in_peek_u8(in);
if (i >= 0 && i < 0x80) {
gu_in_consume(in, 1);
@@ -55,7 +55,7 @@ gu_utf8_decode(const uint8_t** utf8);
inline void
gu_str_out_utf8(const char* str, GuOut* out, GuExn* err)
{
#ifdef GU_CHAR_ASCII
#ifdef CHAR_ASCII
gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
#else
extern void