work around GCC's wide string constant bug

svn path=/trunk/; revision=11007
This commit is contained in:
Martin Fuchs 2004-09-23 18:37:57 +00:00
parent 51c36121e9
commit c39da650dd
3 changed files with 31 additions and 14 deletions

View file

@ -45,7 +45,7 @@ CFG=make_explorer - Win32 bjam
# PROP Use_Debug_Libraries 0 # PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release" # PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Cmd_Line "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0" # PROP Cmd_Line "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.PCH UNICODE=0"
# PROP Rebuild_Opt "clean all" # PROP Rebuild_Opt "clean all"
# PROP Target_File "explorer.exe" # PROP Target_File "explorer.exe"
# PROP Bsc_Name "" # PROP Bsc_Name ""
@ -66,7 +66,7 @@ CFG=make_explorer - Win32 bjam
# PROP Use_Debug_Libraries 1 # PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug" # PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Cmd_Line "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0 DEBUG=1" # PROP Cmd_Line "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.PCH UNICODE=0 DEBUG=1"
# PROP Rebuild_Opt "clean all" # PROP Rebuild_Opt "clean all"
# PROP Target_File "explorer.exe" # PROP Target_File "explorer.exe"
# PROP Bsc_Name "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0 DEBUG=1" # PROP Bsc_Name "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0 DEBUG=1"

View file

@ -40,6 +40,14 @@
#include "precomp.h" #include "precomp.h"
// work around GCC's wide string constant bug
#ifdef __GNUC__
const LPCXSSTR XMLStorage::XS_TRUE = XS_TEXT("true");
const LPCXSSTR XMLStorage::XS_FALSE = XS_TEXT("false");
const LPCXSSTR XMLStorage::XS_NUMBERFMT = XS_TEXT("%d");
#endif
namespace XMLStorage { namespace XMLStorage {

View file

@ -51,6 +51,7 @@
#ifdef UNICODE #ifdef UNICODE
#define _UNICODE #define _UNICODE
#endif #endif
#include <tchar.h> #include <tchar.h>
#include <malloc.h> #include <malloc.h>
@ -72,10 +73,6 @@ namespace XMLStorage {
#ifndef XS_String #ifndef XS_String
#ifdef __GNUC__
#define XS_STRING_UTF8 // The W32API std::wstring implementation of stdlibc++ is unusable, so use UTF8 encoded strings with std::string instead
#endif
#ifdef XS_STRING_UTF8 #ifdef XS_STRING_UTF8
#define XS_CHAR char #define XS_CHAR char
#define XS_TEXT(x) x #define XS_TEXT(x) x
@ -1197,6 +1194,18 @@ protected:
}; };
// work around GCC's wide string constant bug
#ifdef __GNUC__
extern const LPCXSSTR XS_TRUE;
extern const LPCXSSTR XS_FALSE;
extern const LPCXSSTR XS_NUMBERFMT;
#else
#define XS_TRUE XS_TEXT("true")
#define XS_FALSE XS_TEXT("false")
#define XS_NUMBERFMT XS_TEXT("%d")
#endif
struct XMLBool struct XMLBool
{ {
XMLBool(bool value=false) XMLBool(bool value=false)
@ -1207,7 +1216,7 @@ struct XMLBool
XMLBool(LPCXSSTR value, bool def=false) XMLBool(LPCXSSTR value, bool def=false)
{ {
if (value && *value) if (value && *value)
_value = !XS_icmp(value, XS_TEXT("true")); _value = !XS_icmp(value, XS_TRUE);
else else
_value = def; _value = def;
} }
@ -1217,7 +1226,7 @@ struct XMLBool
const XS_String& value = node->get(attr_name); const XS_String& value = node->get(attr_name);
if (!value.empty()) if (!value.empty())
_value = !XS_icmp(value.c_str(), XS_TEXT("true")); _value = !XS_icmp(value.c_str(), XS_TRUE);
else else
_value = def; _value = def;
} }
@ -1234,7 +1243,7 @@ struct XMLBool
operator LPCXSSTR() const operator LPCXSSTR() const
{ {
return _value? XS_TEXT("true"): XS_TEXT("false"); return _value? XS_TRUE: XS_FALSE;
} }
protected: protected:
@ -1255,12 +1264,12 @@ struct XMLBoolRef
operator bool() const operator bool() const
{ {
return !XS_icmp(_ref.c_str(), XS_TEXT("true")); return !XS_icmp(_ref.c_str(), XS_TRUE);
} }
bool operator!() const bool operator!() const
{ {
return XS_icmp(_ref.c_str(), XS_TEXT("true"))? true: false; return XS_icmp(_ref.c_str(), XS_TRUE)? true: false;
} }
XMLBoolRef& operator=(bool value) XMLBoolRef& operator=(bool value)
@ -1272,7 +1281,7 @@ struct XMLBoolRef
void assign(bool value) void assign(bool value)
{ {
_ref.assign(value? XS_TEXT("true"): XS_TEXT("false")); _ref.assign(value? XS_TRUE: XS_FALSE);
} }
void toggle() void toggle()
@ -1318,7 +1327,7 @@ struct XMLInt
operator XS_String() const operator XS_String() const
{ {
XS_CHAR buffer[32]; XS_CHAR buffer[32];
XS_sprintf(buffer, XS_TEXT("%d"), _value); XS_sprintf(buffer, XS_NUMBERFMT, _value);
return buffer; return buffer;
} }
@ -1353,7 +1362,7 @@ struct XMLIntRef
void assign(int value) void assign(int value)
{ {
XS_CHAR buffer[32]; XS_CHAR buffer[32];
XS_sprintf(buffer, XS_TEXT("%d"), value); XS_sprintf(buffer, XS_NUMBERFMT, value);
_ref.assign(buffer); _ref.assign(buffer);
} }