aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/serd/writer.h2
-rw-r--r--src/serdi.c4
-rw-r--r--src/writer.c8
-rw-r--r--test/test_reader_writer.c11
-rw-r--r--test/test_writer.c8
5 files changed, 16 insertions, 17 deletions
diff --git a/include/serd/writer.h b/include/serd/writer.h
index 36880d2a..c5f50b0c 100644
--- a/include/serd/writer.h
+++ b/include/serd/writer.h
@@ -38,7 +38,7 @@ typedef enum {
SERD_WRITE_UNQUALIFIED = 1U << 1U, ///< Do not shorten URIs into CURIEs
SERD_WRITE_UNRESOLVED = 1U << 2U, ///< Do not make URIs relative
SERD_WRITE_BULK = 1U << 3U, ///< Write output in pages
- SERD_WRITE_STRICT = 1U << 4U, ///< Abort with error on lossy output
+ SERD_WRITE_LAX = 1U << 4U, ///< Tolerate lossy output
SERD_WRITE_TERSE = 1U << 5U, ///< Write terser output without newlines
} SerdWriterFlag;
diff --git a/src/serdi.c b/src/serdi.c
index 59c66cae..0610069d 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -100,7 +100,7 @@ main(int argc, char** argv)
SerdSyntax input_syntax = (SerdSyntax)0;
SerdSyntax output_syntax = (SerdSyntax)0;
- SerdWriterFlags writer_flags = SERD_WRITE_STRICT;
+ SerdWriterFlags writer_flags = 0;
bool from_string = false;
bool from_stdin = false;
bool bulk_read = true;
@@ -139,8 +139,8 @@ main(int argc, char** argv)
} else if (opt == 'h') {
return print_usage(prog, false);
} else if (opt == 'l') {
+ writer_flags |= SERD_WRITE_LAX;
lax = true;
- writer_flags &= ~(SerdWriterFlags)SERD_WRITE_STRICT;
} else if (opt == 'q') {
quiet = true;
} else if (opt == 't') {
diff --git a/src/writer.c b/src/writer.c
index 3079cebc..58fd0d53 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -364,7 +364,7 @@ write_uri(SerdWriter* writer, const char* utf8, size_t n_bytes, SerdStatus* st)
size_t size = 0;
len += write_character(writer, (const uint8_t*)utf8 + i, &size, st);
i += size;
- if (*st && (writer->flags & SERD_WRITE_STRICT)) {
+ if (*st && !(writer->flags & SERD_WRITE_LAX)) {
break;
}
@@ -387,7 +387,7 @@ ewrite_uri(SerdWriter* writer, const char* utf8, size_t n_bytes)
SerdStatus st = SERD_SUCCESS;
write_uri(writer, utf8, n_bytes, &st);
- return (st == SERD_BAD_WRITE || (writer->flags & SERD_WRITE_STRICT))
+ return (st == SERD_BAD_WRITE || !(writer->flags & SERD_WRITE_LAX))
? st
: SERD_SUCCESS;
}
@@ -553,7 +553,7 @@ write_text(SerdWriter* writer,
// Write UTF-8 character
size_t size = 0;
write_character(writer, (const uint8_t*)utf8 + i - 1, &size, &st);
- if (st && (writer->flags & SERD_WRITE_STRICT)) {
+ if (st && !(writer->flags & SERD_WRITE_LAX)) {
return st;
}
@@ -567,7 +567,7 @@ write_text(SerdWriter* writer,
}
}
- return (writer->flags & SERD_WRITE_STRICT) ? st : SERD_SUCCESS;
+ return (writer->flags & SERD_WRITE_LAX) ? SERD_SUCCESS : st;
}
typedef struct {
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index abea37b3..3cacd4be 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -370,9 +370,8 @@ faulty_sink(const void* const buf,
static void
test_write_errors(void)
{
- SerdWorld* const world = serd_world_new();
- ErrorContext ctx = {0U, 0U};
- const SerdWriterFlags style = (SerdWriterFlags)SERD_WRITE_STRICT;
+ SerdWorld* const world = serd_world_new();
+ ErrorContext ctx = {0U, 0U};
const size_t max_offsets[] = {0, 386, 1911, 2003, 386};
@@ -385,7 +384,7 @@ test_write_errors(void)
SerdEnv* const env = serd_env_new(serd_empty_string());
SerdWriter* const writer =
- serd_writer_new(world, syntax, style, env, faulty_sink, &ctx);
+ serd_writer_new(world, syntax, 0U, env, faulty_sink, &ctx);
const SerdSink* const sink = serd_writer_sink(writer);
SerdReader* const reader = serd_reader_new(world, SERD_TRIG, sink, 4096U);
@@ -413,8 +412,8 @@ test_writer(const char* const path)
SerdWorld* world = serd_world_new();
- SerdWriter* writer =
- serd_writer_new(world, SERD_TURTLE, 0, env, (SerdWriteFunc)fwrite, fd);
+ SerdWriter* writer = serd_writer_new(
+ world, SERD_TURTLE, SERD_WRITE_LAX, env, (SerdWriteFunc)fwrite, fd);
assert(writer);
serd_writer_chop_blank_prefix(writer, "tmp");
diff --git a/test/test_writer.c b/test/test_writer.c
index e56dd789..9b885dd6 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -177,10 +177,10 @@ test_strict_write(void)
FILE* const fd = fopen(path, "wb");
assert(fd);
- SerdWorld* world = serd_world_new();
- SerdEnv* const env = serd_env_new(serd_empty_string());
- SerdWriter* const writer = serd_writer_new(
- world, SERD_TURTLE, (SerdWriterFlags)SERD_WRITE_STRICT, env, null_sink, fd);
+ SerdWorld* world = serd_world_new();
+ SerdEnv* const env = serd_env_new(serd_empty_string());
+ SerdWriter* const writer =
+ serd_writer_new(world, SERD_TURTLE, 0U, env, null_sink, fd);
assert(writer);