aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:54:49 -0400
committerDavid Robillard <d@drobilla.net>2018-05-27 18:18:55 +0200
commitfe92672ee07da411d4aed891f8475c5a949c93e4 (patch)
tree08daebce2fa68298bffc6e6be4730afdff586b5e
parent8ce3b77e73a6c172dc0954b3f5aa0e37a10850d0 (diff)
downloadserd-fe92672ee07da411d4aed891f8475c5a949c93e4.tar.gz
serd-fe92672ee07da411d4aed891f8475c5a949c93e4.tar.bz2
serd-fe92672ee07da411d4aed891f8475c5a949c93e4.zip
Rename SerdChunk to SerdSlice
-rw-r--r--serd/serd.h26
-rw-r--r--src/env.c10
-rw-r--r--src/serd_internal.h6
-rw-r--r--src/uri.c2
-rw-r--r--src/writer.c6
-rw-r--r--tests/serd_test.c2
6 files changed, 26 insertions, 26 deletions
diff --git a/serd/serd.h b/serd/serd.h
index d3c6cdeb..00f2d417 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -222,12 +222,12 @@ typedef struct {
} SerdNode;
/**
- An unterminated string fragment.
+ An unterminated immutable slice of a string.
*/
typedef struct {
const char* buf; /**< Start of chunk */
size_t len; /**< Length of chunk in bytes */
-} SerdChunk;
+} SerdSlice;
/**
A mutable buffer in memory.
@@ -252,17 +252,17 @@ typedef struct {
/**
A parsed URI.
- This struct directly refers to chunks in other strings, it does not own any
+ This struct directly refers to slices in other strings, it does not own any
memory itself. Thus, URIs can be parsed and/or resolved against a base URI
in-place without allocating memory.
*/
typedef struct {
- SerdChunk scheme; /**< Scheme */
- SerdChunk authority; /**< Authority */
- SerdChunk path_base; /**< Path prefix if relative */
- SerdChunk path; /**< Path suffix */
- SerdChunk query; /**< Query */
- SerdChunk fragment; /**< Fragment */
+ SerdSlice scheme; /**< Scheme */
+ SerdSlice authority; /**< Authority */
+ SerdSlice path_base; /**< Path prefix if relative */
+ SerdSlice path; /**< Path suffix */
+ SerdSlice query; /**< Query */
+ SerdSlice fragment; /**< Fragment */
} SerdURI;
/**
@@ -715,7 +715,7 @@ bool
serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix,
- SerdChunk* suffix);
+ SerdSlice* suffix);
/**
Expand `curie`.
@@ -727,8 +727,8 @@ SERD_API
SerdStatus
serd_env_expand(const SerdEnv* env,
const SerdNode* curie,
- SerdChunk* uri_prefix,
- SerdChunk* uri_suffix);
+ SerdSlice* uri_prefix,
+ SerdSlice* uri_suffix);
/**
Expand `node`, which must be a CURIE or URI, to a full URI.
@@ -971,7 +971,7 @@ size_t
serd_buffer_sink(const void* buf, size_t len, void* stream);
/**
- Finish a serialisation to a chunk with serd_buffer_sink().
+ Finish a serialisation to a buffer with serd_buffer_sink().
The returned string is the result of the serialisation, which is NULL
terminated (by this function) and owned by the caller.
diff --git a/src/env.c b/src/env.c
index 7831daf7..95e255cb 100644
--- a/src/env.c
+++ b/src/env.c
@@ -186,7 +186,7 @@ bool
serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix,
- SerdChunk* suffix)
+ SerdSlice* suffix)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_uri = &env->prefixes[i].uri;
@@ -210,8 +210,8 @@ SERD_API
SerdStatus
serd_env_expand(const SerdEnv* env,
const SerdNode* curie,
- SerdChunk* uri_prefix,
- SerdChunk* uri_suffix)
+ SerdSlice* uri_prefix,
+ SerdSlice* uri_suffix)
{
const char* const colon = (const char*)memchr(
curie->buf, ':', curie->n_bytes + 1);
@@ -238,8 +238,8 @@ serd_env_expand_node(const SerdEnv* env,
{
switch (node->type) {
case SERD_CURIE: {
- SerdChunk prefix;
- SerdChunk suffix;
+ SerdSlice prefix;
+ SerdSlice suffix;
if (serd_env_expand(env, node, &prefix, &suffix)) {
return SERD_NODE_NULL;
}
diff --git a/src/serd_internal.h b/src/serd_internal.h
index d678627f..70ab1e97 100644
--- a/src/serd_internal.h
+++ b/src/serd_internal.h
@@ -408,7 +408,7 @@ parse_utf8_char(const uint8_t* utf8, size_t* size)
/* URI utilities */
static inline bool
-chunk_equals(const SerdChunk* a, const SerdChunk* b)
+slice_equals(const SerdSlice* a, const SerdSlice* b)
{
return a->len == b->len
&& !strncmp((const char*)a->buf, (const char*)b->buf, a->len);
@@ -435,8 +435,8 @@ static inline bool
uri_is_under(const SerdURI* uri, const SerdURI* root)
{
if (!root || !root->scheme.len ||
- !chunk_equals(&root->scheme, &uri->scheme) ||
- !chunk_equals(&root->authority, &uri->authority)) {
+ !slice_equals(&root->scheme, &uri->scheme) ||
+ !slice_equals(&root->authority, &uri->authority)) {
return false;
}
diff --git a/src/uri.c b/src/uri.c
index 46a55675..2149b4f4 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -315,7 +315,7 @@ remove_dot_segments(const char* path, size_t len, size_t* up)
/// Merge `base` and `path` in-place
static void
-merge(SerdChunk* base, SerdChunk* path)
+merge(SerdSlice* base, SerdSlice* path)
{
size_t up;
const char* begin = remove_dot_segments(path->buf, path->len, &up);
diff --git a/src/writer.c b/src/writer.c
index e7ec0e09..dfbfc94a 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -469,7 +469,7 @@ write_uri_node(SerdWriter* const writer,
const SerdStatementFlags flags)
{
SerdNode prefix;
- SerdChunk suffix;
+ SerdSlice suffix;
if (is_inline_start(writer, field, flags)) {
++writer->indent;
@@ -525,8 +525,8 @@ write_curie(SerdWriter* const writer,
const Field field,
const SerdStatementFlags flags)
{
- SerdChunk prefix;
- SerdChunk suffix;
+ SerdSlice prefix;
+ SerdSlice suffix;
SerdStatus st;
switch (writer->syntax) {
case SERD_NTRIPLES:
diff --git a/tests/serd_test.c b/tests/serd_test.c
index b3270cde..c44fcb2f 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -413,7 +413,7 @@ main(void)
FAIL("Base URI mismatch\n");
}
- SerdChunk prefix, suffix;
+ SerdSlice prefix, suffix;
if (!serd_env_expand(env, &b, &prefix, &suffix)) {
FAILF("Expanded invalid curie %s\n", b.buf);
}