aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--serd/serd.h2
-rw-r--r--src/env.c3
-rw-r--r--src/reader.c9
-rw-r--r--src/serdi.c6
-rw-r--r--src/uri.c85
-rw-r--r--src/writer.c9
-rw-r--r--wscript80
7 files changed, 100 insertions, 94 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 0651d734..005f2a73 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -542,7 +542,7 @@ serd_reader_new(SerdSyntax syntax,
SERD_API
void*
serd_reader_get_handle(const SerdReader* reader);
-
+
/**
Set a prefix to be added to all blank node identifiers.
diff --git a/src/env.c b/src/env.c
index d53ef73e..aaa910e1 100644
--- a/src/env.c
+++ b/src/env.c
@@ -266,7 +266,8 @@ serd_env_expand_node(const SerdEnv* env,
0,
SERD_URI };
ret.buf = malloc(ret.n_bytes + 1);
- snprintf((char*)ret.buf, ret.n_bytes + 1, "%s%s", prefix.buf, suffix.buf);
+ snprintf((char*)ret.buf, ret.n_bytes + 1,
+ "%s%s", prefix.buf, suffix.buf);
return ret;
} else if (node->type == SERD_URI) {
SerdURI ignored;
diff --git a/src/reader.c b/src/reader.c
index 3cb2e3db..70bdd1a1 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -67,7 +67,7 @@ static const Node INTERNAL_NODE_NULL = { 0, 0 };
struct SerdReaderImpl {
void* handle;
- void (*free_handle)(void*);
+ void (*free_handle)(void* ptr);
SerdBaseSink base_sink;
SerdPrefixSink prefix_sink;
SerdStatementSink statement_sink;
@@ -330,8 +330,11 @@ emit_statement(SerdReader* reader, SerdStatementFlags* flags,
return ret;
}
-static bool read_collection(SerdReader* reader, ReadContext ctx, Node* dest);
-static bool read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool blank);
+static bool
+read_collection(SerdReader* reader, ReadContext ctx, Node* dest);
+
+static bool
+read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool blank);
// [40] hex ::= [#x30-#x39] | [#x41-#x46]
static inline uint8_t
diff --git a/src/serdi.c b/src/serdi.c
index c3f7aa2e..ef7d72cb 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -74,7 +74,7 @@ set_syntax(SerdSyntax* syntax, const char* name)
}
return true;
}
-
+
int
main(int argc, char** argv)
{
@@ -142,7 +142,7 @@ main(int argc, char** argv)
fprintf(stderr, "Missing input\n");
return 1;
}
-
+
const uint8_t* input = (const uint8_t*)argv[a++];
if (from_file) {
in_name = in_name ? in_name : input;
@@ -183,7 +183,7 @@ main(int argc, char** argv)
SerdURI base_uri = SERD_URI_NULL;
SerdNode base_uri_node = serd_node_new_uri_from_string(
base_uri_str, &base_uri, &base_uri);
-
+
if (!base_uri_node.buf) {
fprintf(stderr, "Invalid base URI <%s>\n", base_uri_str);
return 1;
diff --git a/src/uri.c b/src/uri.c
index 04ca8c84..61fb35ce 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -292,68 +292,67 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream)
if (uri->path_base.len) {
if (!uri->path.buf && (uri->fragment.buf || uri->query.buf)) {
WRITE_COMPONENT("", uri->path_base, "");
- } else {
+ } else if (uri->path.buf) {
/* Merge paths, removing dot components.
See http://tools.ietf.org/html/rfc3986#section-5.2.3
*/
const uint8_t* begin = uri->path.buf;
size_t up = 1;
- if (begin) {
- // Count and skip leading dot components
- const uint8_t* end = uri->path.buf + uri->path.len;
- for (bool done = false; !done && (begin < end);) {
- switch (begin[0]) {
+ // Count and skip leading dot components
+ const uint8_t* end = uri->path.buf + uri->path.len;
+ for (bool done = false; !done && (begin < end);) {
+ switch (begin[0]) {
+ case '.':
+ switch (begin[1]) {
+ case '/':
+ begin += 2; // Chop leading "./"
+ break;
case '.':
- switch (begin[1]) {
+ ++up;
+ switch (begin[2]) {
case '/':
- begin += 2; // Chop leading "./"
- break;
- case '.':
- ++up;
- switch (begin[2]) {
- case '/':
- begin += 3; // Chop lading "../"
- break;
- default:
- begin += 2; // Chop leading ".."
- }
+ begin += 3; // Chop lading "../"
break;
default:
- ++begin; // Chop leading "."
+ begin += 2; // Chop leading ".."
}
break;
- case '/':
- if (begin[1] == '/') {
- ++begin; // Replace leading "//" with "/"
- break;
- } // else fall through
default:
- done = true; // Finished chopping dot components
+ ++begin; // Chop leading "."
}
+ break;
+ case '/':
+ if (begin[1] == '/') {
+ ++begin; // Replace leading "//" with "/"
+ break;
+ } // else fall through
+ default:
+ done = true; // Finished chopping dot components
}
+ }
- if (uri->path.buf && uri->path_base.buf) {
- // Find the up'th last slash
- const uint8_t* base_last = uri->path_base.buf + uri->path_base.len - 1;
- do {
- if (*base_last == '/') {
- --up;
- }
- } while (up > 0 && (--base_last > uri->path_base.buf));
-
- // Write base URI prefix
- const size_t base_len = base_last - uri->path_base.buf + 1;
- WRITE(uri->path_base.buf, base_len);
+ if (uri->path.buf && uri->path_base.buf) {
+ // Find the up'th last slash
+ const uint8_t* base_last = (uri->path_base.buf
+ + uri->path_base.len - 1);
+ do {
+ if (*base_last == '/') {
+ --up;
+ }
+ } while (up > 0 && (--base_last > uri->path_base.buf));
- } else {
- // Relative path is just query or fragment, append it to full base URI
- WRITE_COMPONENT("", uri->path_base, "");
- }
+ // Write base URI prefix
+ const size_t base_len = base_last - uri->path_base.buf + 1;
+ WRITE(uri->path_base.buf, base_len);
- // Write URI suffix
- WRITE(begin, end - begin);
+ } else {
+ // Relative path is just query or fragment, append to base URI
+ WRITE_COMPONENT("", uri->path_base, "");
}
+
+ // Write URI suffix
+ WRITE(begin, end - begin);
}
} else {
WRITE_COMPONENT("", uri->path, "");
diff --git a/src/writer.c b/src/writer.c
index cb68ed46..a3cb5eab 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -213,9 +213,9 @@ write_node(SerdWriter* writer,
writer->sink("[]", 2, writer->stream);
} else {
writer->sink("_:", 2, writer->stream);
- if (writer->bprefix
- && !strncmp((const char*)node->buf, (const char*)writer->bprefix,
- writer->bprefix_len)) {
+ if (writer->bprefix && !strncmp((const char*)node->buf,
+ (const char*)writer->bprefix,
+ writer->bprefix_len)) {
writer->sink(node->buf + writer->bprefix_len,
node->n_bytes - writer->bprefix_len,
writer->stream);
@@ -254,7 +254,8 @@ write_node(SerdWriter* writer,
&& ((node->flags & SERD_HAS_NEWLINE)
|| (node->flags & SERD_HAS_QUOTE))) {
writer->sink("\"\"\"", 3, writer->stream);
- write_text(writer, WRITE_LONG_STRING, node->buf, node->n_bytes, '\0');
+ write_text(writer, WRITE_LONG_STRING,
+ node->buf, node->n_bytes, '\0');
writer->sink("\"\"\"", 3, writer->stream);
} else {
writer->sink("\"", 1, writer->stream);
diff --git a/wscript b/wscript
index fd813323..24a0230a 100644
--- a/wscript
+++ b/wscript
@@ -85,56 +85,58 @@ def build(bld):
'''
# Shared Library
- obj = bld(features = 'c cshlib')
- obj.export_includes = ['.']
- obj.source = lib_source
- obj.includes = ['.', './src']
- obj.name = 'libserd'
- obj.target = 'serd-%s' % SERD_MAJOR_VERSION
- obj.vnum = SERD_LIB_VERSION
- obj.install_path = '${LIBDIR}'
- obj.cflags = [ '-fvisibility=hidden', '-DSERD_SHARED', '-DSERD_INTERNAL' ]
+ obj = bld(features = 'c cshlib',
+ export_includes = ['.'],
+ source = lib_source,
+ includes = ['.', './src'],
+ name = 'libserd',
+ target = 'serd-%s' % SERD_MAJOR_VERSION,
+ vnum = SERD_LIB_VERSION,
+ install_path = '${LIBDIR}',
+ cflags = [ '-fvisibility=hidden',
+ '-DSERD_SHARED', '-DSERD_INTERNAL' ])
# Static library
if bld.env['BUILD_STATIC']:
- obj = bld(features = 'c cstlib')
- obj.export_includes = ['.']
- obj.source = lib_source
- obj.includes = ['.', './src']
- obj.name = 'libserd_static'
- obj.target = 'serd-%s' % SERD_MAJOR_VERSION
- obj.vnum = SERD_LIB_VERSION
- obj.install_path = '${LIBDIR}'
- obj.cflags = [ '-DSERD_INTERNAL' ]
+ obj = bld(features = 'c cstlib',
+ export_includes = ['.'],
+ source = lib_source,
+ includes = ['.', './src'],
+ name = 'libserd_static',
+ target = 'serd-%s' % SERD_MAJOR_VERSION,
+ vnum = SERD_LIB_VERSION,
+ install_path = ',{LIBDIR}',
+ cflags = [ '-DSERD_INTERNAL' ])
if bld.env['BUILD_TESTS']:
# Static library (for unit test code coverage)
- obj = bld(features = 'c cstlib')
- obj.source = lib_source
- obj.includes = ['.', './src']
- obj.name = 'libserd_profiled'
- obj.target = 'serd_profiled'
- obj.install_path = ''
- obj.cflags = [ '-fprofile-arcs', '-ftest-coverage', '-DSERD_INTERNAL' ]
+ obj = bld(features = 'c cstlib',
+ source = lib_source,
+ includes = ['.', './src'],
+ name = 'libserd_profiled',
+ target = 'serd_profiled',
+ install_path = '',
+ cflags = [ '-fprofile-arcs', '-ftest-coverage',
+ '-DSERD_INTERNAL' ])
# Unit test program
- obj = bld(features = 'c cprogram')
- obj.source = 'src/serdi.c'
- obj.includes = ['.', './src']
- obj.use = 'libserd_profiled'
- obj.linkflags = '-lgcov'
- obj.target = 'serdi_static'
- obj.install_path = ''
- obj.cflags = [ '-fprofile-arcs', '-ftest-coverage' ]
+ obj = bld(features = 'c cprogram',
+ source = 'src/serdi.c',
+ includes = ['.', './src'],
+ use = 'libserd_profiled',
+ linkflags = '-lgcov',
+ target = 'serdi_static',
+ install_path = '',
+ cflags = [ '-fprofile-arcs', '-ftest-coverage' ])
# Utilities
if bld.env['BUILD_UTILS']:
- obj = bld(features = 'c cprogram')
- obj.source = 'src/serdi.c'
- obj.includes = ['.', './src']
- obj.use = 'libserd'
- obj.target = 'serdi'
- obj.install_path = '${BINDIR}'
+ obj = bld(features = 'c cprogram',
+ source = 'src/serdi.c',
+ includes = ['.', './src'],
+ use = 'libserd',
+ target = 'serdi',
+ install_path = '${BINDIR}')
# Documentation
autowaf.build_dox(bld, 'SERD', SERD_VERSION, top, out)