aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-26 20:15:58 -0500
committerDavid Robillard <d@drobilla.net>2017-12-29 10:56:53 -0500
commita7eb973ed219f9c6962018d34f9aec261d48dc73 (patch)
tree42a30a1b481aa6123cfc7f2a4372fbb7ae5a9a8b
parent5d1b33259ae5ea31a71d0ec4ef9a4b546a771564 (diff)
downloadserd-a7eb973ed219f9c6962018d34f9aec261d48dc73.tar.gz
serd-a7eb973ed219f9c6962018d34f9aec261d48dc73.tar.bz2
serd-a7eb973ed219f9c6962018d34f9aec261d48dc73.zip
Add serdi option to write ASCII output
-rw-r--r--NEWS3
-rw-r--r--doc/serdi.14
-rw-r--r--src/serdi.c7
3 files changed, 12 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index dc27a68e..c2191ab9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
serd (0.29.3) unstable;
+ * Add serdi option to write ASCII output
* Make serdi guess input syntax from extension if unspecified
* Make serdi syntax options case-insensitive
* Add basic error tolerant parsing for line-based formats
@@ -10,7 +11,7 @@ serd (0.29.3) unstable;
* Fix building with MSVC
* Clean up testing code
- -- David Robillard <d@drobilla.net> Sun, 24 Sep 2017 18:51:27 +0200
+ -- David Robillard <d@drobilla.net> Sun, 24 Dec 2017 14:14:15 -0500
serd (0.28.0) stable;
diff --git a/doc/serdi.1 b/doc/serdi.1
index c11d2b3b..d5051655 100644
--- a/doc/serdi.1
+++ b/doc/serdi.1
@@ -9,6 +9,10 @@ serdi [OPTION]... INPUT BASE_URI
.SH OPTIONS
.TP
+\fB\-a\fR
+Write ASCII output if possible.
+
+.TP
\fB\-b\fR
Fast bulk output for large serialisations.
diff --git a/src/serdi.c b/src/serdi.c
index 59dbaf35..e1a53845 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -83,6 +83,7 @@ print_usage(const char* name, bool error)
fprintf(os, "Usage: %s [OPTION]... INPUT [BASE_URI]\n", name);
fprintf(os, "Read and write RDF syntax.\n");
fprintf(os, "Use - for INPUT to read from standard input.\n\n");
+ fprintf(os, " -a Write ASCII output if possible.\n");
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");
@@ -123,6 +124,7 @@ main(int argc, char** argv)
SerdSyntax input_syntax = (SerdSyntax)0;
SerdSyntax output_syntax = (SerdSyntax)0;
bool from_file = true;
+ bool ascii = false;
bool bulk_read = true;
bool bulk_write = false;
bool full_uris = false;
@@ -138,6 +140,8 @@ main(int argc, char** argv)
in_name = (const uint8_t*)"(stdin)";
in_fd = stdin;
break;
+ } else if (argv[a][1] == 'a') {
+ ascii = true;
} else if (argv[a][1] == 'b') {
bulk_write = true;
} else if (argv[a][1] == 'e') {
@@ -230,7 +234,8 @@ main(int argc, char** argv)
SerdEnv* env = serd_env_new(&base);
int output_style = 0;
- if (output_syntax == SERD_NTRIPLES || output_syntax == SERD_NQUADS) {
+ if (output_syntax == SERD_NTRIPLES || output_syntax == SERD_NQUADS ||
+ ascii) {
output_style |= SERD_STYLE_ASCII;
} else if (output_syntax == SERD_TURTLE) {
output_style |= SERD_STYLE_ABBREVIATED;