aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-13 00:34:55 +0200
committerDavid Robillard <d@drobilla.net>2018-11-25 22:12:47 +0100
commit3036b6c80ecf048f94cfde21b370e085a98f19ed (patch)
treef158d12e6b93985d9f6d0908148dff6203017d3c
parent29d83d5902596ca269196894b154e486465f6ced (diff)
downloadserd-3036b6c80ecf048f94cfde21b370e085a98f19ed.tar.gz
serd-3036b6c80ecf048f94cfde21b370e085a98f19ed.tar.bz2
serd-3036b6c80ecf048f94cfde21b370e085a98f19ed.zip
Fix UTF-8 round tripping
-rw-r--r--src/byte_source.c4
-rw-r--r--src/byte_source.h6
-rw-r--r--src/reader.h2
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;
}