eliminating iconv in favor of the encoding in libxml2

This commit is contained in:
Enno Rehling 2006-02-09 22:43:31 +00:00
parent 589b1b036a
commit 102a68f01e
7 changed files with 26 additions and 53 deletions

View File

@ -81,24 +81,17 @@
#define L10N(x) x
#ifdef USE_ICONV
static iconv_t utf8;
#endif
static xmlChar*
xml_s(const char * str)
{
static char buffer[1024];
static xmlChar buffer[1024];
const char * inbuf = str;
char * outbuf = buffer;
size_t inbytes = strlen(str)+1;
size_t outbytes = sizeof(buffer);
#ifdef USE_ICONV
iconv(utf8, (char**)&inbuf, &inbytes, (char**)&outbuf, &outbytes);
#else
isolat1ToUTF8(outbuf, &outbytes, inbuf, &inbytes);
#endif
return (xmlChar*)buffer;
xmlChar * outbuf = buffer;
int inbytes = (int)strlen(str)+1;
int outbytes = (int)sizeof(buffer);
isolat1ToUTF8(outbuf, &outbytes, BAD_CAST inbuf, &inbytes);
return buffer;
}
static xmlChar*

View File

@ -38,9 +38,6 @@ without prior permission by the authors of Eressea.
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/encoding.h>
#ifdef USE_ICONV
#include <iconv.h>
#endif
/* libc includes */
#include <assert.h>
@ -85,27 +82,13 @@ static const char *
xml_to_locale(const xmlChar * xmlStr)
{
static char zText[1024];
char * inbuf = (char*)xmlStr;
const xmlChar * inbuf = xmlStr;
char * outbuf = zText;
size_t inbytes = strlen((const char*)xmlStr)+1;
size_t outbytes = sizeof(zText);
#ifdef USE_ICONV
static iconv_t context = (iconv_t)-1;
int inbytes = (int)strlen((const char*)xmlStr)+1;
int outbytes = (int)sizeof(zText);
if (context==(iconv_t)-1) {
context = iconv_open("", "UTF-8");
}
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));
if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) {
log_error(("string is too long: %s.\n", (const char*)xmlStr));
}
return zText;
}

View File

@ -37,12 +37,10 @@ LinkLibraries $(SERVER) :
LinkLibraries $(LUASERVER) :
gamecode kernel items modules attributes spells races triggers util ;
iconv $(SERVER) ;
libxml2 $(SERVER) ;
LINKLIBS on $(SERVER) += -L$(LUABIND_ROOT)/lib -lm ;
luabind $(LUASERVER) ;
iconv $(LUASERVER) ;
libxml2 $(LUASERVER) ;
LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ ;

View File

@ -44,7 +44,7 @@
<Tool
Name="VCLinkerTool"
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"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -108,7 +108,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib iconv.lib"
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
OutputFile=".\Profile/eressea-lua.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -175,7 +175,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib iconv.lib"
AdditionalDependencies="luabind.lib lua50.lib libxml2.lib"
OutputFile=".\Debug/eressea-lua.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@ -238,7 +238,7 @@
<Tool
Name="VCLinkerTool"
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"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -301,7 +301,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="luabindd.lib lua50.lib libxml2.lib iconv.lib"
AdditionalDependencies="luabindd.lib lua50.lib libxml2.lib"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
IgnoreDefaultLibraryNames="libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib"

View File

@ -44,7 +44,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libxml2.lib iconv.lib"
AdditionalDependencies="libxml2.lib"
OutputFile=".\Release/eressea.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -108,7 +108,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libxml2.lib iconv.lib"
AdditionalDependencies="libxml2.lib"
OutputFile=".\Profile/eressea.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -172,7 +172,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libxml2.lib iconv.lib"
AdditionalDependencies="libxml2.lib"
OutputFile=".\Debug/eressea.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@ -234,7 +234,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:AMD64"
AdditionalDependencies="libxml2.lib iconv.lib"
AdditionalDependencies="libxml2.lib"
OutputFile=".\Release/eressea.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

View File

@ -31,6 +31,5 @@ LinkLibraries mapper :
triggers
util ;
iconv mapper ;
libxml2 mapper ;
LINKLIBS on mapper += -L$(LUABIND_ROOT)/lib -lm -lncurses ;

View File

@ -41,7 +41,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
AdditionalDependencies="curses.lib libxml2.lib"
OutputFile=".\Release/mapper.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -106,7 +106,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
AdditionalDependencies="curses.lib libxml2.lib"
OutputFile=".\Debug/mapper.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@ -169,7 +169,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
AdditionalDependencies="curses.lib libxml2.lib"
OutputFile=".\Release/mapper.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -230,7 +230,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:AMD64"
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
AdditionalDependencies="curses.lib libxml2.lib"
OutputFile=".\Release/mapper.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@ -291,7 +291,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="curses.lib libxml2.lib iconv.lib"
AdditionalDependencies="curses.lib libxml2.lib"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories=""