diff options
author | David Robillard <d@drobilla.net> | 2011-01-21 19:12:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-21 19:12:20 +0000 |
commit | e3b0d874872c77876988385b72f652e367ce669a (patch) | |
tree | 9ba4465bddc931a852aeee9f2eba21957192d2ea /src/writer.c | |
parent | ff9510dc36fb3d6c5a85e3f4d41220c59b26ee93 (diff) | |
download | serd-e3b0d874872c77876988385b72f652e367ce669a.tar.gz serd-e3b0d874872c77876988385b72f652e367ce669a.tar.bz2 serd-e3b0d874872c77876988385b72f652e367ce669a.zip |
Gracefully stop parsing on error (i.e. report exactly one error for each bad test).
git-svn-id: http://svn.drobilla.net/serd/trunk@23 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/writer.c b/src/writer.c index 684f79e2..eb6310a7 100644 --- a/src/writer.c +++ b/src/writer.c @@ -1,6 +1,6 @@ /* Serd, an RDF serialisation library. * Copyright 2011 David Robillard <d@drobilla.net> - * + * * Serd is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -59,7 +59,7 @@ typedef enum { WRITE_URI, WRITE_STRING } WriteContext; - + static bool write_text(SerdWriter writer, WriteContext ctx, const uint8_t* utf8, size_t n_bytes, uint8_t terminator) @@ -76,12 +76,12 @@ write_text(SerdWriter writer, WriteContext ctx, if (terminator == '"') { writer->sink("\\\"", 2, writer->stream); continue; - } // else fall-through + } // else fall-through default: break; } if (in == terminator) { - sprintf(escape, "\\u%04X", terminator); + snprintf(escape, 7, "\\u%04X", terminator); writer->sink(escape, 6, writer->stream); continue; } @@ -138,10 +138,10 @@ write_text(SerdWriter writer, WriteContext ctx, } if (c < 0xFFFF) { - sprintf(escape, "\\u%04X", c); + snprintf(escape, 7, "\\u%04X", c); writer->sink(escape, 6, writer->stream); } else { - sprintf(escape, "\\U%08X", c); + snprintf(escape, 11, "\\U%08X", c); writer->sink(escape, 10, writer->stream); } } @@ -379,11 +379,11 @@ serd_writer_set_prefix(SerdWriter writer, const SerdString* uri) { if (writer->syntax != SERD_NTRIPLES) { - writer->sink("@prefix ", 8, writer->stream); + writer->sink("@prefix ", 8, writer->stream); writer->sink(name->buf, name->n_bytes - 1, writer->stream); writer->sink(": <", 3, writer->stream); write_text(writer, WRITE_URI, uri->buf, uri->n_bytes - 1, '>'); - writer->sink("> .\n", 4, writer->stream); + writer->sink("> .\n", 4, writer->stream); } } |