From 578ff2b611a4c824c45fc4d6e684b6f5970eb702 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 3 Jan 2012 20:18:29 +0000 Subject: 100% coverage for query.c. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3909 a436a847-0d15-0410-975c-d299462d15a1 --- src/query.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src') 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; } -- cgit v1.2.1