aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-03-03 04:53:59 +0000
committerDavid Robillard <d@drobilla.net>2013-03-03 04:53:59 +0000
commit1d32c6e37bb4409719d6170c4b0e45cd3557df9a (patch)
tree19e607e681f18715d5c6b9c55dab48ee4e4aecf8 /src
parent2f993d40296ef007fa313756a721e48890f3df89 (diff)
downloadserd-1d32c6e37bb4409719d6170c4b0e45cd3557df9a.tar.gz
serd-1d32c6e37bb4409719d6170c4b0e45cd3557df9a.tar.bz2
serd-1d32c6e37bb4409719d6170c4b0e45cd3557df9a.zip
Don't write xsd:decimal literals to Turtle bare if they would not be read back
with the same type. Run thru tests on manifest-based test suites. git-svn-id: http://svn.drobilla.net/serd/trunk@428 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r--src/writer.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/writer.c b/src/writer.c
index 3c94d087..380a561d 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -442,10 +442,18 @@ write_node(SerdWriter* writer,
const char* type_uri = (const char*)datatype->buf;
if (!strncmp(type_uri, NS_XSD, sizeof(NS_XSD) - 1) && (
!strcmp(type_uri + sizeof(NS_XSD) - 1, "boolean") ||
- !strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") ||
!strcmp(type_uri + sizeof(NS_XSD) - 1, "integer"))) {
sink(node->buf, node->n_bytes, writer);
break;
+ } else if (!strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") &&
+ strchr((const char*)node->buf, '.') &&
+ node->buf[node->n_bytes - 1] != '.') {
+ /* xsd:decimal literals without trailing digits, e.g. "5.", can
+ not be written bare in Turtle. We could add a 0 which is
+ prettier, but changes the text and breaks round tripping.
+ */
+ sink(node->buf, node->n_bytes, writer);
+ break;
}
}
if (writer->syntax != SERD_NTRIPLES