diff options
author | David Robillard <d@drobilla.net> | 2018-07-05 21:01:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-12-19 20:55:29 -0500 |
commit | 1f97eee7bdb806c3e4e349a1e1be756736493bce (patch) | |
tree | e0c1065ed91716efe28c652ec73d9458e6a96c16 /src | |
parent | 0ce97313470a7c23bbad098346844f2ceabc07c5 (diff) | |
download | serd-1f97eee7bdb806c3e4e349a1e1be756736493bce.tar.gz serd-1f97eee7bdb806c3e4e349a1e1be756736493bce.tar.bz2 serd-1f97eee7bdb806c3e4e349a1e1be756736493bce.zip |
Simplify writer style options
Diffstat (limited to 'src')
-rw-r--r-- | src/serdi.c | 25 | ||||
-rw-r--r-- | src/writer.c | 4 |
2 files changed, 4 insertions, 25 deletions
diff --git a/src/serdi.c b/src/serdi.c index 28c4749e..e5f859aa 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -55,7 +55,6 @@ print_usage(const char* name, bool error) fprintf(os, " -b Fast bulk output for large serialisations.\n"); fprintf(os, " -c PREFIX Chop PREFIX from matching blank node IDs.\n"); fprintf(os, " -e Eat input one character at a time.\n"); - fprintf(os, " -f Keep full URIs in input (don't qualify).\n"); fprintf(os, " -h Display this help and exit.\n"); fprintf(os, " -i SYNTAX Input syntax: turtle/ntriples/trig/nquads.\n"); fprintf(os, " -k BYTES Parser stack size.\n"); @@ -98,7 +97,6 @@ main(int argc, char** argv) bool ascii = false; bool bulk_read = true; bool bulk_write = false; - bool full_uris = false; bool lax = false; bool quiet = false; size_t stack_size = 4194304; @@ -116,8 +114,6 @@ main(int argc, char** argv) bulk_write = true; } else if (argv[a][1] == 'e') { bulk_read = false; - } else if (argv[a][1] == 'f') { - full_uris = true; } else if (argv[a][1] == 'h') { return print_usage(argv[0], false); } else if (argv[a][1] == 'l') { @@ -206,25 +202,8 @@ main(int argc, char** argv) SerdWorld* world = serd_world_new(); SerdEnv* env = serd_env_new(base); - SerdStyleFlags output_style = 0; - if (output_syntax == SERD_NTRIPLES || ascii) { - output_style |= SERD_STYLE_ASCII; - } else if (output_syntax == SERD_TURTLE) { - output_style |= SERD_STYLE_ABBREVIATED; - if (!full_uris) { - output_style |= SERD_STYLE_CURIED; - } - } - - if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) || - (output_style & SERD_STYLE_CURIED)) { - // Base URI may change and/or we're abbreviating URIs, so must resolve - output_style |= SERD_STYLE_RESOLVED; - } - - if (bulk_write) { - output_style |= SERD_STYLE_BULK; - } + const SerdStyleFlags output_style = ((ascii ? SERD_STYLE_ASCII : 0) | + (bulk_write ? SERD_STYLE_BULK : 0)); SerdWriter* writer = serd_writer_new(world, output_syntax, diff --git a/src/writer.c b/src/writer.c index f6c16d67..4b14405b 100644 --- a/src/writer.c +++ b/src/writer.c @@ -510,7 +510,7 @@ write_uri_node(SerdWriter* const writer, return sink("a", 1, writer) == 1; } else if (supports_abbrev(writer) && !strcmp(node_str, NS_RDF "nil")) { return sink("()", 2, writer) == 2; - } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && + } else if (has_scheme && supports_abbrev(writer) && serd_env_qualify_in_place(writer->env, node, &prefix, &suffix) && is_name(serd_node_get_string(prefix), serd_node_get_length(prefix)) && is_name(suffix.buf, suffix.len)) { @@ -521,7 +521,7 @@ write_uri_node(SerdWriter* const writer, } write_sep(writer, SEP_URI_BEGIN); - if (writer->style & SERD_STYLE_RESOLVED) { + if (serd_env_get_base_uri(writer->env)) { const SerdURI* base_uri = serd_env_get_parsed_base_uri(writer->env); SerdURI uri, abs_uri; serd_uri_parse(node_str, &uri); |