diff options
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/writer.c b/src/writer.c index 47e5701b..a9a2b5dd 100644 --- a/src/writer.c +++ b/src/writer.c @@ -93,7 +93,7 @@ struct SerdWriterImpl { SerdNode list_subj; unsigned list_depth; unsigned indent; - uint8_t* bprefix; + char* bprefix; size_t bprefix_len; Sep last_sep; bool empty; @@ -146,7 +146,7 @@ static void copy_node(SerdNode* dst, const SerdNode* src) { if (src) { - dst->buf = (uint8_t*)realloc((char*)dst->buf, src->n_bytes + 1); + dst->buf = (char*)realloc((char*)dst->buf, src->n_bytes + 1); dst->n_bytes = src->n_bytes; dst->flags = src->flags; dst->type = src->type; @@ -207,7 +207,7 @@ uri_must_escape(const uint8_t c) } static size_t -write_uri(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) +write_uri(SerdWriter* writer, const char* utf8, size_t n_bytes) { size_t len = 0; for (size_t i = 0; i < n_bytes;) { @@ -226,7 +226,7 @@ write_uri(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) // Write UTF-8 character size_t size = 0; - len += write_character(writer, utf8 + i, &size); + len += write_character(writer, (const uint8_t*)utf8 + i, &size); i += size; if (size == 0) { // Corrupt input, scan to start of next character @@ -237,7 +237,7 @@ write_uri(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) } static bool -lname_must_escape(const uint8_t c) +lname_must_escape(const char c) { /* This arbitrary list of characters, most of which have nothing to do with Turtle, must be handled as special cases here because the RDF and SPARQL @@ -258,7 +258,7 @@ lname_must_escape(const uint8_t c) } static size_t -write_lname(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) +write_lname(SerdWriter* writer, const char* utf8, size_t n_bytes) { size_t len = 0; for (size_t i = 0; i < n_bytes; ++i) { @@ -284,7 +284,7 @@ write_lname(SerdWriter* writer, const uint8_t* utf8, size_t n_bytes) static size_t write_text(SerdWriter* writer, TextContext ctx, - const uint8_t* utf8, size_t n_bytes) + const char* utf8, size_t n_bytes) { size_t len = 0; for (size_t i = 0; i < n_bytes;) { @@ -338,7 +338,8 @@ write_text(SerdWriter* writer, TextContext ctx, // Write UTF-8 character size_t size = 0; - len += write_character(writer, utf8 + i - 1, &size); + len += write_character(writer, (const uint8_t*)utf8 + i - 1, &size); + if (size == 0) { // Corrupt input, scan to start of next character for (; i < n_bytes && (utf8[i] & 0x80); ++i) {} @@ -352,7 +353,7 @@ write_text(SerdWriter* writer, TextContext ctx, static size_t uri_sink(const void* buf, size_t len, void* stream) { - return write_uri((SerdWriter*)stream, (const uint8_t*)buf, len); + return write_uri((SerdWriter*)stream, (const char*)buf, len); } static void @@ -463,7 +464,7 @@ write_literal(SerdWriter* writer, // Return true iff `buf` is a valid prefixed name suffix static inline bool -is_name(const uint8_t* buf, const size_t len) +is_name(const char* buf, const size_t len) { // TODO: This is more strict than it should be. for (size_t i = 0; i < len; ++i) { @@ -596,9 +597,8 @@ write_blank(SerdWriter* const writer, } sink("_:", 2, writer); - if (writer->bprefix && !strncmp((const char*)node->buf, - (const char*)writer->bprefix, - writer->bprefix_len)) { + if (writer->bprefix && + !strncmp(node->buf, writer->bprefix, writer->bprefix_len)) { sink(node->buf + writer->bprefix_len, node->n_bytes - writer->bprefix_len, writer); @@ -879,15 +879,15 @@ serd_writer_set_error_sink(SerdWriter* writer, } void -serd_writer_chop_blank_prefix(SerdWriter* writer, - const uint8_t* prefix) +serd_writer_chop_blank_prefix(SerdWriter* writer, + const char* prefix) { free(writer->bprefix); writer->bprefix_len = 0; writer->bprefix = NULL; if (prefix) { - writer->bprefix_len = strlen((const char*)prefix); - writer->bprefix = (uint8_t*)malloc(writer->bprefix_len + 1); + writer->bprefix_len = strlen(prefix); + writer->bprefix = (char*)malloc(writer->bprefix_len + 1); memcpy(writer->bprefix, prefix, writer->bprefix_len + 1); } } @@ -985,9 +985,9 @@ serd_buffer_sink(const void* buf, size_t len, void* stream) return len; } -uint8_t* +char* serd_buffer_sink_finish(SerdBuffer* stream) { serd_buffer_sink("", 1, stream); - return (uint8_t*)stream->buf; + return (char*)stream->buf; } |