1
0
forked from 0ad/0ad

Linux/GCC compat

This was SVN commit r685.
This commit is contained in:
Simon Brenner 2004-07-10 18:57:13 +00:00
parent cdd3317ded
commit 027d18a8b5
4 changed files with 19 additions and 13 deletions

View File

@ -1,4 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
#include <wctype.h>
#include "CConsole.h" #include "CConsole.h"

View File

@ -1,5 +1,8 @@
#include "precompiled.h" #include "precompiled.h"
#ifdef _WIN32
#include "sysdep/win/win_internal.h" #include "sysdep/win/win_internal.h"
#endif
#include "Network.h" #include "Network.h"
#include "NetworkInternal.h" #include "NetworkInternal.h"

View File

@ -1,4 +1,4 @@
// $Id: Xeromyces.cpp,v 1.2 2004/07/09 19:59:19 janwas Exp $ // $Id: Xeromyces.cpp,v 1.3 2004/07/10 18:57:13 olsner Exp $
#include "precompiled.h" #include "precompiled.h"
@ -55,14 +55,14 @@ public:
free(buffer); free(buffer);
} }
void write(void* data, int size) void write(const void* data, int size)
{ {
while (length + size >= allocated) grow(); while (length + size >= allocated) grow();
memcpy(&buffer[length], data, size); memcpy(&buffer[length], data, size);
length += size; length += size;
} }
void write(void* data, int size, int offset) void write(const void* data, int size, int offset)
{ {
assert(offset >= 0 && offset+size <= length); assert(offset >= 0 && offset+size <= length);
memcpy(&buffer[offset], data, size); memcpy(&buffer[offset], data, size);
@ -220,8 +220,8 @@ void CXeromyces::Load(const char* filename)
SAX2XMLReader* Parser = XMLReaderFactory::createXMLReader(); SAX2XMLReader* Parser = XMLReaderFactory::createXMLReader();
// Enable validation // Enable validation
Parser->setFeature(L"http://xml.org/sax/features/validation", true); Parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
Parser->setFeature(L"http://apache.org/xml/features/validation/dynamic", true); Parser->setFeature(XMLUni::fgXercesDynamic, true);
XeroHandler handler; XeroHandler handler;
Parser->setContentHandler(&handler); Parser->setContentHandler(&handler);
@ -309,11 +309,12 @@ void XeroHandler::endDocument()
{ {
} }
std::wstring lowercase(std::wstring a) std::wstring lowercase(const XMLCh *a)
{ {
std::wstring b; std::wstring b;
b.resize(a.length()); uint len=XMLString::stringLen(a);
for (size_t i = 0; i < a.length(); ++i) b.resize(len);
for (uint i = 0; i < len; ++i)
b[i] = towlower(a[i]); b[i] = towlower(a[i]);
return b; return b;
} }
@ -334,7 +335,8 @@ void XeroHandler::startElement(const XMLCh* const uri, const XMLCh* const localn
AttributeNames.insert(attrName); AttributeNames.insert(attrName);
XMLAttribute* a = new XMLAttribute; XMLAttribute* a = new XMLAttribute;
a->name = attrName; a->name = attrName;
a->value = attrs.getValue(i); const XMLCh *tmp = attrs.getValue(i);
a->value = std::wstring(tmp, tmp+XMLString::stringLen(tmp));
e->attrs.push_back(a); e->attrs.push_back(a);
} }
@ -352,7 +354,7 @@ void XeroHandler::endElement(const XMLCh* const uri, const XMLCh* const localnam
void XeroHandler::characters(const XMLCh* const chars, const unsigned int length) void XeroHandler::characters(const XMLCh* const chars, const unsigned int length)
{ {
ElementStack.top()->text += chars; ElementStack.top()->text += std::wstring(chars, chars+XMLString::stringLen(chars));
} }
@ -460,4 +462,4 @@ void XeroHandler::OutputElement(XMLElement* el)
// Tidy up the parser's mess // Tidy up the parser's mess
delete el; delete el;
} }

View File

@ -1,4 +1,4 @@
/* $Id: Xeromyces.h,v 1.1 2004/07/08 15:21:42 philip Exp $ /* $Id: Xeromyces.h,v 1.2 2004/07/10 18:57:13 olsner Exp $
Xeromyces file-loading interface. Xeromyces file-loading interface.
Automatically creates and caches relatively Automatically creates and caches relatively
@ -43,4 +43,4 @@ private:
}; };
#endif // _XEROMYCES_H_ #endif // _XEROMYCES_H_