aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-25 07:09:29 +0000
committerDavid Robillard <d@drobilla.net>2011-12-25 07:09:29 +0000
commitf3c95977f6c71b936e98f41c321265835c4fd623 (patch)
treeab275f04a3dd592c5572687230ba25f422359a36 /src/writer.c
parentb2effabfc5d02bab56bae00e7aa138a42bd7d3b6 (diff)
downloadserd-f3c95977f6c71b936e98f41c321265835c4fd623.tar.gz
serd-f3c95977f6c71b936e98f41c321265835c4fd623.tar.bz2
serd-f3c95977f6c71b936e98f41c321265835c4fd623.zip
Near 100% branch coverage.
git-svn-id: http://svn.drobilla.net/serd/trunk@277 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/writer.c b/src/writer.c
index c388188e..a9209f80 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -176,12 +176,10 @@ write_text(SerdWriter* writer, TextContext ctx,
continue;
}
-#define READ_BYTE() do { \
- assert(i < n_bytes); \
- in = utf8[i++] & 0x3f; \
- c <<= 6; \
- c |= in; \
- } while (0)
+#define READ_BYTE() \
+ in = utf8[i++] & 0x3f; \
+ c <<= 6; \
+ c |= in;
switch (size) {
case 4: READ_BYTE();
@@ -338,14 +336,13 @@ write_node(SerdWriter* writer,
} else if ((writer->style & SERD_STYLE_RESOLVED)
&& !serd_uri_string_has_scheme(node->buf)) {
SerdURI uri;
- if (!serd_uri_parse(node->buf, &uri)) {
- SerdURI abs_uri;
- serd_uri_resolve(&uri, &writer->base_uri, &abs_uri);
- sink("<", 1, writer);
- serd_uri_serialise(&abs_uri, (SerdSink)sink, writer);
- sink(">", 1, writer);
- return true;
- }
+ serd_uri_parse(node->buf, &uri);
+ SerdURI abs_uri;
+ serd_uri_resolve(&uri, &writer->base_uri, &abs_uri);
+ sink("<", 1, writer);
+ serd_uri_serialise(&abs_uri, (SerdSink)sink, writer);
+ sink(">", 1, writer);
+ return true;
}
sink("<", 1, writer);
write_text(writer, WRITE_URI, node->buf, node->n_bytes, '>');
@@ -396,7 +393,7 @@ serd_writer_write_statement(SerdWriter* writer,
}
sink(" .\n", 3, writer);
return SERD_SUCCESS;
- case SERD_TURTLE:
+ default:
break;
}
if (serd_node_equals(subject, &writer->context.subject)) {
@@ -428,9 +425,8 @@ serd_writer_write_statement(SerdWriter* writer,
}
} else {
if (writer->context.subject.type) {
- if (writer->indent > 0) {
- --writer->indent;
- }
+ assert(writer->indent > 0);
+ --writer->indent;
if (serd_stack_is_empty(&writer->anon_stack)) {
serd_writer_write_delim(writer, '.');
serd_writer_write_delim(writer, '\n');
@@ -460,8 +456,7 @@ serd_writer_write_statement(SerdWriter* writer,
FIELD_OBJECT, flags);
}
- if (writer->syntax != SERD_NTRIPLES
- && ((flags & SERD_ANON_S_BEGIN) || (flags & SERD_ANON_O_BEGIN))) {
+ if ((flags & SERD_ANON_S_BEGIN) || (flags & SERD_ANON_O_BEGIN)) {
WriteContext* ctx = (WriteContext*)serd_stack_push(
&writer->anon_stack, sizeof(WriteContext));
*ctx = writer->context;