summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/query.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/query.c b/src/query.c
index 5dba54a..cf5e44f 100644
--- a/src/query.c
+++ b/src/query.c
@@ -32,7 +32,9 @@ typedef enum {
static LilvLangMatch
lilv_lang_matches(const char* a, const char* b)
{
- if (!strcmp(a, b)) {
+ if (!a || !b) {
+ return LILV_LANG_MATCH_NONE;
+ } else if (!strcmp(a, b)) {
return LILV_LANG_MATCH_EXACT;
}
@@ -60,28 +62,26 @@ lilv_nodes_from_stream_objects_i18n(LilvWorld* world,
FOREACH_MATCH(stream) {
const SordNode* value = sord_iter_get_node(stream, field);
if (sord_node_get_type(value) == SORD_LITERAL) {
- const char* lang = sord_node_get_language(value);
- LilvLangMatch lm = LILV_LANG_MATCH_NONE;
- if (lang) {
- lm = (syslang)
- ? lilv_lang_matches(lang, syslang)
- : LILV_LANG_MATCH_PARTIAL;
- } else {
+ const char* lang = sord_node_get_language(value);
+
+ if (!lang) {
nolang = value;
- if (!syslang) {
- lm = LILV_LANG_MATCH_EXACT;
+ } else {
+ switch (lilv_lang_matches(lang, syslang)) {
+ case LILV_LANG_MATCH_EXACT:
+ // Exact language match, add to results
+ zix_tree_insert((ZixTree*)values,
+ lilv_node_new_from_node(world, value),
+ NULL);
+ break;
+ case LILV_LANG_MATCH_PARTIAL:
+ // Partial language match, save in case we find no exact
+ partial = value;
+ break;
+ case LILV_LANG_MATCH_NONE:
+ break;
}
}
-
- if (lm == LILV_LANG_MATCH_EXACT) {
- // Exact language match, add to results
- zix_tree_insert((ZixTree*)values,
- lilv_node_new_from_node(world, value),
- NULL);
- } else if (lm == LILV_LANG_MATCH_PARTIAL) {
- // Partial language match, save in case we find no exact
- partial = value;
- }
} else {
zix_tree_insert((ZixTree*)values,
lilv_node_new_from_node(world, value),