diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-03-17 06:28:44 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-03-17 06:28:44 (EDT) |
commit | fc436f15ee166fc4e2f967b8ff725cf6f0e3a782 (patch) | |
tree | d18aff1171672e52eb6e0b169e2a450b58354f0d | |
parent | b93b018af83ea02d89d2aaecdc34d62be9dc0a39 (diff) | |
download | dodge-balls-fc436f15ee166fc4e2f967b8ff725cf6f0e3a782.zip dodge-balls-fc436f15ee166fc4e2f967b8ff725cf6f0e3a782.tar.gz dodge-balls-fc436f15ee166fc4e2f967b8ff725cf6f0e3a782.tar.bz2 |
db_games_find(): Use db_locale_match()
-rw-r--r-- | src/game.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -29,6 +29,8 @@ struct db_game { char *id; + int best_name_match; + int best_desc_match; char *name; char *desc; enum { @@ -215,7 +217,6 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) XML_Parser p; struct db_game *game; char *lang; - char *lc_messages; db_dbg(" <%s> (game child)", name); @@ -228,10 +229,8 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) if (lang == NULL) { return; } - lc_messages = strdup(db_lc_messages_get()); - db_dbg(" lang=\"%s\" (looking for \"%s\")", - lang, lc_messages); - if (strcasecmp(lang, lc_messages) == 0) { + db_dbg(" lang=\"%s\"", lang); + if (db_locale_match(lang) > game->best_name_match) { goto name_ok; } db_xml_node_push(p, game, _db_game_xml_invalid_start, @@ -245,17 +244,14 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) _db_game_xml_cdata); name_err: free(lang); - free(lc_messages); } else if (db_xml_check_tag(name, "description")) { lang = NULL; db_xml_get_string_attr(p, attr, "lang", &lang, 1); if (lang == NULL) { return; } - lc_messages = strdup(db_lc_messages_get()); - db_dbg(" lang=\"%s\" (looking for \"%s\")", - lang, lc_messages); - if (strcasecmp(lang, lc_messages) == 0) { + db_dbg(" lang=\"%s\"", lang); + if (db_locale_match(lang) > game->best_desc_match) { goto desc_ok; } db_xml_node_push(p, game, _db_game_xml_invalid_start, @@ -269,7 +265,6 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) _db_game_xml_cdata); desc_err: free(lang); - free(lc_messages); } else if (db_xml_check_tag(name, "levels")) { db_xml_node_push(p, game, _db_game_xml_levels_el_start, _db_game_xml_levels_end, NULL); |