From e3b0d874872c77876988385b72f652e367ce669a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 21 Jan 2011 19:12:20 +0000 Subject: 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 --- src/writer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/writer.c') 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 - * + * * 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); } } -- cgit v1.2.1