aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-24 22:44:52 +0000
committerDavid Robillard <d@drobilla.net>2011-12-24 22:44:52 +0000
commit15b033080ce2ebdd16fb01073bb5a5cf976527bb (patch)
tree9ad6ca420c9239ecd1f31ea04f5d0343c91fa7dc /src
parentcc9f30fefe18284a2f05134e7fc2ecbada1722f7 (diff)
downloadserd-15b033080ce2ebdd16fb01073bb5a5cf976527bb.tar.gz
serd-15b033080ce2ebdd16fb01073bb5a5cf976527bb.tar.bz2
serd-15b033080ce2ebdd16fb01073bb5a5cf976527bb.zip
Allow digit as first character of prefixed name suffix (match latest Turtle spec).
Improve env.c test coverage. Add test case for ticket #734. git-svn-id: http://svn.drobilla.net/serd/trunk@271 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r--src/env.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/env.c b/src/env.c
index 6afcc77e..7abe6791 100644
--- a/src/env.c
+++ b/src/env.c
@@ -169,36 +169,31 @@ serd_env_set_prefix_from_strings(SerdEnv* env,
static inline bool
is_nameStartChar(const uint8_t c)
{
- // TODO: not strictly correct (see reader.c read_nameStartChar)
- return (c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z');
+ return is_alpha(c) || is_digit(c) || c == '_';
}
static inline bool
is_nameChar(const uint8_t c)
{
- // TODO: 0x300-0x036F | 0x203F-0x2040 (see reader.c read_nameChar)
- return is_nameStartChar(c) || c == '-'
- || (c >= '0' && c <= '9') || c == 0xB7;
+ return is_nameStartChar(c) || c == '.' || c == 0xB7;
}
/**
- Return true iff @c buf is a valid Turtle name.
+ Return true iff @c buf is a valid prefixed name suffix.
+ TODO: This is more strict than it should be.
*/
static inline bool
-is_name(const uint8_t* buf,
- size_t len)
+is_name(const uint8_t* buf, size_t len)
{
- if (!is_nameStartChar(buf[0])) {
- return false;
- }
-
- for (size_t i = 1; i < len; ++i) {
- if (!is_nameChar(buf[i])) {
- return false;
+ if (is_nameStartChar(buf[0])) {
+ for (size_t i = 1; i < len; ++i) {
+ if (!is_nameChar(buf[i])) {
+ return false;
+ }
}
+ return true;
}
-
- return true;
+ return false;
}
SERD_API
@@ -217,10 +212,9 @@ serd_env_qualify(const SerdEnv* env,
*prefix_name = env->prefixes[i].name;
suffix->buf = uri->buf + prefix_uri->n_bytes;
suffix->len = uri->n_bytes - prefix_uri->n_bytes;
- if (!is_name(suffix->buf, suffix->len)) {
- continue;
+ if (is_name(suffix->buf, suffix->len)) {
+ return true;
}
- return true;
}
}
}