aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--include/serd/serd.h9
-rw-r--r--meson.build2
-rw-r--r--src/node.c2
-rw-r--r--src/serdi.c34
-rw-r--r--src/writer.c5
-rw-r--r--test/meson.build3
-rwxr-xr-xtest/run_test_suite.py34
8 files changed, 35 insertions, 55 deletions
diff --git a/NEWS b/NEWS
index 2d5ad9b0..210e4f80 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ serd (1.0.1) unstable;
* Remove support for Turtle named inline nodes extension
* Remove useless character counting from API
* Rename SerdChunk to SerdStringView
+ * Simplify writer style options
* Use a fixed-size reader stack
* Use char* for strings in public API
diff --git a/include/serd/serd.h b/include/serd/serd.h
index db03108c..9a414b11 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -1565,11 +1565,10 @@ typedef struct SerdWriterImpl SerdWriter;
does not support abbreviation and is always ASCII.
*/
typedef enum {
- SERD_WRITE_ABBREVIATED = 1u << 0u, ///< Abbreviate triples when possible
- SERD_WRITE_ASCII = 1u << 1u, ///< Escape all non-ASCII characters
- SERD_WRITE_RESOLVED = 1u << 2u, ///< Resolve URIs against base URI
- SERD_WRITE_CURIED = 1u << 3u, ///< Shorten URIs into CURIEs
- SERD_WRITE_BULK = 1u << 4u, ///< Write output in pages
+ SERD_WRITE_ASCII = 1u << 0u, ///< Escape all non-ASCII characters
+ SERD_WRITE_BULK = 1u << 1u, ///< Write output in pages
+ SERD_WRITE_UNQUALIFIED = 1u << 2u, ///< Do not shorten URIs into CURIEs
+ SERD_WRITE_UNRESOLVED = 1u << 3u ///< Do not make URIs relative
} SerdWriterFlag;
/// Bitwise OR of SerdWriterFlag values
diff --git a/meson.build b/meson.build
index 4e3c3e31..29236513 100644
--- a/meson.build
+++ b/meson.build
@@ -35,7 +35,6 @@ if get_option('strict')
'-Wno-nullable-to-nonnull-conversion',
'-Wno-padded',
'-Wno-reserved-id-macro',
- '-Wno-sign-conversion',
]
elif cc.get_id() == 'gcc'
c_suppressions += [
@@ -44,7 +43,6 @@ if get_option('strict')
'-Wno-format-nonliteral',
'-Wno-inline',
'-Wno-padded',
- '-Wno-sign-conversion',
'-Wno-switch-default',
'-Wno-unsuffixed-float-constants',
'-Wno-unused-const-variable',
diff --git a/src/node.c b/src/node.c
index 25c1a9df..0f82b837 100644
--- a/src/node.c
+++ b/src/node.c
@@ -137,7 +137,7 @@ serd_node_malloc(const size_t length,
node->flags = flags;
node->type = type;
- assert((intptr_t)node % serd_node_align == 0);
+ assert((uintptr_t)node % serd_node_align == 0);
return node;
}
diff --git a/src/serdi.c b/src/serdi.c
index a94051bc..3f4593db 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -87,36 +87,6 @@ quiet_error_func(void* const handle, const SerdError* const e)
return SERD_SUCCESS;
}
-static SerdWriterFlags
-choose_style(const SerdSyntax input_syntax,
- const SerdSyntax output_syntax,
- const bool ascii,
- const bool bulk_write,
- const bool full_uris)
-{
- SerdWriterFlags writer_flags = 0u;
- if (output_syntax == SERD_NTRIPLES || ascii) {
- writer_flags |= SERD_WRITE_ASCII;
- } else if (output_syntax == SERD_TURTLE) {
- writer_flags |= SERD_WRITE_ABBREVIATED;
- if (!full_uris) {
- writer_flags |= SERD_WRITE_CURIED;
- }
- }
-
- if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) ||
- (writer_flags & SERD_WRITE_CURIED)) {
- // Base URI may change and/or we're abbreviating URIs, so must resolve
- writer_flags |= SERD_WRITE_RESOLVED;
- }
-
- if (bulk_write) {
- writer_flags |= SERD_WRITE_BULK;
- }
-
- return writer_flags;
-}
-
int
main(int argc, char** argv)
{
@@ -249,7 +219,9 @@ main(int argc, char** argv)
}
const SerdWriterFlags writer_flags =
- choose_style(input_syntax, output_syntax, ascii, bulk_write, full_uris);
+ ((ascii ? SERD_WRITE_ASCII : 0u) | //
+ (bulk_write ? SERD_WRITE_BULK : 0u) | //
+ (full_uris ? (SERD_WRITE_UNQUALIFIED | SERD_WRITE_UNRESOLVED) : 0u));
SerdNode* base = NULL;
if (a < argc) { // Base URI given on command line
diff --git a/src/writer.c b/src/writer.c
index 66a53819..e50cdaf1 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -576,7 +576,7 @@ write_uri_node(SerdWriter* const writer,
return sink("()", 2, writer) == 2;
}
- if (has_scheme && (writer->flags & SERD_WRITE_CURIED) &&
+ if (has_scheme && !(writer->flags & SERD_WRITE_UNQUALIFIED) &&
serd_env_qualify(writer->env, node, &prefix, &suffix) &&
is_name(serd_node_string(prefix), serd_node_length(prefix)) &&
is_name(suffix.buf, suffix.len)) {
@@ -597,7 +597,8 @@ write_uri_node(SerdWriter* const writer,
}
write_sep(writer, SEP_URI_BEGIN);
- if ((writer->flags & SERD_WRITE_RESOLVED) && serd_env_base_uri(writer->env)) {
+ if (!(writer->flags & SERD_WRITE_UNRESOLVED) &&
+ serd_env_base_uri(writer->env)) {
const SerdURIView base_uri = serd_env_base_uri_view(writer->env);
SerdURIView uri = serd_parse_uri(node_str);
SerdURIView abs_uri = serd_resolve_uri(uri, base_uri);
diff --git a/test/meson.build b/test/meson.build
index 04c89731..8a76bbb6 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -205,9 +205,6 @@ if get_option('utils')
base_uri = w3c_base + syntax + 'Tests/'
args = ['--syntax', syntax, manifest, base_uri]
- if syntax == 'TriG'
- args += ['--', '-a']
- endif
test(syntax, run_test_suite,
args: script_args + args,
diff --git a/test/run_test_suite.py b/test/run_test_suite.py
index 3f637146..5f1d29c8 100755
--- a/test/run_test_suite.py
+++ b/test/run_test_suite.py
@@ -47,6 +47,13 @@ def log_error(message):
sys.stderr.write(message)
+def test_osyntax_options(osyntax):
+ if osyntax.lower() == "ntriples" or osyntax.lower() == "nquads":
+ return ["-a"]
+
+ return []
+
+
def test_thru(
base_uri,
path,
@@ -81,16 +88,21 @@ def test_thru(
]
)
- thru_cmd = command_prefix + [
- "-i",
- isyntax,
- "-o",
- osyntax,
- "-c",
- "foo",
- out_path,
- base_uri,
- ]
+ thru_cmd = (
+ command_prefix
+ + test_osyntax_options(osyntax)
+ + [
+ "-i",
+ isyntax,
+ "-o",
+ osyntax,
+ "-c",
+ "foo",
+ "-a",
+ out_path,
+ base_uri,
+ ]
+ )
with open(out_path, "wb") as out:
subprocess.run(out_cmd, check=True, stdout=out)
@@ -255,7 +267,7 @@ def test_suite(
test_name = os.path.basename(test_uri_path)
test_path = os.path.join(test_dir, test_name)
- command = command_prefix + ["-f", test_path, test_uri]
+ command = command_prefix + ["-a"] + [test_path, test_uri]
command_string = " ".join(shlex.quote(c) for c in command)
out_filename = os.path.join(out_test_dir, test_name + ".out")