From 3036b6c80ecf048f94cfde21b370e085a98f19ed Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 13 May 2018 00:34:55 +0200 Subject: Fix UTF-8 round tripping --- src/byte_source.c | 4 ++-- src/byte_source.h | 6 +++--- src/reader.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/byte_source.c b/src/byte_source.c index ae891a35..a3f50a14 100644 --- a/src/byte_source.c +++ b/src/byte_source.c @@ -61,7 +61,7 @@ serd_byte_source_open_source(SerdByteSource* source, source->from_stream = true; if (page_size > 1) { - source->file_buf = (char*)serd_allocate_buffer(page_size); + source->file_buf = (uint8_t*)serd_allocate_buffer(page_size); source->read_buf = source->file_buf; memset(source->file_buf, '\0', page_size); } else { @@ -92,7 +92,7 @@ serd_byte_source_open_string(SerdByteSource* source, const char* utf8) memset(source, '\0', sizeof(*source)); source->cur = cur; - source->read_buf = utf8; + source->read_buf = (const uint8_t*)utf8; return SERD_SUCCESS; } diff --git a/src/byte_source.h b/src/byte_source.h index b895aac1..e0c9e349 100644 --- a/src/byte_source.h +++ b/src/byte_source.h @@ -40,10 +40,10 @@ typedef struct { void* stream; ///< Stream (e.g. FILE) size_t page_size; ///< Number of bytes to read at a time Cursor cur; ///< Cursor for error reporting - char* file_buf; ///< Buffer iff reading pages from a file - const char* read_buf; ///< Pointer to file_buf or read_byte + uint8_t* file_buf; ///< Buffer iff reading pages from a file + const uint8_t* read_buf; ///< Pointer to file_buf or read_byte size_t read_head; ///< Offset into read_buf - char read_byte; ///< 1-byte 'buffer' used when not paging + uint8_t read_byte; ///< 1-byte 'buffer' used when not paging bool from_stream; ///< True iff reading from `stream` bool prepared; ///< True iff prepared for reading bool eof; ///< True iff end of file reached diff --git a/src/reader.h b/src/reader.h index 682e89a9..251b9238 100644 --- a/src/reader.h +++ b/src/reader.h @@ -141,7 +141,7 @@ static inline SerdStatus push_byte(SerdReader* reader, SerdNode* node, const uint8_t c) { SERD_STACK_ASSERT_TOP(reader, node); - char* const s = (char*)serd_stack_push(&reader->stack, 1); + uint8_t* const s = (uint8_t*)serd_stack_push(&reader->stack, 1); if (!s) { return SERD_ERR_OVERFLOW; } -- cgit v1.2.1