diff --git a/src/creport.c b/src/creport.c index 20f3130d1..338cfe156 100644 --- a/src/creport.c +++ b/src/creport.c @@ -68,8 +68,6 @@ without prior permission by the authors of Eressea. #include #include -#include - /* libc includes */ #include #include @@ -1470,7 +1468,6 @@ report_computer(const char *filename, report_context * ctx, const char *charset) #if SCORE_MODULE int score = 0, avgscore = 0; #endif - int enc = xmlParseCharEncoding(charset); FILE *F = fopen(filename, "wt"); if (era < 0) { @@ -1479,7 +1476,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset) if (F == NULL) { perror(filename); return -1; - } else if (enc == XML_CHAR_ENCODING_UTF8) { + } else if (_strcmpl(charset, "utf-8")==0 || _strcmpl(charset, "utf8")==0) { const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } diff --git a/src/gmtool.c b/src/gmtool.c index 26d913872..df76b6965 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -59,14 +59,13 @@ #include #include -#include - #include #include #include -#include #include +#include +#include static int g_quit; int force_color = 0; diff --git a/src/kernel/config.c b/src/kernel/config.c index 9a5d8655e..9b9af1f62 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -58,8 +58,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include +#include +#include #include #include #include @@ -72,9 +73,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#ifdef USE_LIBXML2 /* libxml includes */ #include #include +#endif /* external libraries */ #include @@ -3139,8 +3142,9 @@ void load_inifile(dictionary * d) lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; str = iniparser_getstring(d, "eressea:encoding", NULL); - if (str) - enc_gamedata = xmlParseCharEncoding(str); + if (str && (_strcmpl(str, "utf8")==0 || _strcmpl(str, "utf-8")==0)) { + enc_gamedata = ENCODING_UTF8; + } verbosity = iniparser_getint(d, "eressea:verbose", 2); sqlpatch = iniparser_getint(d, "eressea:sqlpatch", false); diff --git a/src/kernel/save.c b/src/kernel/save.c index f31c60e2b..5bc26a84c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -73,8 +73,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include - /* libc includes */ #include #include @@ -92,7 +90,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* exported symbols symbols */ const char *game_name = "eressea"; int firstx = 0, firsty = 0; -int enc_gamedata = XML_CHAR_ENCODING_UTF8; +int enc_gamedata = ENCODING_UTF8; /* local symbols */ static region *current_region; diff --git a/src/report.c b/src/report.c index 3e87dc98c..10a35b3cb 100644 --- a/src/report.c +++ b/src/report.c @@ -82,8 +82,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#include - /* libc includes */ #include #include @@ -1472,15 +1470,14 @@ report_template(const char *filename, report_context * ctx, const char *charset) char buf[8192], *bufp; size_t size; int bytes; - - int enc = xmlParseCharEncoding(charset); + bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0; if (F == NULL) { perror(filename); return -1; } - if (enc == XML_CHAR_ENCODING_UTF8) { + if (utf8) { const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } @@ -2106,7 +2103,7 @@ report_plaintext(const char *filename, report_context * ctx, seen_region *sr = NULL; char buf[8192]; char *bufp; - int enc = xmlParseCharEncoding(charset); + bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0; size_t size; /* static variables can cope with writing for different turns */ @@ -2126,7 +2123,7 @@ report_plaintext(const char *filename, report_context * ctx, perror(filename); return -1; } - if (enc == XML_CHAR_ENCODING_UTF8) { + if (utf8) { const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } diff --git a/src/util/filereader.c b/src/util/filereader.c index 12ef3add4..2a49b7bdd 100644 --- a/src/util/filereader.c +++ b/src/util/filereader.c @@ -4,8 +4,6 @@ #include #include -#include - #include #include @@ -322,7 +320,7 @@ static const char *getbuf_utf8(FILE * F) const char *getbuf(FILE * F, int encoding) { - if (encoding == XML_CHAR_ENCODING_UTF8) + if (encoding == ENCODING_UTF8) return getbuf_utf8(F); return getbuf_latin1(F); } diff --git a/src/util/filereader.h b/src/util/filereader.h index 9637c1394..116e2341a 100644 --- a/src/util/filereader.h +++ b/src/util/filereader.h @@ -15,6 +15,9 @@ extern "C" { #endif +#define ENCODING_UTF8 0 +#define ENCODING_LATIN1 1 + const char *getbuf(FILE *, int encoding); #ifdef __cplusplus diff --git a/src/util/xml.c b/src/util/xml.c index b55836e5a..b4f7dadac 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -15,8 +15,10 @@ /* util includes */ #include "log.h" +#ifdef USE_LIBXML2 #include #include +#endif /* libc includes */ #include @@ -25,6 +27,7 @@ #include #include +#ifdef USE_LIBXML2 const xmlChar *xml_i(double number) { static char buffer[128]; @@ -85,7 +88,6 @@ double xml_fvalue(xmlNodePtr node, const char *name, double dflt) #include #include -#ifdef USE_LIBXML2 typedef struct xml_reader { struct xml_reader *next; xml_callback callback;