summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2021-03-16 17:40:45 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2021-03-16 17:40:45 (EDT)
commit4bb88b24696e222bf2729bbf68f113f2fcf635f2 (patch)
tree287ceeeed8e64d958afc065ecd9fca9c8662a32d
parent4945cedb57edd76f4a53d57437d486daa7c26662 (diff)
downloaddodge-balls-4bb88b24696e222bf2729bbf68f113f2fcf635f2.zip
dodge-balls-4bb88b24696e222bf2729bbf68f113f2fcf635f2.tar.gz
dodge-balls-4bb88b24696e222bf2729bbf68f113f2fcf635f2.tar.bz2
db_games_find(): Support multiline XML char data
-rw-r--r--src/game.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/game.c b/src/game.c
index 3eea396..29168cd 100644
--- a/src/game.c
+++ b/src/game.c
@@ -77,6 +77,7 @@ _db_game_xml_cdata(void *pv, const char *s, int len)
char *s_z;
char *s_z_trimmed;
char *s_z_trimmed_end;
+ char *old_data;
db_dbg( "[CDATA]");
@@ -95,6 +96,7 @@ _db_game_xml_cdata(void *pv, const char *s, int len)
--len;
}
if (*s_z_trimmed == '\0') {
+ free(s_z);
return;
}
s_z_trimmed_end = s_z_trimmed + len - 1;
@@ -103,7 +105,13 @@ _db_game_xml_cdata(void *pv, const char *s, int len)
}
*(s_z_trimmed_end + 1) = '\0';
- *data = strdup(s_z_trimmed);
+ if (*data != NULL && **data != '\0') {
+ old_data = *data;
+ sprintf(*data, "%s %s", *data, strdup(s_z_trimmed));
+ free(old_data);
+ } else {
+ *data = strdup(s_z_trimmed);
+ }
free(s_z);
}