summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-03 20:18:29 +0000
committerDavid Robillard <d@drobilla.net>2012-01-03 20:18:29 +0000
commit578ff2b611a4c824c45fc4d6e684b6f5970eb702 (patch)
tree41c1c31d71579b70ea5fbc9a70bdeb5fb2f18ab9 /src
parent8708ccb858ddbf5d521c4755e137bd04544a6ae5 (diff)
downloadlilv-578ff2b611a4c824c45fc4d6e684b6f5970eb702.tar.gz
lilv-578ff2b611a4c824c45fc4d6e684b6f5970eb702.tar.bz2
lilv-578ff2b611a4c824c45fc4d6e684b6f5970eb702.zip
100% coverage for query.c.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3909 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/query.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/query.c b/src/query.c
index 40387ef..d8d4ea7 100644
--- a/src/query.c
+++ b/src/query.c
@@ -35,19 +35,14 @@ lilv_lang_matches(const char* a, const char* b)
}
const char* a_dash = strchr(a, '-');
- const size_t a_lang_len = a_dash ? (a_dash - a) : 0;
+ const size_t a_lang_len = a_dash ? (size_t)(a_dash - a) : strlen(a);
const char* b_dash = strchr(b, '-');
- const size_t b_lang_len = b_dash ? (b_dash - b) : 0;
+ const size_t b_lang_len = b_dash ? (size_t)(b_dash - b) : strlen(b);
- if (a_lang_len && b_lang_len) {
- if (a_lang_len == b_lang_len && !strncmp(a, b, a_lang_len)) {
- return LILV_LANG_MATCH_PARTIAL; // e.g. a="en-gb", b="en-ca"
- }
- } else if (a_lang_len && !strncmp(a, b, a_lang_len)) {
- return LILV_LANG_MATCH_PARTIAL; // e.g. a="en", b="en-ca"
- } else if (b_lang_len && !strncmp(a, b, b_lang_len)) {
- return LILV_LANG_MATCH_PARTIAL; // e.g. a="en-ca", b="en"
+ if (a_lang_len == b_lang_len && !strncmp(a, b, a_lang_len)) {
+ return LILV_LANG_MATCH_PARTIAL;
}
+
return LILV_LANG_MATCH_NONE;
}