forked from github/server
apply USE_LIBXML consistently, so tests can be built without libxml2
This commit is contained in:
parent
a10ccac64b
commit
3dda5d3033
|
@ -68,8 +68,6 @@ without prior permission by the authors of Eressea.
|
||||||
#include <util/nrmessage.h>
|
#include <util/nrmessage.h>
|
||||||
#include <quicklist.h>
|
#include <quicklist.h>
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1470,7 +1468,6 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
#if SCORE_MODULE
|
#if SCORE_MODULE
|
||||||
int score = 0, avgscore = 0;
|
int score = 0, avgscore = 0;
|
||||||
#endif
|
#endif
|
||||||
int enc = xmlParseCharEncoding(charset);
|
|
||||||
FILE *F = fopen(filename, "wt");
|
FILE *F = fopen(filename, "wt");
|
||||||
|
|
||||||
if (era < 0) {
|
if (era < 0) {
|
||||||
|
@ -1479,7 +1476,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
if (F == NULL) {
|
if (F == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
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 };
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,14 +59,13 @@
|
||||||
#include <util/console.h>
|
#include <util/console.h>
|
||||||
#include <util/listbox.h>
|
#include <util/listbox.h>
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
|
||||||
|
|
||||||
#include <storage.h>
|
#include <storage.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static int g_quit;
|
static int g_quit;
|
||||||
int force_color = 0;
|
int force_color = 0;
|
||||||
|
|
|
@ -58,8 +58,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <critbit.h>
|
#include <critbit.h>
|
||||||
#include <util/crmessage.h>
|
#include <util/crmessage.h>
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/functions.h>
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
#include <util/filereader.h>
|
||||||
|
#include <util/functions.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
#include <util/parser.h>
|
#include <util/parser.h>
|
||||||
|
@ -72,9 +73,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/umlaut.h>
|
#include <util/umlaut.h>
|
||||||
#include <util/xml.h>
|
#include <util/xml.h>
|
||||||
|
|
||||||
|
#ifdef USE_LIBXML2
|
||||||
/* libxml includes */
|
/* libxml includes */
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxml/xpath.h>
|
#include <libxml/xpath.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* external libraries */
|
/* external libraries */
|
||||||
#include <iniparser.h>
|
#include <iniparser.h>
|
||||||
|
@ -3139,8 +3142,9 @@ void load_inifile(dictionary * d)
|
||||||
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
|
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
|
||||||
|
|
||||||
str = iniparser_getstring(d, "eressea:encoding", NULL);
|
str = iniparser_getstring(d, "eressea:encoding", NULL);
|
||||||
if (str)
|
if (str && (_strcmpl(str, "utf8")==0 || _strcmpl(str, "utf-8")==0)) {
|
||||||
enc_gamedata = xmlParseCharEncoding(str);
|
enc_gamedata = ENCODING_UTF8;
|
||||||
|
}
|
||||||
|
|
||||||
verbosity = iniparser_getint(d, "eressea:verbose", 2);
|
verbosity = iniparser_getint(d, "eressea:verbose", 2);
|
||||||
sqlpatch = iniparser_getint(d, "eressea:sqlpatch", false);
|
sqlpatch = iniparser_getint(d, "eressea:sqlpatch", false);
|
||||||
|
|
|
@ -73,8 +73,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <storage.h>
|
#include <storage.h>
|
||||||
#include <binarystore.h>
|
#include <binarystore.h>
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -92,7 +90,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* exported symbols symbols */
|
/* exported symbols symbols */
|
||||||
const char *game_name = "eressea";
|
const char *game_name = "eressea";
|
||||||
int firstx = 0, firsty = 0;
|
int firstx = 0, firsty = 0;
|
||||||
int enc_gamedata = XML_CHAR_ENCODING_UTF8;
|
int enc_gamedata = ENCODING_UTF8;
|
||||||
|
|
||||||
/* local symbols */
|
/* local symbols */
|
||||||
static region *current_region;
|
static region *current_region;
|
||||||
|
|
11
src/report.c
11
src/report.c
|
@ -82,8 +82,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <quicklist.h>
|
#include <quicklist.h>
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1472,15 +1470,14 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
char buf[8192], *bufp;
|
char buf[8192], *bufp;
|
||||||
size_t size;
|
size_t size;
|
||||||
int bytes;
|
int bytes;
|
||||||
|
bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0;
|
||||||
int enc = xmlParseCharEncoding(charset);
|
|
||||||
|
|
||||||
if (F == NULL) {
|
if (F == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enc == XML_CHAR_ENCODING_UTF8) {
|
if (utf8) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
@ -2106,7 +2103,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
seen_region *sr = NULL;
|
seen_region *sr = NULL;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
char *bufp;
|
char *bufp;
|
||||||
int enc = xmlParseCharEncoding(charset);
|
bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
/* static variables can cope with writing for different turns */
|
/* static variables can cope with writing for different turns */
|
||||||
|
@ -2126,7 +2123,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (enc == XML_CHAR_ENCODING_UTF8) {
|
if (utf8) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/unicode.h>
|
#include <util/unicode.h>
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
|
||||||
|
@ -322,7 +320,7 @@ static const char *getbuf_utf8(FILE * F)
|
||||||
|
|
||||||
const char *getbuf(FILE * F, int encoding)
|
const char *getbuf(FILE * F, int encoding)
|
||||||
{
|
{
|
||||||
if (encoding == XML_CHAR_ENCODING_UTF8)
|
if (encoding == ENCODING_UTF8)
|
||||||
return getbuf_utf8(F);
|
return getbuf_utf8(F);
|
||||||
return getbuf_latin1(F);
|
return getbuf_latin1(F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ENCODING_UTF8 0
|
||||||
|
#define ENCODING_LATIN1 1
|
||||||
|
|
||||||
const char *getbuf(FILE *, int encoding);
|
const char *getbuf(FILE *, int encoding);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
#ifdef USE_LIBXML2
|
||||||
#include <libxml/catalog.h>
|
#include <libxml/catalog.h>
|
||||||
#include <libxml/xmlstring.h>
|
#include <libxml/xmlstring.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -25,6 +27,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef USE_LIBXML2
|
||||||
const xmlChar *xml_i(double number)
|
const xmlChar *xml_i(double number)
|
||||||
{
|
{
|
||||||
static char buffer[128];
|
static char buffer[128];
|
||||||
|
@ -85,7 +88,6 @@ double xml_fvalue(xmlNodePtr node, const char *name, double dflt)
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/xinclude.h>
|
#include <libxml/xinclude.h>
|
||||||
|
|
||||||
#ifdef USE_LIBXML2
|
|
||||||
typedef struct xml_reader {
|
typedef struct xml_reader {
|
||||||
struct xml_reader *next;
|
struct xml_reader *next;
|
||||||
xml_callback callback;
|
xml_callback callback;
|
||||||
|
|
Loading…
Reference in New Issue