summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-01-18 17:09:43 +0100
committerDavid Robillard <d@drobilla.net>2020-01-18 17:13:05 +0100
commitf317e39966f709a68ecdb2355cb39c23abc535c8 (patch)
tree4e3b733d14aed49a1d0e29ae383d5f4af4bdcccf /src
parent152589e302a18f8db4e3690341e9e764cd16971c (diff)
downloadlilv-f317e39966f709a68ecdb2355cb39c23abc535c8.tar.gz
lilv-f317e39966f709a68ecdb2355cb39c23abc535c8.tar.bz2
lilv-f317e39966f709a68ecdb2355cb39c23abc535c8.zip
Clean up i18n code
Diffstat (limited to 'src')
-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),