aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-12-31 11:48:42 -0500
committerDavid Robillard <d@drobilla.net>2019-12-20 10:26:55 -0500
commit6644fef8c9f1fe9ccfbc049fe9f4a5e26448d7fd (patch)
tree4a1a1ee5fc25ba2e0da4d7ad9918e63836308475 /src/writer.c
parent8ab439b7bc50533da52a8be232950b615d75c532 (diff)
downloadserd-6644fef8c9f1fe9ccfbc049fe9f4a5e26448d7fd.tar.gz
serd-6644fef8c9f1fe9ccfbc049fe9f4a5e26448d7fd.tar.bz2
serd-6644fef8c9f1fe9ccfbc049fe9f4a5e26448d7fd.zip
Fix various warnings and conversion issues
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/writer.c b/src/writer.c
index 19588c69..f187aefc 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -113,7 +113,7 @@ struct SerdWriterImpl {
SerdLogFunc log_func;
void* log_handle;
WriteContext context;
- unsigned indent;
+ int indent;
char* bprefix;
size_t bprefix_len;
Sep last_sep;
@@ -142,12 +142,13 @@ supports_abbrev(const SerdWriter* writer)
return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG;
}
-static inline WriteContext*
-anon_stack_top(SerdWriter* writer)
+static inline const WriteContext*
+anon_stack_top(const SerdWriter* writer)
{
assert(!serd_stack_is_empty(&writer->anon_stack));
- return (WriteContext*)(writer->anon_stack.buf
- + writer->anon_stack.size - sizeof(WriteContext));
+ const char* const end = writer->anon_stack.buf + writer->anon_stack.size;
+ const void* const top = end - sizeof(WriteContext);
+ return (const WriteContext*)top;
}
static inline SerdNode*
@@ -319,7 +320,7 @@ write_text(SerdWriter* writer, TextContext ctx,
break; // Reached end
}
- const uint8_t in = utf8[i++];
+ const char in = utf8[i++];
if (ctx == WRITE_LONG_STRING) {
switch (in) {
case '\\': len += sink("\\\\", 2, writer); continue;
@@ -379,7 +380,7 @@ static void
write_newline(SerdWriter* writer)
{
sink("\n", 1, writer);
- for (unsigned i = 0; i < writer->indent; ++i) {
+ for (int i = 0; i < writer->indent; ++i) {
sink("\t", 1, writer);
}
}
@@ -391,7 +392,7 @@ write_sep(SerdWriter* writer, const Sep sep)
// Adjust indent, but tolerate if it would become negative
writer->indent =
- ((rule->indent >= 0 || writer->indent >= (unsigned)-rule->indent)
+ ((rule->indent >= 0 || writer->indent >= -rule->indent)
? writer->indent + rule->indent
: 0);