summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/game.c36
2 files changed, 31 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index d98283d..64384b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ funcs_missing=false
AC_CHECK_FUNCS(
[\
alphasort calloc dirname free isspace malloc printf putchar \
- realpath scandir sscanf strcmp strdup strndup vprintf
+ realpath scandir sscanf strcasecmp strcmp strdup strndup vprintf
],
[],
[funcs_missing=true])
diff --git a/src/game.c b/src/game.c
index 0103332..791abe7 100644
--- a/src/game.c
+++ b/src/game.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include "game.h"
+#include "locale.h"
#include "output.h"
#include "xml.h"
@@ -214,6 +215,7 @@ _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);
@@ -226,26 +228,48 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr)
if (lang == NULL) {
return;
}
- db_dbg(" lang=\"%s\"", lang);
+ lc_messages = strdup(db_lc_messages_get());
+ db_dbg(" lang=\"%s\" (looking for \"%s\")",
+ lang, lc_messages);
+ if (strcasecmp(lang, lc_messages) == 0) {
+ goto name_ok;
+ }
+ db_xml_node_push(p, game, _db_game_xml_invalid_start,
+ _db_game_xml_name_end,
+ NULL);
+ goto name_err;
+ name_ok:
game->xml_parsing = DB_GAME_XML_PARSING_NAME;
- /* TODO */
- free(lang);
db_xml_node_push(p, game, _db_game_xml_invalid_start,
_db_game_xml_name_end,
_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;
}
- db_dbg(" lang=\"%s\"", lang);
+ lc_messages = strdup(db_lc_messages_get());
+ db_dbg(" lang=\"%s\" (looking for \"%s\")",
+ lang, lc_messages);
+ if (strcasecmp(lang, lc_messages) == 0) {
+ goto desc_ok;
+ }
+ db_xml_node_push(p, game, _db_game_xml_invalid_start,
+ _db_game_xml_description_end,
+ NULL);
+ goto desc_err;
+ desc_ok:
game->xml_parsing = DB_GAME_XML_PARSING_DESCRIPTION;
- /* TODO */
- free(lang);
db_xml_node_push(p, game, _db_game_xml_invalid_start,
_db_game_xml_description_end,
_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);