forked from github/server
eliminating iconv in favor of the encoding in libxml2
This commit is contained in:
parent
589b1b036a
commit
102a68f01e
|
@ -81,24 +81,17 @@
|
||||||
|
|
||||||
#define L10N(x) x
|
#define L10N(x) x
|
||||||
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
static iconv_t utf8;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static xmlChar*
|
static xmlChar*
|
||||||
xml_s(const char * str)
|
xml_s(const char * str)
|
||||||
{
|
{
|
||||||
static char buffer[1024];
|
static xmlChar buffer[1024];
|
||||||
const char * inbuf = str;
|
const char * inbuf = str;
|
||||||
char * outbuf = buffer;
|
xmlChar * outbuf = buffer;
|
||||||
size_t inbytes = strlen(str)+1;
|
int inbytes = (int)strlen(str)+1;
|
||||||
size_t outbytes = sizeof(buffer);
|
int outbytes = (int)sizeof(buffer);
|
||||||
#ifdef USE_ICONV
|
|
||||||
iconv(utf8, (char**)&inbuf, &inbytes, (char**)&outbuf, &outbytes);
|
isolat1ToUTF8(outbuf, &outbytes, BAD_CAST inbuf, &inbytes);
|
||||||
#else
|
return buffer;
|
||||||
isolat1ToUTF8(outbuf, &outbytes, inbuf, &inbytes);
|
|
||||||
#endif
|
|
||||||
return (xmlChar*)buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static xmlChar*
|
static xmlChar*
|
||||||
|
|
|
@ -38,9 +38,6 @@ without prior permission by the authors of Eressea.
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxml/xpath.h>
|
#include <libxml/xpath.h>
|
||||||
#include <libxml/encoding.h>
|
#include <libxml/encoding.h>
|
||||||
#ifdef USE_ICONV
|
|
||||||
#include <iconv.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -85,27 +82,13 @@ static const char *
|
||||||
xml_to_locale(const xmlChar * xmlStr)
|
xml_to_locale(const xmlChar * xmlStr)
|
||||||
{
|
{
|
||||||
static char zText[1024];
|
static char zText[1024];
|
||||||
char * inbuf = (char*)xmlStr;
|
const xmlChar * inbuf = xmlStr;
|
||||||
char * outbuf = zText;
|
char * outbuf = zText;
|
||||||
size_t inbytes = strlen((const char*)xmlStr)+1;
|
int inbytes = (int)strlen((const char*)xmlStr)+1;
|
||||||
size_t outbytes = sizeof(zText);
|
int outbytes = (int)sizeof(zText);
|
||||||
#ifdef USE_ICONV
|
|
||||||
static iconv_t context = (iconv_t)-1;
|
|
||||||
|
|
||||||
if (context==(iconv_t)-1) {
|
if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) {
|
||||||
context = iconv_open("", "UTF-8");
|
log_error(("string is too long: %s.\n", (const char*)xmlStr));
|
||||||
}
|
|
||||||
assert(context!=(iconv_t)-1);
|
|
||||||
|
|
||||||
iconv(context, &inbuf, &inbytes, &outbuf, &outbytes);
|
|
||||||
#else
|
|
||||||
size_t insize = inbytes;
|
|
||||||
if (UTF8Toisolat1(outbuf, &outbytes, inbuf, &inbytes)>=0) {
|
|
||||||
inbytes -= insize;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (inbytes!=0) {
|
|
||||||
log_error(("string is too long: %d chars remain in %s.\n", inbytes, (const char*)xmlStr));
|
|
||||||
}
|
}
|
||||||
return zText;
|
return zText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,10 @@ LinkLibraries $(SERVER) :
|
||||||
LinkLibraries $(LUASERVER) :
|
LinkLibraries $(LUASERVER) :
|
||||||
gamecode kernel items modules attributes spells races triggers util ;
|
gamecode kernel items modules attributes spells races triggers util ;
|
||||||
|
|
||||||
iconv $(SERVER) ;
|
|
||||||
libxml2 $(SERVER) ;
|
libxml2 $(SERVER) ;
|
||||||
LINKLIBS on $(SERVER) += -L$(LUABIND_ROOT)/lib -lm ;
|
LINKLIBS on $(SERVER) += -L$(LUABIND_ROOT)/lib -lm ;
|
||||||
|
|
||||||
luabind $(LUASERVER) ;
|
luabind $(LUASERVER) ;
|
||||||
iconv $(LUASERVER) ;
|
|
||||||
libxml2 $(LUASERVER) ;
|
libxml2 $(LUASERVER) ;
|
||||||
LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ ;
|
LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ ;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386 /FIXED:NO"
|
AdditionalOptions="/MACHINE:I386 /FIXED:NO"
|
||||||
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
|
||||||
OutputFile=".\Release/eressea-lua.exe"
|
OutputFile=".\Release/eressea-lua.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
|
||||||
OutputFile=".\Profile/eressea-lua.exe"
|
OutputFile=".\Profile/eressea-lua.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
|
||||||
OutputFile=".\Debug/eressea-lua.exe"
|
OutputFile=".\Debug/eressea-lua.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:AMD64 /FIXED:NO"
|
AdditionalOptions="/MACHINE:AMD64 /FIXED:NO"
|
||||||
AdditionalDependencies="luabind.lib lua50.lib lualib50.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
|
||||||
OutputFile=".\Release/eressea-lua.exe"
|
OutputFile=".\Release/eressea-lua.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="luabindd.lib lua50.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="luabindd.lib lua50.lib libxml2.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
IgnoreDefaultLibraryNames="libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib"
|
IgnoreDefaultLibraryNames="libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib"
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="libxml2.lib iconv.lib"
|
AdditionalDependencies="libxml2.lib"
|
||||||
OutputFile=".\Release/eressea.exe"
|
OutputFile=".\Release/eressea.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="libxml2.lib iconv.lib"
|
AdditionalDependencies="libxml2.lib"
|
||||||
OutputFile=".\Profile/eressea.exe"
|
OutputFile=".\Profile/eressea.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="libxml2.lib iconv.lib"
|
AdditionalDependencies="libxml2.lib"
|
||||||
OutputFile=".\Debug/eressea.exe"
|
OutputFile=".\Debug/eressea.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -234,7 +234,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:AMD64"
|
AdditionalOptions="/MACHINE:AMD64"
|
||||||
AdditionalDependencies="libxml2.lib iconv.lib"
|
AdditionalDependencies="libxml2.lib"
|
||||||
OutputFile=".\Release/eressea.exe"
|
OutputFile=".\Release/eressea.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
|
|
@ -31,6 +31,5 @@ LinkLibraries mapper :
|
||||||
triggers
|
triggers
|
||||||
util ;
|
util ;
|
||||||
|
|
||||||
iconv mapper ;
|
|
||||||
libxml2 mapper ;
|
libxml2 mapper ;
|
||||||
LINKLIBS on mapper += -L$(LUABIND_ROOT)/lib -lm -lncurses ;
|
LINKLIBS on mapper += -L$(LUABIND_ROOT)/lib -lm -lncurses ;
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="curses.lib libxml2.lib"
|
||||||
OutputFile=".\Release/mapper.exe"
|
OutputFile=".\Release/mapper.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="curses.lib libxml2.lib"
|
||||||
OutputFile=".\Debug/mapper.exe"
|
OutputFile=".\Debug/mapper.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="curses.lib libxml2.lib"
|
||||||
OutputFile=".\Release/mapper.exe"
|
OutputFile=".\Release/mapper.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -230,7 +230,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:AMD64"
|
AdditionalOptions="/MACHINE:AMD64"
|
||||||
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="curses.lib libxml2.lib"
|
||||||
OutputFile=".\Release/mapper.exe"
|
OutputFile=".\Release/mapper.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
|
@ -291,7 +291,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
|
AdditionalDependencies="curses.lib libxml2.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories=""
|
AdditionalLibraryDirectories=""
|
||||||
|
|
Loading…
Reference in New Issue