aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/serdi.14
-rw-r--r--serd/serd.h7
-rw-r--r--src/serdi.c25
-rw-r--r--src/writer.c4
-rw-r--r--wscript15
5 files changed, 16 insertions, 39 deletions
diff --git a/doc/serdi.1 b/doc/serdi.1
index 921de461..66d845c6 100644
--- a/doc/serdi.1
+++ b/doc/serdi.1
@@ -29,10 +29,6 @@ page of input has arrived. With this option serdi uses one page less memory,
but will likely be significantly slower.
.TP
-\fB\-f\fR
-Keep full URIs in input (don't qualify).
-
-.TP
\fB\-h\fR
Print the command line options.
diff --git a/serd/serd.h b/serd/serd.h
index f4391f4e..a36f6db3 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -303,11 +303,8 @@ typedef struct {
always ASCII).
*/
typedef enum {
- SERD_STYLE_ABBREVIATED = 1, /**< Abbreviate triples when possible. */
- SERD_STYLE_ASCII = 1 << 1, /**< Escape all non-ASCII characters. */
- SERD_STYLE_RESOLVED = 1 << 2, /**< Resolve URIs against base URI. */
- SERD_STYLE_CURIED = 1 << 3, /**< Shorten URIs into CURIEs. */
- SERD_STYLE_BULK = 1 << 4 /**< Write output in pages. */
+ SERD_STYLE_ASCII = 1 << 0, /**< Escape all non-ASCII characters. */
+ SERD_STYLE_BULK = 1 << 1 /**< Write output in pages. */
} SerdStyle;
/**
diff --git a/src/serdi.c b/src/serdi.c
index dbc57a6c..515d547e 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -51,7 +51,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");
@@ -94,7 +93,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;
@@ -112,8 +110,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') {
@@ -197,25 +193,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 d3904143..6b83d839 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -513,7 +513,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(suffix.buf, suffix.len)) {
write_uri_from_node(writer, prefix);
@@ -523,7 +523,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);
diff --git a/wscript b/wscript
index 9a1dd31a..c2b3a226 100644
--- a/wscript
+++ b/wscript
@@ -298,6 +298,11 @@ def check_output(out_filename, check_filename, subst_from='', subst_to=''):
return False
+def test_osyntax_options(osyntax):
+ if osyntax.lower() == 'ntriples' or osyntax.lower() == 'nquads':
+ return ' -a'
+ return ''
+
def test_thru(ctx, base, path, check_filename, flags, isyntax, osyntax,
options='', quiet=False):
in_filename = os.path.join(ctx.path.abspath(), path)
@@ -305,9 +310,9 @@ def test_thru(ctx, base, path, check_filename, flags, isyntax, osyntax,
command = ('serdi_static %s %s -i %s -o %s -p foo "%s" "%s" | '
'serdi_static %s -i %s -o %s -c foo - "%s" > %s') % (
- options, flags.ljust(5),
+ options + test_osyntax_options(isyntax), flags.ljust(5),
isyntax, isyntax, in_filename, base,
- options, isyntax, osyntax, base, out_filename)
+ options + test_osyntax_options(osyntax), isyntax, osyntax, base, out_filename)
if autowaf.run_test(ctx, APPNAME, command, 0, name=' to ' + out_filename, quiet=quiet):
autowaf.run_test(
@@ -374,7 +379,7 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, osyntax, options=''):
if len(tests) == 0:
return
- thru_flags = ['-e', '-f', '-b', '-r http://example.org/']
+ thru_flags = ['-e', '-b', '-r http://example.org/']
thru_options = []
for n in range(len(thru_flags) + 1):
thru_options += list(itertools.combinations(thru_flags, n))
@@ -389,7 +394,7 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, osyntax, options=''):
rel_action = os.path.join(os.path.relpath(srcdir), action)
abs_action = os.path.join(srcdir, action)
uri = base_uri + os.path.basename(action)
- command = 'serdi_static %s -f %s "%s" > %s' % (
+ command = 'serdi_static -a %s %s "%s" > %s' % (
options, rel_action, uri, action + '.out')
# Run strict test
@@ -528,7 +533,7 @@ def test(ctx):
test_suite(ctx, w3c_base + 'NQuadsTests/',
'NQuadsTests', report, 'NQuads', 'NQuads')
test_suite(ctx, w3c_base + 'TriGTests/',
- 'TriGTests', report, 'TriG', 'NQuads', '-a')
+ 'TriGTests', report, 'TriG', 'NQuads')
autowaf.post_test(ctx, APPNAME)