1. made CRT wrappers definitions indepenent of wxUSE_UNICODE: both ANSI and Unicode variants are now defined

2. split wxcrt.h into wxcrtbase.h with lowlevel compiler-specific definitions and wxcrt.h with ANSI- and Unicode-compatible wx wrappers


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-06-10 17:14:14 +00:00
parent c475be6dfa
commit 52de37c78f
31 changed files with 1742 additions and 1643 deletions

View File

@@ -424,6 +424,7 @@ ALL_BASE_HEADERS = \
wx/wx.h \ wx/wx.h \
wx/wxchar.h \ wx/wxchar.h \
wx/wxcrt.h \ wx/wxcrt.h \
wx/wxcrtbase.h \
wx/wxcrtvararg.h \ wx/wxcrtvararg.h \
wx/wxprec.h \ wx/wxprec.h \
wx/xti.h \ wx/xti.h \
@@ -567,6 +568,7 @@ ALL_PORTS_BASE_HEADERS = \
wx/wx.h \ wx/wx.h \
wx/wxchar.h \ wx/wxchar.h \
wx/wxcrt.h \ wx/wxcrt.h \
wx/wxcrtbase.h \
wx/wxcrtvararg.h \ wx/wxcrtvararg.h \
wx/wxprec.h \ wx/wxprec.h \
wx/xti.h \ wx/xti.h \

View File

@@ -503,6 +503,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/wx.h wx/wx.h
wx/wxchar.h wx/wxchar.h
wx/wxcrt.h wx/wxcrt.h
wx/wxcrtbase.h
wx/wxcrtvararg.h wx/wxcrtvararg.h
wx/wxprec.h wx/wxprec.h
wx/xti.h wx/xti.h

View File

@@ -1903,6 +1903,10 @@ SOURCE=..\..\include\wx\wxcrt.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\include\wx\wxcrtbase.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\wxcrtvararg.h SOURCE=..\..\include\wx\wxcrtvararg.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -59,6 +59,9 @@ Changes in behaviour which may result in compilation errors
to const wxChar*: to const wxChar*:
wxLogError(_("error: %s"), !err.empty() ? (const wxChar*)err.c_str() : "") wxLogError(_("error: %s"), !err.empty() ? (const wxChar*)err.c_str() : "")
- wxCtime() and wxAsctime() return char*; this is incompatible with Unicode
build in wxWidgets 2.8 that returned wchar_t*.
- DigitalMars compiler has a bug that prevents it from using - DigitalMars compiler has a bug that prevents it from using
wxUniChar::operator bool in conditions and it erroneously reports type wxUniChar::operator bool in conditions and it erroneously reports type
conversion ambiguity in expressions such as this: conversion ambiguity in expressions such as this:

View File

@@ -13,17 +13,12 @@
#define _WX_BUFFER_H #define _WX_BUFFER_H
#include "wx/chartype.h" #include "wx/chartype.h"
#include "wx/wxcrt.h" #include "wx/wxcrtbase.h"
#include <stdlib.h> // malloc() and free() #include <stdlib.h> // malloc() and free()
class WXDLLIMPEXP_BASE wxCStrData; class WXDLLIMPEXP_BASE wxCStrData;
inline char *wxStrDup(const char *s) { return wxStrdupA(s); }
#if wxUSE_WCHAR_T
inline wchar_t *wxStrDup(const wchar_t *ws) { return wxStrdupW(ws); }
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Special classes for (wide) character strings: they use malloc/free instead // Special classes for (wide) character strings: they use malloc/free instead
// of new/delete // of new/delete
@@ -36,7 +31,7 @@ public:
typedef T CharType; typedef T CharType;
wxCharTypeBuffer(const CharType *str = NULL) wxCharTypeBuffer(const CharType *str = NULL)
: m_str(str ? wxStrDup(str) : NULL), : m_str(str ? wxStrdup(str) : NULL),
m_owned(true) m_owned(true)
{ {
} }
@@ -103,7 +98,7 @@ public:
{ {
if ( m_owned ) if ( m_owned )
free(m_str); free(m_str);
m_str = str ? wxStrDup(str) : NULL; m_str = str ? wxStrdup(str) : NULL;
m_owned = true; m_owned = true;
return *this; return *this;
} }

View File

@@ -95,6 +95,10 @@
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if defined(__VISUALC__) || defined(__DIGITALMARS__)
typedef int mode_t;
#endif
#ifdef __WXWINCE__ #ifdef __WXWINCE__
typedef long off_t; typedef long off_t;
#else #else
@@ -139,8 +143,8 @@ enum wxFileKind
#if defined( __WXWINCE__) #if defined( __WXWINCE__)
typedef __int64 wxFileOffset; typedef __int64 wxFileOffset;
#define wxFileOffsetFmtSpec _("I64") #define wxFileOffsetFmtSpec _("I64")
WXDLLIMPEXP_BASE int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode)); WXDLLIMPEXP_BASE int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode));
WXDLLIMPEXP_BASE int wxAccess(const wxChar *name, int WXUNUSED(how)); WXDLLIMPEXP_BASE int wxCRT_Access(const wxChar *name, int WXUNUSED(how));
WXDLLIMPEXP_BASE int wxClose(int fd); WXDLLIMPEXP_BASE int wxClose(int fd);
WXDLLIMPEXP_BASE int wxFsync(int WXUNUSED(fd)); WXDLLIMPEXP_BASE int wxFsync(int WXUNUSED(fd));
WXDLLIMPEXP_BASE int wxRead(int fd, void *buf, unsigned int count); WXDLLIMPEXP_BASE int wxRead(int fd, void *buf, unsigned int count);
@@ -151,9 +155,9 @@ enum wxFileKind
WXDLLIMPEXP_BASE wxFileOffset wxTell(int fd); WXDLLIMPEXP_BASE wxFileOffset wxTell(int fd);
// always Unicode under WinCE // always Unicode under WinCE
#define wxMkDir _wmkdir #define wxCRT_MkDir _wmkdir
#define wxRmDir _wrmdir #define wxCRT_RmDir _wrmdir
#define wxStat _wstat #define wxCRT_Stat _wstat
#define wxStructStat struct _stat #define wxStructStat struct _stat
#elif defined(__WXMSW__) && !defined(__WXPALMOS__) && \ #elif defined(__WXMSW__) && !defined(__WXPALMOS__) && \
( \ ( \
@@ -276,53 +280,53 @@ enum wxFileKind
wxPOSIX_STRUCT(stati64) *buffer); wxPOSIX_STRUCT(stati64) *buffer);
#endif // Windows compilers with MSLU support #endif // Windows compilers with MSLU support
#define wxOpen wxMSLU__wopen #define wxCRT_Open wxMSLU__wopen
#define wxAccess wxMSLU__waccess #define wxCRT_Access wxMSLU__waccess
#define wxMkDir wxMSLU__wmkdir #define wxCRT_MkDir wxMSLU__wmkdir
#define wxRmDir wxMSLU__wrmdir #define wxCRT_RmDir wxMSLU__wrmdir
#ifdef wxHAS_HUGE_FILES #ifdef wxHAS_HUGE_FILES
#define wxStat wxMSLU__wstati64 #define wxCRT_Stat wxMSLU__wstati64
#else #else
#define wxStat wxMSLU__wstat #define wxCRT_Stat wxMSLU__wstat
#endif #endif
#else // !wxUSE_UNICODE_MSLU #else // !wxUSE_UNICODE_MSLU
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#if __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551 #if __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551
WXDLLIMPEXP_BASE int wxOpen(const wxChar *pathname, WXDLLIMPEXP_BASE int wxCRT_Open(const wxChar *pathname,
int flags, mode_t mode); int flags, mode_t mode);
#else #else
#define wxOpen _wopen #define wxCRT_Open _wopen
#endif #endif
#define wxAccess _waccess #define wxCRT_Access _waccess
#define wxMkDir _wmkdir #define wxCRT_MkDir _wmkdir
#define wxRmDir _wrmdir #define wxCRT_RmDir _wrmdir
#ifdef wxHAS_HUGE_FILES #ifdef wxHAS_HUGE_FILES
#define wxStat _wstati64 #define wxCRT_Stat _wstati64
#else #else
#define wxStat _wstat #define wxCRT_Stat _wstat
#endif #endif
#else #else
#define wxOpen _wopen #define wxCRT_Open _wopen
#define wxAccess _waccess #define wxCRT_Access _waccess
#define wxMkDir _wmkdir #define wxCRT_MkDir _wmkdir
#define wxRmDir _wrmdir #define wxCRT_RmDir _wrmdir
#ifdef wxHAS_HUGE_FILES #ifdef wxHAS_HUGE_FILES
#define wxStat _wstati64 #define wxCRT_Stat _wstati64
#else #else
#define wxStat _wstat #define wxCRT_Stat _wstat
#endif #endif
#endif #endif
#endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU #endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU
#else // !wxUSE_UNICODE #else // !wxUSE_UNICODE
#define wxOpen wxPOSIX_IDENT(open) #define wxCRT_Open wxPOSIX_IDENT(open)
#define wxAccess wxPOSIX_IDENT(access) #define wxCRT_Access wxPOSIX_IDENT(access)
#define wxMkDir wxPOSIX_IDENT(mkdir) #define wxCRT_MkDir wxPOSIX_IDENT(mkdir)
#define wxRmDir wxPOSIX_IDENT(rmdir) #define wxCRT_RmDir wxPOSIX_IDENT(rmdir)
#ifdef wxHAS_HUGE_FILES #ifdef wxHAS_HUGE_FILES
#define wxStat wxPOSIX_IDENT(stati64) #define wxCRT_Stat wxPOSIX_IDENT(stati64)
#else #else
#define wxStat wxPOSIX_IDENT(stat) #define wxCRT_Stat wxPOSIX_IDENT(stat)
#endif #endif
#endif // wxUSE_UNICODE/!wxUSE_UNICODE #endif // wxUSE_UNICODE/!wxUSE_UNICODE
@@ -398,44 +402,51 @@ enum wxFileKind
#define wxFsync fsync #define wxFsync fsync
#define wxEof eof #define wxEof eof
#define wxMkDir mkdir #define wxCRT_MkDir mkdir
#define wxRmDir rmdir #define wxCRT_RmDir rmdir
#define wxTell(fd) lseek(fd, 0, SEEK_CUR) #define wxTell(fd) lseek(fd, 0, SEEK_CUR)
#define wxStructStat struct stat #define wxStructStat struct stat
#if wxUSE_UNICODE #define wxCRT_Open open
#define wxNEED_WX_UNISTD_H #define wxCRT_Stat stat
#if defined(__DMC__) #define wxCRT_Lstat lstat
typedef unsigned long mode_t; #define wxCRT_Access access
#endif
WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf );
WXDLLIMPEXP_BASE int wxLstat( const wxChar *file_name, wxStructStat *buf );
WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode );
WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode );
#else
#define wxOpen open
#define wxStat stat
#define wxLstat lstat
#define wxAccess access
#endif
#define wxHAS_NATIVE_LSTAT #define wxHAS_NATIVE_LSTAT
#endif // platforms #endif // platforms
// if the platform doesn't have symlinks, define wxCRT_Lstat to be the same as
// wxCRT_Stat to avoid #ifdefs in the code using it
#ifndef wxHAS_NATIVE_LSTAT
#define wxCRT_Lstat wxCRT_Stat
#endif
inline int wxStat(const wxString& path, wxStructStat *buf)
{ return wxCRT_Stat(path.fn_str(), buf); }
inline int wxLstat(const wxString& path, wxStructStat *buf)
{ return wxCRT_Lstat(path.fn_str(), buf); }
inline int wxAccess(const wxString& path, mode_t mode)
{ return wxCRT_Access(path.fn_str(), mode); }
inline int wxOpen(const wxString& path, int flags, mode_t mode)
{ return wxCRT_Open(path.fn_str(), flags, mode); }
inline int wxRmDir(const wxString& path)
{ return wxCRT_RmDir(path.fn_str()); }
#ifdef __WINDOWS__
inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0)
{ return wxCRT_MkDir(path.fn_str()); }
#else
inline int wxMkDir(const wxString& path, mode_t mode)
{ return wxCRT_MkDir(path.fn_str(), mode); }
#endif
#ifdef O_BINARY #ifdef O_BINARY
#define wxO_BINARY O_BINARY #define wxO_BINARY O_BINARY
#else #else
#define wxO_BINARY 0 #define wxO_BINARY 0
#endif #endif
// if the platform doesn't have symlinks, define wxLstat to be the same as
// wxStat to avoid #ifdefs in the code using it
#ifndef wxHAS_NATIVE_LSTAT
#define wxLstat wxStat
#endif
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
// //
// VisualAge C++ V4.0 cannot have any external linkage const decs // VisualAge C++ V4.0 cannot have any external linkage const decs
@@ -463,15 +474,15 @@ WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path);
// Get directory // Get directory
WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path); WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path);
// wxString version WXDLLIMPEXP_BASE void wxDos2UnixFilename(char *s);
WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path); WXDLLIMPEXP_BASE void wxDos2UnixFilename(wchar_t *s);
WXDLLIMPEXP_BASE void wxDos2UnixFilename(wxChar *s); WXDLLIMPEXP_BASE void wxUnix2DosFilename(char *s);
WXDLLIMPEXP_BASE void wxUnix2DosFilename(wchar_t *s);
WXDLLIMPEXP_BASE void wxUnix2DosFilename(wxChar *s);
// Strip the extension, in situ // Strip the extension, in situ
WXDLLIMPEXP_BASE void wxStripExtension(wxChar *buffer); WXDLLIMPEXP_BASE void wxStripExtension(char *buffer);
WXDLLIMPEXP_BASE void wxStripExtension(wchar_t *buffer);
WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer); WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer);
// Get a temporary filename // Get a temporary filename
@@ -479,8 +490,9 @@ WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf =
WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf); WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf);
// Expand file name (~/ and ${OPENWINHOME}/ stuff) // Expand file name (~/ and ${OPENWINHOME}/ stuff)
WXDLLIMPEXP_BASE wxChar* wxExpandPath(wxChar *dest, const wxChar *path); WXDLLIMPEXP_BASE char* wxExpandPath(char *dest, const wxString& path);
WXDLLIMPEXP_BASE bool wxExpandPath(wxString& dest, const wxChar *path); WXDLLIMPEXP_BASE wchar_t* wxExpandPath(wchar_t *dest, const wxString& path);
// FIXME-UTF8: add some wxString version
// Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib) // Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
// and make (if under the home tree) relative to home // and make (if under the home tree) relative to home
@@ -490,7 +502,10 @@ WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename,
const wxString& user = wxEmptyString); const wxString& user = wxEmptyString);
// Destructive removal of /./ and /../ stuff // Destructive removal of /./ and /../ stuff
WXDLLIMPEXP_BASE wxChar* wxRealPath(wxChar *path); // FIXME-UTF8: deprecate these two (and similar)
WXDLLIMPEXP_BASE char* wxRealPath(char *path);
WXDLLIMPEXP_BASE wchar_t* wxRealPath(wchar_t *path);
WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path);
// Allocate a copy of the full absolute path // Allocate a copy of the full absolute path
WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path); WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path);
@@ -499,7 +514,7 @@ WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path);
// Flags are reserved for future use. // Flags are reserved for future use.
#define wxFILE 1 #define wxFILE 1
#define wxDIR 2 #define wxDIR 2
WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE); WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxString& spec, int flags = wxFILE);
WXDLLIMPEXP_BASE wxString wxFindNextFile(); WXDLLIMPEXP_BASE wxString wxFindNextFile();
// Does the pattern contain wildcards? // Does the pattern contain wildcards?
@@ -619,17 +634,17 @@ inline bool wxIsPathSeparator(wxChar c)
} }
// does the string ends with path separator? // does the string ends with path separator?
WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxChar *pszFileName); WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxString& filename);
// split the full path into path (including drive for DOS), name and extension // split the full path into path (including drive for DOS), name and extension
// (understands both '/' and '\\') // (understands both '/' and '\\')
WXDLLIMPEXP_BASE void wxSplitPath(const wxChar *pszFileName, WXDLLIMPEXP_BASE void wxSplitPath(const wxString& fileName,
wxString *pstrPath, wxString *pstrPath,
wxString *pstrName, wxString *pstrName,
wxString *pstrExt); wxString *pstrExt);
// find a file in a list of directories, returns false if not found // find a file in a list of directories, returns false if not found
WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile); WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile);
// Get the OS directory if appropriate (such as the Windows directory). // Get the OS directory if appropriate (such as the Windows directory).
// On non-Windows platform, probably just return the empty string. // On non-Windows platform, probably just return the empty string.

View File

@@ -545,7 +545,7 @@ private:
m_strShort; // short name for the locale m_strShort; // short name for the locale
int m_language; // this locale wxLanguage value int m_language; // this locale wxLanguage value
const wxChar *m_pszOldLocale; // previous locale from setlocale() const char *m_pszOldLocale; // previous locale from setlocale()
wxLocale *m_pOldLocale; // previous wxLocale wxLocale *m_pOldLocale; // previous wxLocale
wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs

View File

@@ -519,12 +519,6 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// filenames are multibyte on Unix and widechar on Windows // filenames are multibyte on Unix and widechar on Windows
#if defined(__UNIX__) || defined(__WXMAC__)
#define wxMBFILES 1
#else
#define wxMBFILES 0
#endif
#if wxMBFILES && wxUSE_UNICODE #if wxMBFILES && wxUSE_UNICODE
#define wxFNCONV(name) wxConvFileName->cWX2MB(name) #define wxFNCONV(name) wxConvFileName->cWX2MB(name)
#define wxFNSTRINGCAST wxMBSTRINGCAST #define wxFNSTRINGCAST wxMBSTRINGCAST

View File

@@ -51,7 +51,7 @@
#include <StringMgr.h> #include <StringMgr.h>
#endif #endif
#include "wx/wxcrt.h" // for wxChar, wxStrlen() etc. #include "wx/wxcrtbase.h" // for wxChar, wxStrlen() etc.
#include "wx/strvararg.h" #include "wx/strvararg.h"
#include "wx/buffer.h" // for wxCharBuffer #include "wx/buffer.h" // for wxCharBuffer
#include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
@@ -1510,11 +1510,7 @@ public:
bool IsSameAs(const wxWCharBuffer& str, bool compareWithCase = true) const bool IsSameAs(const wxWCharBuffer& str, bool compareWithCase = true) const
{ return IsSameAs(str.data(), compareWithCase); } { return IsSameAs(str.data(), compareWithCase); }
// comparison with a single character: returns true if equal // comparison with a single character: returns true if equal
bool IsSameAs(wxUniChar c, bool compareWithCase = true) const bool IsSameAs(wxUniChar c, bool compareWithCase = true) const;
{
return (length() == 1) && (compareWithCase ? GetChar(0u) == c
: wxToupper(GetChar(0u)) == wxToupper(c));
}
// FIXME-UTF8: remove these overloads // FIXME-UTF8: remove these overloads
bool IsSameAs(wxUniCharRef c, bool compareWithCase = true) const bool IsSameAs(wxUniCharRef c, bool compareWithCase = true) const
{ return IsSameAs(wxUniChar(c), compareWithCase); } { return IsSameAs(wxUniChar(c), compareWithCase); }

View File

@@ -24,7 +24,7 @@
#include "wx/defs.h" // everybody should include this #include "wx/defs.h" // everybody should include this
#include "wx/chartype.h" // for wxChar #include "wx/chartype.h" // for wxChar
#include "wx/wxcrt.h" // for wxStrlen() etc. #include "wx/wxcrtbase.h" // for wxStrlen() etc.
#include <stdlib.h> #include <stdlib.h>
@@ -401,7 +401,7 @@ public:
{ ConcatSelf(str.length(), str.c_str()); return *this; } { ConcatSelf(str.length(), str.c_str()); return *this; }
// append first n (or all if n == npos) characters of sz // append first n (or all if n == npos) characters of sz
wxStringImpl& append(const wxStringCharType *sz) wxStringImpl& append(const wxStringCharType *sz)
{ ConcatSelf(Strsize(sz), sz); return *this; } { ConcatSelf(wxStrlen(sz), sz); return *this; }
wxStringImpl& append(const wxStringCharType *sz, size_t n) wxStringImpl& append(const wxStringCharType *sz, size_t n)
{ ConcatSelf(n, sz); return *this; } { ConcatSelf(n, sz); return *this; }
// append n copies of ch // append n copies of ch
@@ -418,7 +418,7 @@ public:
{ clear(); return append(str, pos, n); } { clear(); return append(str, pos, n); }
// same as `= first n (or all if n == npos) characters of sz' // same as `= first n (or all if n == npos) characters of sz'
wxStringImpl& assign(const wxStringCharType *sz) wxStringImpl& assign(const wxStringCharType *sz)
{ clear(); return append(sz, Strsize(sz)); } { clear(); return append(sz, wxStrlen(sz)); }
wxStringImpl& assign(const wxStringCharType *sz, size_t n) wxStringImpl& assign(const wxStringCharType *sz, size_t n)
{ clear(); return append(sz, n); } { clear(); return append(sz, n); }
// same as `= n copies of ch' // same as `= n copies of ch'
@@ -546,13 +546,6 @@ public:
void DoUngetWriteBuf(); void DoUngetWriteBuf();
void DoUngetWriteBuf(size_t nLen); void DoUngetWriteBuf(size_t nLen);
private:
#if wxUSE_UNICODE_UTF8
static size_t Strsize(const wxStringCharType *s) { return strlen(s); }
#else
static size_t Strsize(const wxStringCharType *s) { return wxStrlen(s); }
#endif
friend class WXDLLIMPEXP_BASE wxString; friend class WXDLLIMPEXP_BASE wxString;
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -25,24 +25,6 @@
/* Required for wxPrintf() etc */ /* Required for wxPrintf() etc */
#include <stdarg.h> #include <stdarg.h>
#ifdef wxHAVE_TCHAR_SUPPORT
#define wxCRT_Fprintf _ftprintf
#define wxCRT_Printf _tprintf
#define wxCRT_Vfprintf _vftprintf
#define wxCRT_Vprintf _vtprintf
#define wxCRT_Vsprintf _vstprintf
#else /* !TCHAR-aware compilers */
#if !wxUSE_UNICODE /* ASCII */
#define wxCRT_Fprintf fprintf
#define wxCRT_Printf printf
#define wxCRT_Vfprintf vfprintf
#define wxCRT_Vprintf vprintf
#define wxCRT_Vsprintf vsprintf
#endif /* ASCII */
#endif /* TCHAR-aware compilers/the others */
/* printf() family saga */ /* printf() family saga */
/* /*
@@ -64,7 +46,7 @@
#else #else
extern extern
#endif #endif
WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...); int snprintf(char *str, size_t size, const char *format, ...);
#endif /* !HAVE_SNPRINTF_DECL */ #endif /* !HAVE_SNPRINTF_DECL */
/* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the /* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the
@@ -94,16 +76,13 @@
our wxVsnprintf() implementation. our wxVsnprintf() implementation.
*/ */
#if defined(HAVE_UNIX98_PRINTF) #if defined(HAVE_UNIX98_PRINTF)
#if wxUSE_UNICODE #ifdef HAVE_VSWPRINTF
#ifdef HAVE_VSWPRINTF #define wxCRT_VsnprintfW_ vswprintf
#define wxVsnprintf_ vswprintf #endif
#endif #ifdef HAVE_BROKEN_VSNPRINTF_DECL
#else /* ASCII */ #define wxCRT_VsnprintfA wx_fixed_vsnprintf
#ifdef HAVE_BROKEN_VSNPRINTF_DECL #else
#define wxVsnprintf_ wx_fixed_vsnprintf #define wxCRT_VsnprintfA vsnprintf
#else
#define wxVsnprintf_ vsnprintf
#endif
#endif #endif
#else /* !HAVE_UNIX98_PRINTF */ #else /* !HAVE_UNIX98_PRINTF */
/* /*
@@ -113,11 +92,8 @@
main release and does not have the printf_p functions. main release and does not have the printf_p functions.
*/ */
#if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__ #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__
#if wxUSE_UNICODE #define wxCRT_VsnprintfA _vsprintf_p
#define wxVsnprintf_ _vswprintf_p #define wxCRT_VsnprintfW_ _vswprintf_p
#else
#define wxVsnprintf_ _vsprintf_p
#endif
#endif #endif
#endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */ #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */
#else /* !wxUSE_PRINTF_POS_PARAMS */ #else /* !wxUSE_PRINTF_POS_PARAMS */
@@ -131,60 +107,71 @@
is a wrapper around it as explained below is a wrapper around it as explained below
*/ */
/* first deal with TCHAR-aware compilers which have _vsntprintf */ #if defined(__VISUALC__) || \
#ifndef wxVsnprintf_ (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
#if defined(__VISUALC__) || \ #define wxCRT_VsnprintfA _vsnprintf
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540) #define wxCRT_VsnprintfW_ _vsnwprintf
#define wxVsnprintf_ _vsntprintf #else
#if defined(HAVE__VSNWPRINTF)
#define wxCRT_VsnprintfW_ _vsnwprintf
#elif defined(HAVE_VSWPRINTF)
#define wxCRT_VsnprintfW_ vswprintf
#elif defined(__WATCOMC__)
#define wxCRT_VsnprintfW_ _vsnwprintf
#endif
/*
All versions of CodeWarrior supported by wxWidgets apparently
have both snprintf() and vsnprintf()
*/
#if defined(HAVE_VSNPRINTF) \
|| defined(__MWERKS__) || defined(__WATCOMC__)
#ifdef HAVE_BROKEN_VSNPRINTF_DECL
#define wxCRT_VsnprintfA wx_fixed_vsnprintf
#else
#define wxCRT_VsnprintfA vsnprintf
#endif
#endif #endif
#endif #endif
/* if this didn't work, define it separately for Unicode and ANSI builds */
#ifndef wxVsnprintf_
#if wxUSE_UNICODE
#if defined(HAVE__VSNWPRINTF)
#define wxVsnprintf_ _vsnwprintf
#elif defined(HAVE_VSWPRINTF)
#define wxVsnprintf_ vswprintf
#elif defined(__WATCOMC__)
#define wxVsnprintf_ _vsnwprintf
#endif
#else /* ASCII */
/*
All versions of CodeWarrior supported by wxWidgets apparently
have both snprintf() and vsnprintf()
*/
#if defined(HAVE_VSNPRINTF) \
|| defined(__MWERKS__) || defined(__WATCOMC__)
#ifdef HAVE_BROKEN_VSNPRINTF_DECL
#define wxVsnprintf_ wx_fixed_vsnprintf
#else
#define wxVsnprintf_ vsnprintf
#endif
#endif
#endif /* Unicode/ASCII */
#endif /* wxVsnprintf_ */
#endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */ #endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */
#ifndef wxVsnprintf_ #ifndef wxCRT_VsnprintfW_
/* no (suitable) vsnprintf(), cook our own */ /* no (suitable) vsnprintf(), cook our own */
WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE int
wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format, va_list argptr); wxCRT_VsnprintfW_(wchar_t *buf, size_t len, const wchar_t *format, va_list argptr);
#define wxUSE_WXVSNPRINTFW 1
#define wxUSE_WXVSNPRINTF 1
#else #else
#define wxUSE_WXVSNPRINTF 0 #define wxUSE_WXVSNPRINTFW 0
#endif #endif
/* #ifndef wxCRT_VsnprintfA
In Unicode mode we need to have all standard functions such as wprintf() and /* no (suitable) vsnprintf(), cook our own */
so on but not all systems have them so use our own implementations in this WXDLLIMPEXP_BASE int
case. wxCRT_VsnprintfA(char *buf, size_t len, const char *format, va_list argptr);
*/ #define wxUSE_WXVSNPRINTFA 1
#if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF) #else
#define wxNEED_WPRINTF #define wxUSE_WXVSNPRINTFA 0
#endif #endif
// for wxString code, define wxUSE_WXVSNPRINTF to indicate that wx
// implementation is used no matter what (in UTF-8 build, either *A or *W
// version may be called):
#if !wxUSE_UNICODE
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA
#elif wxUSE_UNICODE_WCHAR
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFW
#elif wxUSE_UTF8_LOCALE_ONLY
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA
#else // UTF-8 under any locale
#define wxUSE_WXVSNPRINTF (wxUSE_WXVSNPRINTFA && wxUSE_WXVSNPRINTFW)
#endif
#define wxCRT_FprintfA fprintf
#define wxCRT_PrintfA printf
#define wxCRT_VfprintfA vfprintf
#define wxCRT_VprintfA vprintf
#define wxCRT_VsprintfA vsprintf
/* /*
More Unicode complications: although both ANSI C and C++ define a number of More Unicode complications: although both ANSI C and C++ define a number of
wide character functions such as wprintf(), not all environments have them. wide character functions such as wprintf(), not all environments have them.
@@ -197,6 +184,32 @@
if we have wprintf() we still must wrap it in a non trivial wxPrintf(). if we have wprintf() we still must wrap it in a non trivial wxPrintf().
*/ */
#ifndef __WINDOWS__
#define wxNEED_PRINTF_CONVERSION
#endif
// FIXME-UTF8: format conversion should be moved outside of wxCRT_* and to the
// vararg templates; after then, wxNEED_PRINTF_CONVERSION should
// be removed and this code simplified
#ifndef wxNEED_PRINTF_CONVERSION
#ifdef wxHAVE_TCHAR_SUPPORT
#define wxCRT_FprintfW fwprintf
#define wxCRT_PrintfW wprintf
#define wxCRT_VfprintfW vfwprintf
#define wxCRT_VprintfW vwprintf
#define wxCRT_VsprintfW vswprintf
#endif
#endif // !defined(wxNEED_PRINTF_CONVERSION)
/*
In Unicode mode we need to have all standard functions such as wprintf() and
so on but not all systems have them so use our own implementations in this
case.
*/
#if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
#define wxNEED_WPRINTF
#endif
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF) #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
/* /*
@@ -204,23 +217,23 @@
we don't have them at all or because they don't have the semantics we we don't have them at all or because they don't have the semantics we
need need
*/ */
int wxCRT_Printf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1; int wxCRT_PrintfW( const wchar_t *format, ... ) ATTRIBUTE_PRINTF_1;
int wxCRT_Fprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2; int wxCRT_FprintfW( FILE *stream, const wchar_t *format, ... ) ATTRIBUTE_PRINTF_2;
int wxCRT_Vfprintf( FILE *stream, const wxChar *format, va_list ap ); int wxCRT_VfprintfW( FILE *stream, const wchar_t *format, va_list ap );
int wxCRT_Vprintf( const wxChar *format, va_list ap ); int wxCRT_VprintfW( const wchar_t *format, va_list ap );
int wxCRT_Vsprintf( wxChar *str, const wxChar *format, va_list ap ); int wxCRT_VsprintfW( wchar_t *str, const wchar_t *format, va_list ap );
#endif /* wxNEED_PRINTF_CONVERSION */ #endif /* wxNEED_PRINTF_CONVERSION */
/* these 2 can be simply mapped to the versions with underscore at the end */ /* these 2 can be simply mapped to the versions with underscore at the end */
/* if we don't have to do the conversion */ /* if we don't have to do the conversion */
/* /*
However, if we don't have any vswprintf() at all we don't need to redefine However, if we don't have any vswprintf() at all we don't need to redefine
anything as our own wxVsnprintf_() already behaves as needed. anything as our own wxCRT_VsnprintfW_() already behaves as needed.
*/ */
#if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_) #if defined(wxNEED_PRINTF_CONVERSION) && defined(wxCRT_VsnprintfW_)
int wxCRT_Vsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap ); int wxCRT_VsnprintfW( wchar_t *str, size_t size, const wchar_t *format, va_list ap );
#else #else
#define wxCRT_Vsnprintf wxVsnprintf_ #define wxCRT_VsnprintfW wxCRT_VsnprintfW_
#endif #endif
@@ -265,40 +278,52 @@
// we'll also need wxArgNormalizer<T> specializations for char, // we'll also need wxArgNormalizer<T> specializations for char,
// wchar_t, wxUniChar and wxUniCharRef to handle this correctly // wchar_t, wxUniChar and wxUniCharRef to handle this correctly
// FIXME-UTF8: remove this
#if wxUSE_UNICODE
#define wxCRT_PrintfNative wxCRT_PrintfW
#define wxCRT_FprintfNative wxCRT_FprintfW
#else
#define wxCRT_PrintfNative wxCRT_PrintfA
#define wxCRT_FprintfNative wxCRT_FprintfA
#endif
WX_DEFINE_VARARG_FUNC(int, wxPrintf, 1, (const wxFormatString&), WX_DEFINE_VARARG_FUNC(int, wxPrintf, 1, (const wxFormatString&),
wxCRT_Printf, printf) wxCRT_PrintfNative, wxCRT_PrintfA)
WX_DEFINE_VARARG_FUNC(int, wxFprintf, 2, (FILE*, const wxFormatString&), WX_DEFINE_VARARG_FUNC(int, wxFprintf, 2, (FILE*, const wxFormatString&),
wxCRT_Fprintf, fprintf) wxCRT_FprintfNative, wxCRT_FprintfA)
// va_list versions of printf functions simply forward to the respective // va_list versions of printf functions simply forward to the respective
// CRT function; note that they assume that va_list was created using // CRT function; note that they assume that va_list was created using
// wxArgNormalizer<T>! // wxArgNormalizer<T>!
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
#if wxUSE_UTF8_LOCALE_ONLY #if wxUSE_UTF8_LOCALE_ONLY
#define WX_VARARG_VFOO_IMPL(args, implWchar, implUtf8) \ #define WX_VARARG_VFOO_IMPL(args, implW, implA) \
return implUtf8 args return implA args
#else #else
#define WX_VARARG_VFOO_IMPL(args, implWchar, implUtf8) \ #define WX_VARARG_VFOO_IMPL(args, implW, implA) \
if ( wxLocaleIsUtf8 ) return implUtf8 args; \ if ( wxLocaleIsUtf8 ) return implA args; \
else return implWchar args else return implW args
#endif #endif
#else // wxUSE_UNICODE_WCHAR / ANSI #elif wxUSE_UNICODE_WCHAR
#define WX_VARARG_VFOO_IMPL(args, implWchar, implUtf8) \ #define WX_VARARG_VFOO_IMPL(args, implW, implA) \
return implWchar args return implW args
#else // ANSI
#define WX_VARARG_VFOO_IMPL(args, implW, implA) \
return implA args
#endif #endif
inline int inline int
wxVprintf(const wxString& format, va_list ap) wxVprintf(const wxString& format, va_list ap)
{ {
WX_VARARG_VFOO_IMPL((wxFormatString(format), ap), WX_VARARG_VFOO_IMPL((wxFormatString(format), ap),
wxCRT_Vprintf, vprintf); wxCRT_VprintfW, wxCRT_VprintfA);
} }
inline int inline int
wxVfprintf(FILE *f, const wxString& format, va_list ap) wxVfprintf(FILE *f, const wxString& format, va_list ap)
{ {
WX_VARARG_VFOO_IMPL((f, wxFormatString(format), ap), WX_VARARG_VFOO_IMPL((f, wxFormatString(format), ap),
wxCRT_Vfprintf, vfprintf); wxCRT_VfprintfW, wxCRT_VfprintfA);
} }
#undef WX_VARARG_VFOO_IMPL #undef WX_VARARG_VFOO_IMPL

View File

@@ -46,7 +46,7 @@ bool wxColourBase::FromString(const wxString& str)
// according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units // according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units
// values outside 0-255 range are allowed but should be clipped // values outside 0-255 range are allowed but should be clipped
int red, green, blue; int red, green, blue;
if (wxSscanf(str.substr(3), wxT("(%d, %d, %d)"), &red, &green, &blue) != 3) if (wxSscanf(str.wx_str() + 3, wxT("(%d, %d, %d)"), &red, &green, &blue) != 3)
return false; return false;
Set((unsigned char)wxClip(red,0,255), Set((unsigned char)wxClip(red,0,255),
@@ -57,7 +57,7 @@ bool wxColourBase::FromString(const wxString& str)
{ {
// hexadecimal prefixed with # (HTML syntax) // hexadecimal prefixed with # (HTML syntax)
unsigned long tmp; unsigned long tmp;
if (wxSscanf(str.substr(1), wxT("%lx"), &tmp) != 1) if (wxSscanf(str.wx_str() + 1, wxT("%lx"), &tmp) != 1)
return false; return false;
Set((unsigned char)(tmp >> 16), Set((unsigned char)(tmp >> 16),

View File

@@ -128,30 +128,6 @@ const int wxInvalidOffset = -1;
// wrappers around standard POSIX functions // wrappers around standard POSIX functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef wxNEED_WX_UNISTD_H
WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf )
{
return stat( wxConvFile.cWX2MB( file_name ), buf );
}
WXDLLEXPORT int wxLstat( const wxChar *file_name, wxStructStat *buf )
{
return lstat( wxConvFile.cWX2MB( file_name ), buf );
}
WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode )
{
return access( wxConvFile.cWX2MB( pathname ), mode );
}
WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode )
{
return open( wxConvFile.cWX2MB( pathname ), flags, mode );
}
#endif // wxNEED_WX_UNISTD_H
#if wxUSE_UNICODE && defined __BORLANDC__ \ #if wxUSE_UNICODE && defined __BORLANDC__ \
&& __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551 && __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551
@@ -159,7 +135,7 @@ WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode )
// regardless of the mode parameter. This hack works around the problem by // regardless of the mode parameter. This hack works around the problem by
// setting the mode with _wchmod. // setting the mode with _wchmod.
// //
int wxOpen(const wchar_t *pathname, int flags, mode_t mode) int wxCRT_Open(const wchar_t *pathname, int flags, mode_t mode)
{ {
int moreflags = 0; int moreflags = 0;
@@ -324,9 +300,10 @@ static inline wxChar* MYcopystring(const wxString& s)
return wxStrcpy(copy, s.c_str()); return wxStrcpy(copy, s.c_str());
} }
static inline wxChar* MYcopystring(const wxChar* s) template<typename CharType>
static inline CharType* MYcopystring(const CharType* s)
{ {
wxChar* copy = new wxChar[wxStrlen(s) + 1]; CharType* copy = new CharType[wxStrlen(s) + 1];
return wxStrcpy(copy, s); return wxStrcpy(copy, s);
} }
@@ -398,7 +375,8 @@ wxIsAbsolutePath (const wxString& filename)
* *
*/ */
void wxStripExtension(wxChar *buffer) template<typename T>
static void wxDoStripExtension(T *buffer)
{ {
int len = wxStrlen(buffer); int len = wxStrlen(buffer);
int i = len-1; int i = len-1;
@@ -413,6 +391,9 @@ void wxStripExtension(wxChar *buffer)
} }
} }
void wxStripExtension(char *buffer) { wxDoStripExtension(buffer); }
void wxStripExtension(wchar_t *buffer) { wxDoStripExtension(buffer); }
void wxStripExtension(wxString& buffer) void wxStripExtension(wxString& buffer)
{ {
//RN: Be careful about the handling the case where //RN: Be careful about the handling the case where
@@ -428,17 +409,18 @@ void wxStripExtension(wxString& buffer)
} }
// Destructive removal of /./ and /../ stuff // Destructive removal of /./ and /../ stuff
wxChar *wxRealPath (wxChar *path) template<typename CharType>
static CharType *wxDoRealPath (CharType *path)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
static const wxChar SEP = wxT('\\'); static const CharType SEP = wxT('\\');
wxUnix2DosFilename(path); wxUnix2DosFilename(path);
#else #else
static const wxChar SEP = wxT('/'); static const CharType SEP = wxT('/');
#endif #endif
if (path[0] && path[1]) { if (path[0] && path[1]) {
/* MATTHEW: special case "/./x" */ /* MATTHEW: special case "/./x" */
wxChar *p; CharType *p;
if (path[2] == SEP && path[1] == wxT('.')) if (path[2] == SEP && path[1] == wxT('.'))
p = &path[0]; p = &path[0];
else else
@@ -449,7 +431,7 @@ wxChar *wxRealPath (wxChar *path)
{ {
if (p[1] == wxT('.') && p[2] == wxT('.') && (p[3] == SEP || p[3] == wxT('\0'))) if (p[1] == wxT('.') && p[2] == wxT('.') && (p[3] == SEP || p[3] == wxT('\0')))
{ {
wxChar *q; CharType *q;
for (q = p - 1; q >= path && *q != SEP; q--) for (q = p - 1; q >= path && *q != SEP; q--)
{ {
// Empty // Empty
@@ -483,6 +465,16 @@ wxChar *wxRealPath (wxChar *path)
return path; return path;
} }
char *wxRealPath(char *path)
{
return wxDoRealPath(path);
}
wchar_t *wxRealPath(wchar_t *path)
{
return wxDoRealPath(path);
}
wxString wxRealPath(const wxString& path) wxString wxRealPath(const wxString& path)
{ {
wxChar *buf1=MYcopystring(path); wxChar *buf1=MYcopystring(path);
@@ -540,38 +532,39 @@ wxChar *wxCopyAbsolutePath(const wxString& filename)
/* input name in name, pathname output to buf. */ /* input name in name, pathname output to buf. */
wxChar *wxExpandPath(wxChar *buf, const wxChar *name) template<typename CharType>
static CharType *wxDoExpandPath(CharType *buf, const wxString& name)
{ {
register wxChar *d, *s, *nm; register CharType *d, *s, *nm;
wxChar lnm[_MAXPATHLEN]; CharType lnm[_MAXPATHLEN];
int q; int q;
// Some compilers don't like this line. // Some compilers don't like this line.
// const wxChar trimchars[] = wxT("\n \t"); // const CharType trimchars[] = wxT("\n \t");
wxChar trimchars[4]; CharType trimchars[4];
trimchars[0] = wxT('\n'); trimchars[0] = wxT('\n');
trimchars[1] = wxT(' '); trimchars[1] = wxT(' ');
trimchars[2] = wxT('\t'); trimchars[2] = wxT('\t');
trimchars[3] = 0; trimchars[3] = 0;
#ifdef __WXMSW__ #ifdef __WXMSW__
const wxChar SEP = wxT('\\'); const CharType SEP = wxT('\\');
#else #else
const wxChar SEP = wxT('/'); const CharType SEP = wxT('/');
#endif #endif
buf[0] = wxT('\0'); buf[0] = wxT('\0');
if (name == NULL || *name == wxT('\0')) if (name.empty())
return buf; return buf;
nm = MYcopystring(name); // Make a scratch copy nm = MYcopystring((const CharType*)name.c_str()); // Make a scratch copy
wxChar *nm_tmp = nm; CharType *nm_tmp = nm;
/* Skip leading whitespace and cr */ /* Skip leading whitespace and cr */
while (wxStrchr((wxChar *)trimchars, *nm) != NULL) while (wxStrchr(trimchars, *nm) != NULL)
nm++; nm++;
/* And strip off trailing whitespace and cr */ /* And strip off trailing whitespace and cr */
s = nm + (q = wxStrlen(nm)) - 1; s = nm + (q = wxStrlen(nm)) - 1;
while (q-- && wxStrchr((wxChar *)trimchars, *s) != NULL) while (q-- && wxStrchr(trimchars, *s) != NULL)
*s = wxT('\0'); *s = wxT('\0');
s = nm; s = nm;
@@ -619,9 +612,9 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
if (*s++ == wxT('$')) if (*s++ == wxT('$'))
#endif #endif
{ {
register wxChar *start = d; register CharType *start = d;
register int braces = (*s == wxT('{') || *s == wxT('(')); register int braces = (*s == wxT('{') || *s == wxT('('));
register wxChar *value; register CharType *value;
while ((*d++ = *s) != 0) while ((*d++ = *s) != 0)
if (braces ? (*s == wxT('}') || *s == wxT(')')) : !(wxIsalnum(*s) || *s == wxT('_')) ) if (braces ? (*s == wxT('}') || *s == wxT(')')) : !(wxIsalnum(*s) || *s == wxT('_')) )
break; break;
@@ -645,21 +638,22 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
} }
/* Expand ~ and ~user */ /* Expand ~ and ~user */
wxString homepath;
nm = lnm; nm = lnm;
if (nm[0] == wxT('~') && !q) if (nm[0] == wxT('~') && !q)
{ {
/* prefix ~ */ /* prefix ~ */
if (nm[1] == SEP || nm[1] == 0) if (nm[1] == SEP || nm[1] == 0)
{ /* ~/filename */ { /* ~/filename */
// FIXME: wxGetUserHome could return temporary storage in Unicode mode homepath = wxGetUserHome(wxEmptyString);
if ((s = WXSTRINGCAST wxGetUserHome(wxEmptyString)) != NULL) { if (!homepath.empty()) {
s = (CharType*)(const CharType*)homepath.c_str();
if (*++nm) if (*++nm)
nm++; nm++;
} }
} else } else
{ /* ~user/filename */ { /* ~user/filename */
register wxChar *nnm; register CharType *nnm;
register wxChar *home;
for (s = nm; *s && *s != SEP; s++) for (s = nm; *s && *s != SEP; s++)
{ {
// Empty // Empty
@@ -668,8 +662,8 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
was_sep = (*s == SEP); was_sep = (*s == SEP);
nnm = *s ? s + 1 : s; nnm = *s ? s + 1 : s;
*s = 0; *s = 0;
// FIXME: wxGetUserHome could return temporary storage in Unicode mode homepath = wxGetUserHome(wxString(nm + 1));
if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL) if (homepath.empty())
{ {
if (was_sep) /* replace only if it was there: */ if (was_sep) /* replace only if it was there: */
*s = SEP; *s = SEP;
@@ -678,7 +672,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
else else
{ {
nm = nnm; nm = nnm;
s = home; s = (CharType*)(const CharType*)homepath.c_str();
} }
} }
} }
@@ -702,6 +696,17 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
return wxRealPath(buf); return wxRealPath(buf);
} }
char *wxExpandPath(char *buf, const wxString& name)
{
return wxDoExpandPath(buf, name);
}
wchar_t *wxExpandPath(wchar_t *buf, const wxString& name)
{
return wxDoExpandPath(buf, name);
}
/* Contract Paths to be build upon an environment variable /* Contract Paths to be build upon an environment variable
component: component:
@@ -719,22 +724,22 @@ wxContractPath (const wxString& filename,
if (filename.empty()) if (filename.empty())
return (wxChar *) NULL; return (wxChar *) NULL;
wxStrcpy (dest, WXSTRINGCAST filename); wxStrcpy (dest, filename);
#ifdef __WXMSW__ #ifdef __WXMSW__
wxUnix2DosFilename(dest); wxUnix2DosFilename(dest);
#endif #endif
// Handle environment // Handle environment
const wxChar *val; wxString val;
#ifndef __WXWINCE__ #ifndef __WXWINCE__
wxChar *tcp; wxChar *tcp;
if (!envname.empty() && (val = wxGetenv (WXSTRINGCAST envname)) != NULL && if (!envname.empty() && !(val = wxGetenv (envname)).empty() &&
(tcp = wxStrstr (dest, val)) != NULL) (tcp = wxStrstr (dest, val)) != NULL)
{ {
wxStrcpy (wxFileFunctionsBuffer, tcp + wxStrlen (val)); wxStrcpy (wxFileFunctionsBuffer, tcp + val.length());
*tcp++ = wxT('$'); *tcp++ = wxT('$');
*tcp++ = wxT('{'); *tcp++ = wxT('{');
wxStrcpy (tcp, WXSTRINGCAST envname); wxStrcpy (tcp, envname);
wxStrcat (tcp, wxT("}")); wxStrcat (tcp, wxT("}"));
wxStrcat (tcp, wxFileFunctionsBuffer); wxStrcat (tcp, wxFileFunctionsBuffer);
} }
@@ -742,10 +747,10 @@ wxContractPath (const wxString& filename,
// Handle User's home (ignore root homes!) // Handle User's home (ignore root homes!)
val = wxGetUserHome (user); val = wxGetUserHome (user);
if (!val) if (val.empty())
return dest; return dest;
const size_t len = wxStrlen(val); const size_t len = val.length();
if (len <= 2) if (len <= 2)
return dest; return dest;
@@ -753,7 +758,7 @@ wxContractPath (const wxString& filename,
{ {
wxStrcpy(wxFileFunctionsBuffer, wxT("~")); wxStrcpy(wxFileFunctionsBuffer, wxT("~"));
if (!user.empty()) if (!user.empty())
wxStrcat(wxFileFunctionsBuffer, (const wxChar*) user); wxStrcat(wxFileFunctionsBuffer, user);
wxStrcat(wxFileFunctionsBuffer, dest + len); wxStrcat(wxFileFunctionsBuffer, dest + len);
wxStrcpy (dest, wxFileFunctionsBuffer); wxStrcpy (dest, wxFileFunctionsBuffer);
} }
@@ -849,7 +854,7 @@ wxString wxPathOnly (const wxString& path)
wxChar buf[_MAXPATHLEN]; wxChar buf[_MAXPATHLEN];
// Local copy // Local copy
wxStrcpy (buf, WXSTRINGCAST path); wxStrcpy(buf, path);
int l = path.length(); int l = path.length();
int i = l - 1; int i = l - 1;
@@ -985,8 +990,8 @@ void wxMacFilename2FSSpec( const wxString& path , FSSpec *spec )
#endif // __WXMAC__ #endif // __WXMAC__
void template<typename T>
wxDos2UnixFilename (wxChar *s) static void wxDoDos2UnixFilename(T *s)
{ {
if (s) if (s)
while (*s) while (*s)
@@ -995,17 +1000,21 @@ wxDos2UnixFilename (wxChar *s)
*s = _T('/'); *s = _T('/');
#ifdef __WXMSW__ #ifdef __WXMSW__
else else
*s = (wxChar)wxTolower (*s); // Case INDEPENDENT *s = wxTolower(*s); // Case INDEPENDENT
#endif #endif
s++; s++;
} }
} }
void void wxDos2UnixFilename(char *s) { wxDoDos2UnixFilename(s); }
void wxDos2UnixFilename(wchar_t *s) { wxDoDos2UnixFilename(s); }
template<typename T>
static void
#if defined(__WXMSW__) || defined(__OS2__) #if defined(__WXMSW__) || defined(__OS2__)
wxUnix2DosFilename (wxChar *s) wxDoUnix2DosFilename(T *s)
#else #else
wxUnix2DosFilename (wxChar *WXUNUSED(s) ) wxDoUnix2DosFilename(T *WXUNUSED(s) )
#endif #endif
{ {
// Yes, I really mean this to happen under DOS only! JACS // Yes, I really mean this to happen under DOS only! JACS
@@ -1020,6 +1029,9 @@ wxUnix2DosFilename (wxChar *WXUNUSED(s) )
#endif #endif
} }
void wxUnix2DosFilename(char *s) { wxDoUnix2DosFilename(s); }
void wxUnix2DosFilename(wchar_t *s) { wxDoUnix2DosFilename(s); }
// Concatenate two files to form third // Concatenate two files to form third
bool bool
wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3) wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3)
@@ -1421,7 +1433,7 @@ bool wxGetTempFileName(const wxString& prefix, wxString& buf)
static wxDir *gs_dir = NULL; static wxDir *gs_dir = NULL;
static wxString gs_dirPath; static wxString gs_dirPath;
wxString wxFindFirstFile(const wxChar *spec, int flags) wxString wxFindFirstFile(const wxString& spec, int flags)
{ {
wxSplitPath(spec, &gs_dirPath, NULL, NULL); wxSplitPath(spec, &gs_dirPath, NULL, NULL);
if ( gs_dirPath.empty() ) if ( gs_dirPath.empty() )
@@ -1448,7 +1460,7 @@ wxString wxFindFirstFile(const wxChar *spec, int flags)
} }
wxString result; wxString result;
gs_dir->GetFirst(&result, wxFileNameFromPath(wxString(spec)), dirFlags); gs_dir->GetFirst(&result, wxFileNameFromPath(spec), dirFlags);
if ( result.empty() ) if ( result.empty() )
{ {
wxDELETE(gs_dir); wxDELETE(gs_dir);
@@ -1695,64 +1707,50 @@ wxString wxGetOSDirectory()
#endif #endif
} }
bool wxEndsWithPathSeparator(const wxChar *pszFileName) bool wxEndsWithPathSeparator(const wxString& filename)
{ {
size_t len = wxStrlen(pszFileName); return !filename.empty() && wxIsPathSeparator(filename.Last());
return len && wxIsPathSeparator(pszFileName[len - 1]);
} }
// find a file in a list of directories, returns false if not found // find a file in a list of directories, returns false if not found
bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile) bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile)
{ {
// we assume that it's not empty // we assume that it's not empty
wxCHECK_MSG( !wxIsEmpty(pszFile), false, wxCHECK_MSG( !szFile.empty(), false,
_T("empty file name in wxFindFileInPath")); _T("empty file name in wxFindFileInPath"));
// skip path separator in the beginning of the file name if present // skip path separator in the beginning of the file name if present
if ( wxIsPathSeparator(*pszFile) ) wxString szFile2;
pszFile++; if ( wxIsPathSeparator(szFile[0u]) )
szFile2 = szFile.Mid(1);
else
szFile2 = szFile;
// copy the path (strtok will modify it) wxStringTokenizer tkn(szPath, wxPATH_SEP);
wxChar *szPath = new wxChar[wxStrlen(pszPath) + 1];
wxStrcpy(szPath, pszPath);
wxString strFile; while ( tkn.HasMoreTokens() )
wxChar *pc, *save_ptr;
for ( pc = wxStrtok(szPath, wxPATH_SEP, &save_ptr);
pc != NULL;
pc = wxStrtok((wxChar *) NULL, wxPATH_SEP, &save_ptr) )
{ {
// search for the file in this directory wxString strFile = tkn.GetNextToken();
strFile = pc; if ( !wxEndsWithPathSeparator(strFile) )
if ( !wxEndsWithPathSeparator(pc) )
strFile += wxFILE_SEP_PATH; strFile += wxFILE_SEP_PATH;
strFile += pszFile; strFile += szFile2;
if ( wxFileExists(strFile) ) { if ( wxFileExists(strFile) )
{
*pStr = strFile; *pStr = strFile;
break; return true;
} }
} }
// suppress warning about unused variable save_ptr when wxStrtok() is a return false;
// macro which throws away its third argument
save_ptr = pc;
delete [] szPath;
return pc != NULL; // if true => we breaked from the loop
} }
void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, void WXDLLEXPORT wxSplitPath(const wxString& fileName,
wxString *pstrPath, wxString *pstrPath,
wxString *pstrName, wxString *pstrName,
wxString *pstrExt) wxString *pstrExt)
{ {
// it can be empty, but it shouldn't be NULL wxFileName::SplitPath(fileName, pstrPath, pstrName, pstrExt);
wxCHECK_RET( pszFileName, wxT("NULL file name in wxSplitPath") );
wxFileName::SplitPath(pszFileName, pstrPath, pstrName, pstrExt);
} }
#if wxUSE_DATETIME #if wxUSE_DATETIME
@@ -1896,7 +1894,7 @@ static bool wxCheckWin32Permission(const wxString& path, DWORD access)
HANDLE h = ::CreateFile HANDLE h = ::CreateFile
( (
path.c_str(), path.wx_str(),
access, access,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, NULL,
@@ -1915,7 +1913,7 @@ bool wxIsWritable(const wxString &path)
{ {
#if defined( __UNIX__ ) || defined(__OS2__) #if defined( __UNIX__ ) || defined(__OS2__)
// access() will take in count also symbolic links // access() will take in count also symbolic links
return access(wxConvFile.cWX2MB(path), W_OK) == 0; return access(path.fn_str(), W_OK) == 0;
#elif defined( __WINDOWS__ ) #elif defined( __WINDOWS__ )
return wxCheckWin32Permission(path, GENERIC_WRITE); return wxCheckWin32Permission(path, GENERIC_WRITE);
#else #else
@@ -1929,7 +1927,7 @@ bool wxIsReadable(const wxString &path)
{ {
#if defined( __UNIX__ ) || defined(__OS2__) #if defined( __UNIX__ ) || defined(__OS2__)
// access() will take in count also symbolic links // access() will take in count also symbolic links
return access(wxConvFile.cWX2MB(path), R_OK) == 0; return access(path.fn_str(), R_OK) == 0;
#elif defined( __WINDOWS__ ) #elif defined( __WINDOWS__ )
return wxCheckWin32Permission(path, GENERIC_READ); return wxCheckWin32Permission(path, GENERIC_READ);
#else #else
@@ -1943,7 +1941,7 @@ bool wxIsExecutable(const wxString &path)
{ {
#if defined( __UNIX__ ) || defined(__OS2__) #if defined( __UNIX__ ) || defined(__OS2__)
// access() will take in count also symbolic links // access() will take in count also symbolic links
return access(wxConvFile.cWX2MB(path), X_OK) == 0; return access(path.fn_str(), X_OK) == 0;
#elif defined( __WINDOWS__ ) #elif defined( __WINDOWS__ )
return wxCheckWin32Permission(path, GENERIC_EXECUTE); return wxCheckWin32Permission(path, GENERIC_EXECUTE);
#else #else
@@ -2033,17 +2031,19 @@ wxFileKind wxGetFileKind(FILE *fp)
bool wxIsWild( const wxString& pattern ) bool wxIsWild( const wxString& pattern )
{ {
wxString tmp = pattern; for ( wxString::const_iterator p = pattern.begin(); p != pattern.end(); ++p )
wxChar *pat = WXSTRINGCAST(tmp);
while (*pat)
{ {
switch (*pat++) switch ( (*p).GetValue() )
{ {
case wxT('?'): case wxT('*'): case wxT('['): case wxT('{'): case wxT('?'):
return true; case wxT('*'):
case wxT('\\'): case wxT('['):
if (!*pat++) case wxT('{'):
return false; return true;
case wxT('\\'):
if ( ++p == pattern.end() )
return false;
} }
} }
return false; return false;

View File

@@ -873,7 +873,7 @@ public:
~wxMsgCatalogFile(); ~wxMsgCatalogFile();
// load the catalog from disk (szDirPrefix corresponds to language) // load the catalog from disk (szDirPrefix corresponds to language)
bool Load(const wxChar *szDirPrefix, const wxChar *szName, bool Load(const wxString& szDirPrefix, const wxString& szName,
wxPluralFormsCalculatorPtr& rPluralFormsCalculator); wxPluralFormsCalculatorPtr& rPluralFormsCalculator);
// fills the hash with string-translation pairs // fills the hash with string-translation pairs
@@ -1015,7 +1015,7 @@ wxMsgCatalogFile::~wxMsgCatalogFile()
// return the directories to search for message catalogs under the given // return the directories to search for message catalogs under the given
// prefix, separated by wxPATH_SEP // prefix, separated by wxPATH_SEP
static static
wxString GetMsgCatalogSubdirs(const wxChar *prefix, const wxChar *lang) wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang)
{ {
wxString searchPath; wxString searchPath;
searchPath << prefix << wxFILE_SEP_PATH << lang; searchPath << prefix << wxFILE_SEP_PATH << lang;
@@ -1037,7 +1037,7 @@ wxString GetMsgCatalogSubdirs(const wxChar *prefix, const wxChar *lang)
} }
// construct the search path for the given language // construct the search path for the given language
static wxString GetFullSearchPath(const wxChar *lang) static wxString GetFullSearchPath(const wxString& lang)
{ {
// first take the entries explicitly added by the program // first take the entries explicitly added by the program
wxArrayString paths; wxArrayString paths;
@@ -1097,7 +1097,7 @@ static wxString GetFullSearchPath(const wxChar *lang)
} }
// open disk file and read in it's contents // open disk file and read in it's contents
bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName, bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
wxPluralFormsCalculatorPtr& rPluralFormsCalculator) wxPluralFormsCalculatorPtr& rPluralFormsCalculator)
{ {
wxString searchPath; wxString searchPath;
@@ -1118,15 +1118,14 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName,
searchPath += GetFullSearchPath(szDirPrefix); searchPath += GetFullSearchPath(szDirPrefix);
const wxChar *sublocale = wxStrchr(szDirPrefix, wxT('_')); size_t sublocaleIndex = szDirPrefix.find(wxT('_'));
if ( sublocale ) if ( sublocaleIndex != wxString::npos )
{ {
// also add just base locale name: for things like "fr_BE" (belgium // also add just base locale name: for things like "fr_BE" (belgium
// french) we should use "fr" if no belgium specific message catalogs // french) we should use "fr" if no belgium specific message catalogs
// exist // exist
searchPath << wxPATH_SEP searchPath << wxPATH_SEP
<< GetFullSearchPath(wxString(szDirPrefix). << GetFullSearchPath(szDirPrefix.Left(sublocaleIndex));
Left((size_t)(sublocale - szDirPrefix)));
} }
// don't give translation errors here because the wxstd catalog might // don't give translation errors here because the wxstd catalog might
@@ -1546,7 +1545,7 @@ bool wxLocale::Init(const wxString& name,
256); 256);
if (ret != 0) if (ret != 0)
{ {
m_pszOldLocale = wxStrdup(localeName); m_pszOldLocale = wxStrdup(wxConvLibc.cWC2MB(localeName));
} }
else else
m_pszOldLocale = NULL; m_pszOldLocale = NULL;
@@ -1554,7 +1553,7 @@ bool wxLocale::Init(const wxString& name,
// TODO: how to find languageId // TODO: how to find languageId
// SetLocaleInfo(languageId, SORT_DEFAULT, localeName); // SetLocaleInfo(languageId, SORT_DEFAULT, localeName);
#else #else
wxMB2WXbuf oldLocale = wxSetlocale(LC_ALL, szLocale); const char *oldLocale = wxSetlocale(LC_ALL, szLocale);
if ( oldLocale ) if ( oldLocale )
m_pszOldLocale = wxStrdup(oldLocale); m_pszOldLocale = wxStrdup(oldLocale);
else else
@@ -1601,33 +1600,33 @@ bool wxLocale::Init(const wxString& name,
#if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WXMAC__) #if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WXMAC__)
static wxWCharBuffer wxSetlocaleTryUTF8(int c, const wxChar *lc) static const char *wxSetlocaleTryUTF8(int c, const wxString& lc)
{ {
wxMB2WXbuf l; const char *l;
// NB: We prefer to set UTF-8 locale if it's possible and only fall back to // NB: We prefer to set UTF-8 locale if it's possible and only fall back to
// non-UTF-8 locale if it fails // non-UTF-8 locale if it fails
if ( lc && lc[0] != 0 ) if ( !lc.empty() )
{ {
wxString buf(lc); wxString buf(lc);
wxString buf2; wxString buf2;
buf2 = buf + wxT(".UTF-8"); buf2 = buf + wxT(".UTF-8");
l = wxSetlocale(c, buf2.c_str()); l = wxSetlocale(c, buf2);
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".utf-8"); buf2 = buf + wxT(".utf-8");
l = wxSetlocale(c, buf2.c_str()); l = wxSetlocale(c, buf2);
} }
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".UTF8"); buf2 = buf + wxT(".UTF8");
l = wxSetlocale(c, buf2.c_str()); l = wxSetlocale(c, buf2);
} }
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".utf8"); buf2 = buf + wxT(".utf8");
l = wxSetlocale(c, buf2.c_str()); l = wxSetlocale(c, buf2);
} }
} }
@@ -1671,12 +1670,12 @@ bool wxLocale::Init(int language, int flags)
// Set the locale: // Set the locale:
#if defined(__OS2__) #if defined(__OS2__)
wxMB2WXbuf retloc = wxSetlocale(LC_ALL , wxEmptyString); const char *retloc = wxSetlocale(LC_ALL , wxEmptyString);
#elif defined(__UNIX__) && !defined(__WXMAC__) #elif defined(__UNIX__) && !defined(__WXMAC__)
if (language != wxLANGUAGE_DEFAULT) if (language != wxLANGUAGE_DEFAULT)
locale = info->CanonicalName; locale = info->CanonicalName;
wxMB2WXbuf retloc = wxSetlocaleTryUTF8(LC_ALL, locale); const char *retloc = wxSetlocaleTryUTF8(LC_ALL, locale);
const wxString langOnly = locale.Left(2); const wxString langOnly = locale.Left(2);
if ( !retloc ) if ( !retloc )
@@ -1743,9 +1742,9 @@ bool wxLocale::Init(int language, int flags)
// //
// this contradicts IBM own docs but this is not of much help, so just work // this contradicts IBM own docs but this is not of much help, so just work
// around it in the crudest possible manner // around it in the crudest possible manner
wxChar *p = wxStrchr((wxChar *)retloc, _T(' ')); char *p = wxStrchr(retloc, ' ');
if ( p ) if ( p )
*p = _T('\0'); *p = '\0';
#endif // __AIX__ #endif // __AIX__
#elif defined(__WIN32__) #elif defined(__WIN32__)
@@ -1760,10 +1759,7 @@ bool wxLocale::Init(int language, int flags)
#define SETLOCALE_FAILS_ON_UNICODE_LANGS #define SETLOCALE_FAILS_ON_UNICODE_LANGS
#endif #endif
#if !wxUSE_UNICODE const char *retloc = "C";
const
#endif
wxMB2WXbuf retloc = wxT("C");
if (language != wxLANGUAGE_DEFAULT) if (language != wxLANGUAGE_DEFAULT)
{ {
if (info->WinLang == 0) if (info->WinLang == 0)
@@ -1812,9 +1808,9 @@ bool wxLocale::Init(int language, int flags)
retloc = wxSetlocale(LC_ALL, locale); retloc = wxSetlocale(LC_ALL, locale);
#endif #endif
#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
if (codepage == 0 && (const wxChar*)retloc == NULL) if (codepage == 0 && retloc == NULL)
{ {
retloc = wxT("C"); retloc = "C";
} }
#endif #endif
} }
@@ -1829,14 +1825,14 @@ bool wxLocale::Init(int language, int flags)
retloc = NULL; retloc = NULL;
#endif #endif
#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
if ((const wxChar*)retloc == NULL) if (retloc == NULL)
{ {
wxChar buffer[16]; wxChar buffer[16];
if (GetLocaleInfo(LOCALE_USER_DEFAULT, if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 && LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
wxStrcmp(buffer, wxT("0")) == 0) wxStrcmp(buffer, wxT("0")) == 0)
{ {
retloc = wxT("C"); retloc = "C";
} }
} }
#endif #endif
@@ -1853,7 +1849,7 @@ bool wxLocale::Init(int language, int flags)
else else
locale = info->CanonicalName; locale = info->CanonicalName;
wxMB2WXbuf retloc = wxSetlocale(LC_ALL, locale); const char *retloc = wxSetlocale(LC_ALL, locale);
if ( !retloc ) if ( !retloc )
{ {
@@ -2561,7 +2557,7 @@ const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale)
// looking // looking
// //
// OTOH, maybe we had already found a language match and in this // OTOH, maybe we had already found a language match and in this
// case don't overwrite it becauce the entry for the default // case don't overwrite it because the entry for the default
// country always appears first in ms_languagesDB // country always appears first in ms_languagesDB
if ( !infoRet ) if ( !infoRet )
infoRet = info; infoRet = info;
@@ -2763,10 +2759,10 @@ bool wxLocale::IsAvailable(int lang)
return false; return false;
#elif defined(__UNIX__) #elif defined(__UNIX__)
// Test if setting the locale works, then set it back. // Test if setting the locale works, then set it back.
wxMB2WXbuf oldLocale = wxSetlocale(LC_ALL, wxEmptyString); const char *oldLocale = wxSetlocale(LC_ALL, "");
wxMB2WXbuf tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName); const char *tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName);
if ( !tmp ) if ( !tmp )
{ {
// Some C libraries don't like xx_YY form and require xx only // Some C libraries don't like xx_YY form and require xx only
@@ -2775,8 +2771,8 @@ bool wxLocale::IsAvailable(int lang)
return false; return false;
} }
// restore the original locale // restore the original locale
wxSetlocale(LC_ALL, oldLocale); wxSetlocale(LC_ALL, oldLocale);
#endif #endif
return true; return true;
} }

View File

@@ -56,7 +56,11 @@
#ifdef __REG_NOFRONT #ifdef __REG_NOFRONT
# define WXREGEX_USING_BUILTIN # define WXREGEX_USING_BUILTIN
# define WXREGEX_IF_NEED_LEN(x) ,x # define WXREGEX_IF_NEED_LEN(x) ,x
# define WXREGEX_CHAR(x) x # if wxUSE_UNICODE
# define WXREGEX_CHAR(x) x.wc_str()
# else
# define WXREGEX_CHAR(x) x.mb_str()
# endif
#else #else
# ifdef HAVE_RE_SEARCH # ifdef HAVE_RE_SEARCH
# define WXREGEX_IF_NEED_LEN(x) ,x # define WXREGEX_IF_NEED_LEN(x) ,x
@@ -67,7 +71,7 @@
# if wxUSE_UNICODE # if wxUSE_UNICODE
# define WXREGEX_CONVERT_TO_MB # define WXREGEX_CONVERT_TO_MB
# endif # endif
# define WXREGEX_CHAR(x) wxConvertWX2MB(x) # define WXREGEX_CHAR(x) x.mb_str()
# define wx_regfree regfree # define wx_regfree regfree
# define wx_regerror regerror # define wx_regerror regerror
#endif #endif
@@ -293,8 +297,11 @@ bool wxRegExImpl::Compile(const wxString& expr, int flags)
// compile it // compile it
#ifdef WXREGEX_USING_BUILTIN #ifdef WXREGEX_USING_BUILTIN
bool conv = true; bool conv = true;
int errorcode = wx_re_comp(&m_RegEx, expr, expr.length(), flagsRE); // FIXME-UTF8: use wc_str() after removing ANSI build
int errorcode = wx_re_comp(&m_RegEx, expr.c_str(), expr.length(), flagsRE);
#else #else
// FIXME-UTF8: this is potentially broken, we shouldn't even try it
// and should always use builtin regex library (or PCRE?)
const wxWX2MBbuf conv = expr.mbc_str(); const wxWX2MBbuf conv = expr.mbc_str();
int errorcode = conv ? regcomp(&m_RegEx, conv, flagsRE) : REG_BADPAT; int errorcode = conv ? regcomp(&m_RegEx, conv, flagsRE) : REG_BADPAT;
#endif #endif

View File

@@ -565,6 +565,12 @@ wxString operator+(const wchar_t *pwz, const wxString& str)
// string comparison // string comparison
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool wxString::IsSameAs(wxUniChar c, bool compareWithCase) const
{
return (length() == 1) && (compareWithCase ? GetChar(0u) == c
: wxToupper(GetChar(0u)) == wxToupper(c));
}
#ifdef HAVE_STD_STRING_COMPARE #ifdef HAVE_STD_STRING_COMPARE
// NB: Comparison code (both if HAVE_STD_STRING_COMPARE and if not) works with // NB: Comparison code (both if HAVE_STD_STRING_COMPARE and if not) works with
@@ -1376,14 +1382,15 @@ int wxString::Find(wxUniChar ch, bool bFromEnd) const
// conversion to numbers // conversion to numbers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the implementation of all the functions below is exactly the same so factor // The implementation of all the functions below is exactly the same so factor
// it out // it out. Note that number extraction works correctly on UTF-8 strings, so
// we can use wxStringCharType and wx_str() for maximum efficiency.
template <typename T, typename F> template <typename T>
bool wxStringToIntType(const wxChar *start, bool wxStringToIntType(const wxStringCharType *start,
T *val, T *val,
int base, int base,
F func) T (*func)(const wxStringCharType*, wxStringCharType**, int))
{ {
wxCHECK_MSG( val, false, _T("NULL output pointer") ); wxCHECK_MSG( val, false, _T("NULL output pointer") );
wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") );
@@ -1392,7 +1399,7 @@ bool wxStringToIntType(const wxChar *start,
errno = 0; errno = 0;
#endif #endif
wxChar *end; wxStringCharType *end;
*val = (*func)(start, &end, base); *val = (*func)(start, &end, base);
// return true only if scan was stopped by the terminating NUL and if the // return true only if scan was stopped by the terminating NUL and if the
@@ -1406,22 +1413,22 @@ bool wxStringToIntType(const wxChar *start,
bool wxString::ToLong(long *val, int base) const bool wxString::ToLong(long *val, int base) const
{ {
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtol); return wxStringToIntType(wx_str(), val, base, wxStrtol);
} }
bool wxString::ToULong(unsigned long *val, int base) const bool wxString::ToULong(unsigned long *val, int base) const
{ {
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoul); return wxStringToIntType(wx_str(), val, base, wxStrtoul);
} }
bool wxString::ToLongLong(wxLongLong_t *val, int base) const bool wxString::ToLongLong(wxLongLong_t *val, int base) const
{ {
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoll); return wxStringToIntType(wx_str(), val, base, wxStrtoll);
} }
bool wxString::ToULongLong(wxULongLong_t *val, int base) const bool wxString::ToULongLong(wxULongLong_t *val, int base) const
{ {
return wxStringToIntType((const wxChar*)c_str(), val, base, wxStrtoull); return wxStringToIntType(wx_str(), val, base, wxStrtoull);
} }
bool wxString::ToDouble(double *val) const bool wxString::ToDouble(double *val) const
@@ -1579,14 +1586,19 @@ static int DoStringPrintfV(wxString& str,
// buffer were large enough (newer standards such as Unix98) // buffer were large enough (newer standards such as Unix98)
if ( len < 0 ) if ( len < 0 )
{ {
// NB: wxVsnprintf() may call either wxCRT_VsnprintfW or
// wxCRT_VsnprintfA in UTF-8 build; wxUSE_WXVSNPRINTF
// is true if *both* of them use our own implementation,
// otherwise we can't be sure
#if wxUSE_WXVSNPRINTF #if wxUSE_WXVSNPRINTF
// we know that our own implementation of wxVsnprintf() returns -1 // we know that our own implementation of wxVsnprintf() returns -1
// only for a format error - thus there's something wrong with // only for a format error - thus there's something wrong with
// the user's format string // the user's format string
return -1; return -1;
#else // assume that system version only returns error if not enough space #else // possibly using system version
// still not enough, as we don't know how much we need, double the // assume it only returns error if there is not enough space, but
// current size of the buffer // as we don't know how much we need, double the current size of
// the buffer
size *= 2; size *= 2;
#endif // wxUSE_WXVSNPRINTF/!wxUSE_WXVSNPRINTF #endif // wxUSE_WXVSNPRINTF/!wxUSE_WXVSNPRINTF
} }

View File

@@ -162,9 +162,9 @@ void wxStringImpl::InitWith(const wxStringCharType *psz,
// if the length is not given, assume the string to be NUL terminated // if the length is not given, assume the string to be NUL terminated
if ( nLength == npos ) { if ( nLength == npos ) {
wxASSERT_MSG( nPos <= Strsize(psz), _T("index out of bounds") ); wxASSERT_MSG( nPos <= wxStrlen(psz), _T("index out of bounds") );
nLength = Strsize(psz + nPos); nLength = wxStrlen(psz + nPos);
} }
STATISTICS_ADD(InitialLength, nLength); STATISTICS_ADD(InitialLength, nLength);
@@ -426,7 +426,7 @@ wxStringImpl& wxStringImpl::insert(size_t nPos,
{ {
wxASSERT( nPos <= length() ); wxASSERT( nPos <= length() );
if ( n == npos ) n = Strsize(sz); if ( n == npos ) n = wxStrlen(sz);
if ( n == 0 ) return *this; if ( n == 0 ) return *this;
if ( !Alloc(length() + n) || !CopyBeforeWrite() ) { if ( !Alloc(length() + n) || !CopyBeforeWrite() ) {
@@ -666,7 +666,7 @@ wxStringImpl& wxStringImpl::operator=(wxStringCharType ch)
// assigns C string // assigns C string
wxStringImpl& wxStringImpl::operator=(const wxStringCharType *psz) wxStringImpl& wxStringImpl::operator=(const wxStringCharType *psz)
{ {
if ( !AssignCopy(Strsize(psz), psz) ) { if ( !AssignCopy(wxStrlen(psz), psz) ) {
wxFAIL_MSG( _T("out of memory in wxStringImpl::operator=(const wxStringCharType *)") ); wxFAIL_MSG( _T("out of memory in wxStringImpl::operator=(const wxStringCharType *)") );
} }
return *this; return *this;
@@ -769,7 +769,7 @@ wxStringCharType *wxStringImpl::DoGetWriteBuf(size_t nLen)
// put string back in a reasonable state after GetWriteBuf // put string back in a reasonable state after GetWriteBuf
void wxStringImpl::DoUngetWriteBuf() void wxStringImpl::DoUngetWriteBuf()
{ {
DoUngetWriteBuf(Strsize(m_pchData)); DoUngetWriteBuf(wxStrlen(m_pchData));
} }
void wxStringImpl::DoUngetWriteBuf(size_t nLen) void wxStringImpl::DoUngetWriteBuf(size_t nLen)

View File

@@ -286,7 +286,7 @@ bool wxVariantDataLong::Read(wxInputStream& str)
bool wxVariantDataLong::Read(wxString& str) bool wxVariantDataLong::Read(wxString& str)
{ {
m_value = wxAtol((const wxChar*) str); m_value = wxAtol(str);
return true; return true;
} }
@@ -436,7 +436,7 @@ bool wxVariantDoubleData::Read(wxInputStream& str)
bool wxVariantDoubleData::Read(wxString& str) bool wxVariantDoubleData::Read(wxString& str)
{ {
m_value = wxAtof((const wxChar*) str); m_value = wxAtof(str);
return true; return true;
} }
@@ -579,7 +579,7 @@ bool wxVariantDataBool::Read(wxInputStream& str)
bool wxVariantDataBool::Read(wxString& str) bool wxVariantDataBool::Read(wxString& str)
{ {
m_value = (wxAtol((const wxChar*) str) != 0); m_value = (wxAtol(str) != 0);
return true; return true;
} }
@@ -1239,7 +1239,7 @@ bool wxVariantDataDateTime::Read(wxSTD istream& WXUNUSED(str))
bool wxVariantDataDateTime::Read(wxString& str) bool wxVariantDataDateTime::Read(wxString& str)
{ {
if(! m_value.ParseDateTime(str)) if(! m_value.ParseDateTime(str.c_str()/*FIXME-UTF8*/))
return false; return false;
return true; return true;
} }
@@ -1757,7 +1757,7 @@ bool wxVariant::Convert(long* value) const
*value = (long) (((wxVariantDataBool*)GetData())->GetValue()); *value = (long) (((wxVariantDataBool*)GetData())->GetValue());
#endif #endif
else if (type == wxT("string")) else if (type == wxT("string"))
*value = wxAtol((const wxChar*) ((wxVariantDataString*)GetData())->GetValue()); *value = wxAtol(((wxVariantDataString*)GetData())->GetValue());
else else
return false; return false;
@@ -1804,7 +1804,7 @@ bool wxVariant::Convert(double* value) const
*value = (double) (((wxVariantDataBool*)GetData())->GetValue()); *value = (double) (((wxVariantDataBool*)GetData())->GetValue());
#endif #endif
else if (type == wxT("string")) else if (type == wxT("string"))
*value = (double) wxAtof((const wxChar*) ((wxVariantDataString*)GetData())->GetValue()); *value = (double) wxAtof(((wxVariantDataString*)GetData())->GetValue());
else else
return false; return false;
@@ -1846,7 +1846,9 @@ bool wxVariant::Convert(wxDateTime* value) const
// Fallback to string conversion // Fallback to string conversion
wxString val; wxString val;
return Convert(&val) && return Convert(&val) &&
(value->ParseDateTime(val) || value->ParseDate(val) || value->ParseTime(val)); (value->ParseDateTime(val.c_str()/*FIXME-UTF8*/) ||
value->ParseDate(val.c_str()/*FIXME-UTF8*/) ||
value->ParseTime(val.c_str()/*FIXME-UTF8*/));
} }
#endif // wxUSE_DATETIME #endif // wxUSE_DATETIME

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,7 @@ using namespace std ;
// special test mode: define all functions below even if we don't really need // special test mode: define all functions below even if we don't really need
// them to be able to test them // them to be able to test them
#ifdef wxTEST_PRINTF #ifdef wxTEST_PRINTF
#undef wxVsnprintf_ #undef wxCRT_VsnprintfW_
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -53,13 +53,13 @@ using namespace std ;
// (very useful for i18n purposes) // (very useful for i18n purposes)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !defined(wxVsnprintf_) #if !defined(wxCRT_VsnprintfW_)
#if !wxUSE_WXVSNPRINTF #if !wxUSE_WXVSNPRINTFW
#error wxUSE_WXVSNPRINTF must be 1 if our wxVsnprintf_ is used #error "wxUSE_WXVSNPRINTFW must be 1 if our wxCRT_VsnprintfW_ is used"
#endif #endif
// wxUSE_STRUTILS says our wxVsnprintf_ implementation to use or not to // wxUSE_STRUTILS says our wxCRT_VsnprintfW_ implementation to use or not to
// use wxStrlen and wxStrncpy functions over one-char processing loops. // use wxStrlen and wxStrncpy functions over one-char processing loops.
// //
// Some benchmarking revealed that wxUSE_STRUTILS == 1 has the following // Some benchmarking revealed that wxUSE_STRUTILS == 1 has the following
@@ -99,7 +99,7 @@ using namespace std ;
#define SYSTEM_SPRINTF_IS_UNSAFE #define SYSTEM_SPRINTF_IS_UNSAFE
#endif #endif
// the conversion specifiers accepted by wxVsnprintf_ // the conversion specifiers accepted by wxCRT_VsnprintfW_
enum wxPrintfArgType { enum wxPrintfArgType {
wxPAT_INVALID = -1, wxPAT_INVALID = -1,
@@ -126,7 +126,7 @@ enum wxPrintfArgType {
wxPAT_NLONGINT // %ln wxPAT_NLONGINT // %ln
}; };
// an argument passed to wxVsnprintf_ // an argument passed to wxCRT_VsnprintfW_
typedef union { typedef union {
int pad_int; // %d, %i, %o, %u, %x, %X int pad_int; // %d, %i, %o, %u, %x, %X
long int pad_longint; // %ld, etc long int pad_longint; // %ld, etc
@@ -152,7 +152,7 @@ typedef union {
// Contains parsed data relative to a conversion specifier given to // Contains parsed data relative to a conversion specifier given to
// wxVsnprintf_ and parsed from the format string // wxCRT_VsnprintfW_ and parsed from the format string
// NOTE: in C++ there is almost no difference between struct & classes thus // NOTE: in C++ there is almost no difference between struct & classes thus
// there is no performance gain by using a struct here... // there is no performance gain by using a struct here...
class wxPrintfConvSpec class wxPrintfConvSpec
@@ -176,18 +176,18 @@ public:
// pointer to the '%' of this conversion specifier in the format string // pointer to the '%' of this conversion specifier in the format string
// NOTE: this points somewhere in the string given to the Parse() function - // NOTE: this points somewhere in the string given to the Parse() function -
// it's task of the caller ensure that memory is still valid ! // it's task of the caller ensure that memory is still valid !
const wxChar *m_pArgPos; const wchar_t *m_pArgPos;
// pointer to the last character of this conversion specifier in the // pointer to the last character of this conversion specifier in the
// format string // format string
// NOTE: this points somewhere in the string given to the Parse() function - // NOTE: this points somewhere in the string given to the Parse() function -
// it's task of the caller ensure that memory is still valid ! // it's task of the caller ensure that memory is still valid !
const wxChar *m_pArgEnd; const wchar_t *m_pArgEnd;
// a little buffer where formatting flags like #+\.hlqLZ are stored by Parse() // a little buffer where formatting flags like #+\.hlqLZ are stored by Parse()
// for use in Process() // for use in Process()
// NB: even if this buffer is used only for numeric conversion specifiers and // NB: even if this buffer is used only for numeric conversion specifiers and
// thus could be safely declared as a char[] buffer, we want it to be wxChar // thus could be safely declared as a char[] buffer, we want it to be wchar_t
// so that in Unicode builds we can avoid to convert its contents to Unicode // so that in Unicode builds we can avoid to convert its contents to Unicode
// chars when copying it in user's buffer. // chars when copying it in user's buffer.
char m_szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN]; char m_szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN];
@@ -196,19 +196,19 @@ public:
public: public:
// we don't declare this as a constructor otherwise it would be called // we don't declare this as a constructor otherwise it would be called
// automatically and we don't want this: to be optimized, wxVsnprintf_ // automatically and we don't want this: to be optimized, wxCRT_VsnprintfW_
// calls this function only on really-used instances of this class. // calls this function only on really-used instances of this class.
void Init(); void Init();
// Parses the first conversion specifier in the given string, which must // Parses the first conversion specifier in the given string, which must
// begin with a '%'. Returns false if the first '%' does not introduce a // begin with a '%'. Returns false if the first '%' does not introduce a
// (valid) conversion specifier and thus should be ignored. // (valid) conversion specifier and thus should be ignored.
bool Parse(const wxChar *format); bool Parse(const wchar_t *format);
// Process this conversion specifier and puts the result in the given // Process this conversion specifier and puts the result in the given
// buffer. Returns the number of characters written in 'buf' or -1 if // buffer. Returns the number of characters written in 'buf' or -1 if
// there's not enough space. // there's not enough space.
int Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t written); int Process(wchar_t *buf, size_t lenMax, wxPrintfArg *p, size_t written);
// Loads the argument of this conversion specifier from given va_list. // Loads the argument of this conversion specifier from given va_list.
bool LoadArg(wxPrintfArg *p, va_list &argptr); bool LoadArg(wxPrintfArg *p, va_list &argptr);
@@ -232,7 +232,7 @@ void wxPrintfConvSpec::Init()
m_szFlags[0] = '%'; m_szFlags[0] = '%';
} }
bool wxPrintfConvSpec::Parse(const wxChar *format) bool wxPrintfConvSpec::Parse(const wchar_t *format)
{ {
bool done = false; bool done = false;
@@ -254,7 +254,7 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
} }
// what follows '%'? // what follows '%'?
const wxChar ch = *(++m_pArgEnd); const wchar_t ch = *(++m_pArgEnd);
switch ( ch ) switch ( ch )
{ {
case wxT('\0'): case wxT('\0'):
@@ -637,7 +637,7 @@ bool wxPrintfConvSpec::LoadArg(wxPrintfArg *p, va_list &argptr)
return true; // loading was successful return true; // loading was successful
} }
int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t written) int wxPrintfConvSpec::Process(wchar_t *buf, size_t lenMax, wxPrintfArg *p, size_t written)
{ {
// buffer to avoid dynamic memory allocation each time for small strings; // buffer to avoid dynamic memory allocation each time for small strings;
// note that this buffer is used only to hold results of number formatting, // note that this buffer is used only to hold results of number formatting,
@@ -688,7 +688,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t
case wxPAT_CHAR: case wxPAT_CHAR:
case wxPAT_WCHAR: case wxPAT_WCHAR:
{ {
wxChar val = wchar_t val =
#if wxUSE_UNICODE #if wxUSE_UNICODE
p->pad_wchar; p->pad_wchar;
@@ -820,11 +820,11 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t
// conversion, but we can optimise by making use of the fact // conversion, but we can optimise by making use of the fact
// that we are formatting numbers, this should mean only 7-bit // that we are formatting numbers, this should mean only 7-bit
// ascii characters are involved. // ascii characters are involved.
wxChar *bufptr = buf; wchar_t *bufptr = buf;
const wxChar *bufend = buf + lenMax; const wchar_t *bufend = buf + lenMax;
const char *scratchptr = szScratch; const char *scratchptr = szScratch;
// Simply copy each char to a wxChar, stopping on the first // Simply copy each char to a wchar_t, stopping on the first
// null or non-ascii byte. Checking '(signed char)*scratchptr // null or non-ascii byte. Checking '(signed char)*scratchptr
// > 0' is an extra optimisation over '*scratchptr != 0 && // > 0' is an extra optimisation over '*scratchptr != 0 &&
// isascii(*scratchptr)', though it assumes signed char is // isascii(*scratchptr)', though it assumes signed char is
@@ -866,9 +866,9 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t
// //
static int wxCopyStrWithPercents( static int wxCopyStrWithPercents(
size_t maxOut, size_t maxOut,
wxChar *dest, wchar_t *dest,
size_t maxIn, size_t maxIn,
const wxChar *source) const wchar_t *source)
{ {
size_t written = 0; size_t written = 0;
@@ -894,13 +894,13 @@ static int wxCopyStrWithPercents(
return written; return written;
} }
int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax, int WXDLLEXPORT wxCRT_VsnprintfW_(wchar_t *buf, size_t lenMax,
const wxChar *format, va_list argptr) const wchar_t *format, va_list argptr)
{ {
// useful for debugging, to understand if we are really using this function // useful for debugging, to understand if we are really using this function
// rather than the system implementation // rather than the system implementation
#if 0 #if 0
wprintf(L"Using wxVsnprintf_\n"); wprintf(L"Using wxCRT_VsnprintfW_\n");
#endif #endif
// required memory: // required memory:
@@ -914,7 +914,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
size_t lenCur = 0; size_t lenCur = 0;
size_t nargs = 0; size_t nargs = 0;
const wxChar *toparse = format; const wchar_t *toparse = format;
// parse the format string // parse the format string
bool posarg_present = false, nonposarg_present = false; bool posarg_present = false, nonposarg_present = false;
@@ -1053,10 +1053,10 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
#undef APPEND_CH #undef APPEND_CH
#undef CHECK_PREC #undef CHECK_PREC
#else // wxVsnprintf_ is defined #else // wxCRT_VsnprintfW_ is defined
#if wxUSE_WXVSNPRINTF #if wxUSE_WXVSNPRINTFW
#error wxUSE_WXVSNPRINTF must be 0 if our wxVsnprintf_ is not used #error "wxUSE_WXVSNPRINTFW must be 0 if our wxCRT_VsnprintfW_ is not used"
#endif #endif
#endif // !wxVsnprintf_ #endif // !wxCRT_VsnprintfW_

View File

@@ -332,7 +332,7 @@ struct wxMSWCommandLineArguments
argv = new wxChar *[argc + 1]; argv = new wxChar *[argc + 1];
for ( int i = 0; i < argc; i++ ) for ( int i = 0; i < argc; i++ )
{ {
argv[i] = wxStrdup(args[i]); argv[i] = wxStrdup(args[i].wx_str());
} }
// argv[] must be NULL-terminated // argv[] must be NULL-terminated

View File

@@ -147,29 +147,39 @@ WXDLLEXPORT int wxMSLU_GetSaveFileNameW(void *ofn)
#if wxUSE_BASE #if wxUSE_BASE
WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname,
const wxChar *newname) const wchar_t *newname)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return rename(wxConvFile.cWX2MB(oldname), wxConvFile.cWX2MB(newname)); return rename(wxConvFile.cWX2MB(oldname), wxConvFile.cWX2MB(newname));
else else
return _trename(oldname, newname); return _wrename(oldname, newname);
} }
WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name) WXDLLIMPEXP_BASE int wxMSLU__wremove(const wchar_t *name)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return remove(wxConvFile.cWX2MB(name)); return remove(wxConvFile.cWX2MB(name));
else else
return _tremove(name); return _wremove(name);
} }
WXDLLIMPEXP_BASE FILE* wxMSLU__tfopen(const wxChar *name,const wxChar* mode) WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name,const wchar_t* mode)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return fopen(wxConvFile.cWX2MB(name),wxConvFile.cWX2MB(mode)); return fopen(wxConvFile.cWX2MB(name),wxConvFile.cWX2MB(mode));
else else
return _tfopen(name,mode); return _wfopen(name,mode);
}
WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name,
const wchar_t* mode,
FILE *stream)
{
if ( wxUsingUnicowsDll() )
return freopen(wxConvFile.cWX2MB(name), wxConvFile.cWX2MB(mode), stream);
else
return _wfreopen(name, mode, stream);
} }
#if defined( __VISUALC__ ) \ #if defined( __VISUALC__ ) \
@@ -177,7 +187,7 @@ WXDLLIMPEXP_BASE FILE* wxMSLU__tfopen(const wxChar *name,const wxChar* mode)
|| ( defined(__MWERKS__) && defined(__WXMSW__) ) \ || ( defined(__MWERKS__) && defined(__WXMSW__) ) \
|| ( defined(__BORLANDC__) && (__BORLANDC__ > 0x460) ) || ( defined(__BORLANDC__) && (__BORLANDC__ > 0x460) )
WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, int flags, int mode) WXDLLIMPEXP_BASE int wxMSLU__wopen(const wchar_t *name, int flags, int mode)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
#ifdef __BORLANDC__ #ifdef __BORLANDC__
@@ -189,7 +199,7 @@ WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, int flags, int mode)
return _wopen(name, flags, mode); return _wopen(name, flags, mode);
} }
WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name, int mode) WXDLLIMPEXP_BASE int wxMSLU__waccess(const wchar_t *name, int mode)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _access(wxConvFile.cWX2MB(name), mode); return _access(wxConvFile.cWX2MB(name), mode);
@@ -197,7 +207,7 @@ WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name, int mode)
return _waccess(name, mode); return _waccess(name, mode);
} }
WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name) WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wchar_t *name)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _mkdir(wxConvFile.cWX2MB(name)); return _mkdir(wxConvFile.cWX2MB(name));
@@ -205,7 +215,7 @@ WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name)
return _wmkdir(name); return _wmkdir(name);
} }
WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name) WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wchar_t *name)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _rmdir(wxConvFile.cWX2MB(name)); return _rmdir(wxConvFile.cWX2MB(name));
@@ -213,7 +223,7 @@ WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name)
return _wrmdir(name); return _wrmdir(name);
} }
WXDLLIMPEXP_BASE int wxMSLU__wstat(const wxChar *name, struct _stat *buffer) WXDLLIMPEXP_BASE int wxMSLU__wstat(const wchar_t *name, struct _stat *buffer)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _stat((const char*)wxConvFile.cWX2MB(name), buffer); return _stat((const char*)wxConvFile.cWX2MB(name), buffer);
@@ -224,7 +234,7 @@ WXDLLIMPEXP_BASE int wxMSLU__wstat(const wxChar *name, struct _stat *buffer)
#ifdef __BORLANDC__ #ifdef __BORLANDC__
//here _stati64 is defined as stati64, see wx/filefn.h //here _stati64 is defined as stati64, see wx/filefn.h
#undef _stati64 #undef _stati64
WXDLLIMPEXP_BASE int wxMSLU__wstati64(const wxChar *name, struct _stati64 *buffer) WXDLLIMPEXP_BASE int wxMSLU__wstati64(const wchar_t *name, struct _stati64 *buffer)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _stati64((const char*)wxConvFile.cWX2MB(name), (stati64 *) buffer); return _stati64((const char*)wxConvFile.cWX2MB(name), (stati64 *) buffer);
@@ -232,7 +242,7 @@ WXDLLIMPEXP_BASE int wxMSLU__wstati64(const wxChar *name, struct _stati64 *buffe
return _wstati64(name, (stati64 *) buffer); return _wstati64(name, (stati64 *) buffer);
} }
#else #else
WXDLLIMPEXP_BASE int wxMSLU__wstati64(const wxChar *name, struct _stati64 *buffer) WXDLLIMPEXP_BASE int wxMSLU__wstati64(const wchar_t *name, struct _stati64 *buffer)
{ {
if ( wxUsingUnicowsDll() ) if ( wxUsingUnicowsDll() )
return _stati64((const char*)wxConvFile.cWX2MB(name), buffer); return _stati64((const char*)wxConvFile.cWX2MB(name), buffer);

View File

@@ -34,7 +34,7 @@
#ifdef __WXWINCE__ #ifdef __WXWINCE__
#include "wx/msw/wince/missing.h" #include "wx/msw/wince/missing.h"
int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode)) int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode))
{ {
DWORD access = 0; DWORD access = 0;
DWORD shareMode = 0; DWORD shareMode = 0;
@@ -97,7 +97,7 @@ int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode))
return fd; return fd;
} }
int wxAccess(const wxChar *name, int WXUNUSED(how)) int wxCRT_Access(const wxChar *name, int WXUNUSED(how))
{ {
HANDLE fileHandle = ::CreateFile(name, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, HANDLE fileHandle = ::CreateFile(name, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

View File

@@ -5229,7 +5229,7 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel),
// menu creation code // menu creation code
wxMenuItem *item = (wxMenuItem*)mii.dwItemData; wxMenuItem *item = (wxMenuItem*)mii.dwItemData;
const wxChar *p = wxStrchr(item->GetText(), _T('&')); const wxChar *p = wxStrchr(item->GetText().wx_str(), _T('&'));
while ( p++ ) while ( p++ )
{ {
if ( *p == _T('&') ) if ( *p == _T('&') )

View File

@@ -634,9 +634,9 @@ static struct cclass {
*/ */
#define Tcl_UniChar wxChar #define Tcl_UniChar wxChar
Tcl_UniChar Tcl_UniCharToUpper(int ch) { return wxToupper(ch); } Tcl_UniChar Tcl_UniCharToUpper(int ch) { return wxCRT_ToupperNative(ch); }
Tcl_UniChar Tcl_UniCharToLower(int ch) { return wxTolower(ch); } Tcl_UniChar Tcl_UniCharToLower(int ch) { return wxCRT_TolowerNative(ch); }
Tcl_UniChar Tcl_UniCharToTitle(int ch) { return wxToupper(ch); } Tcl_UniChar Tcl_UniCharToTitle(int ch) { return wxCRT_ToupperNative(ch); }
#endif /* !wxUSE_UNICODE */ #endif /* !wxUSE_UNICODE */
@@ -703,7 +703,7 @@ element(v, startp, endp)
/* search table */ /* search table */
for (cn=cnames; cn->name!=NULL; cn++) { for (cn=cnames; cn->name!=NULL; cn++) {
if (wxStrlen_(cn->name)==len && wxStrncmp(cn->name, startp, len)==0) { if (wxCRT_StrlenNative(cn->name)==len && wxCRT_StrncmpNative(cn->name, startp, len)==0) {
break; /* NOTE BREAK OUT */ break; /* NOTE BREAK OUT */
} }
} }
@@ -871,8 +871,8 @@ cclass(v, startp, endp, cases)
* Remap lower and upper to alpha if the match is case insensitive. * Remap lower and upper to alpha if the match is case insensitive.
*/ */
if (cases && len == 5 && (wxStrncmp(_T("lower"), np, 5) == 0 if (cases && len == 5 && (wxCRT_StrncmpNative(_T("lower"), np, 5) == 0
|| wxStrncmp(_T("upper"), np, 5) == 0)) { || wxCRT_StrncmpNative(_T("upper"), np, 5) == 0)) {
np = _T("alpha"); np = _T("alpha");
} }
@@ -882,7 +882,7 @@ cclass(v, startp, endp, cases)
index = -1; index = -1;
for (namePtr=classNames,i=0 ; *namePtr!=NULL ; namePtr++,i++) { for (namePtr=classNames,i=0 ; *namePtr!=NULL ; namePtr++,i++) {
if ((wxStrlen_(*namePtr) == len) && (wxStrncmp(*namePtr, np, len) == 0)) { if ((wxCRT_StrlenNative(*namePtr) == len) && (wxCRT_StrncmpNative(*namePtr, np, len) == 0)) {
index = i; index = i;
break; break;
} }
@@ -1057,11 +1057,11 @@ int cases; /* case-independent? */
/* find the name */ /* find the name */
len = endp - startp; len = endp - startp;
np = startp; np = startp;
if (cases && len == 5 && (wxStrncmp(_T("lower"), np, 5) == 0 || if (cases && len == 5 && (wxCRT_StrncmpNative(_T("lower"), np, 5) == 0 ||
wxStrncmp(_T("upper"), np, 5) == 0)) wxCRT_StrncmpNative(_T("upper"), np, 5) == 0))
np = _T("alpha"); np = _T("alpha");
for (cc = cclasses; cc->name != NULL; cc++) for (cc = cclasses; cc->name != NULL; cc++)
if (wxStrlen_(cc->name) == len && wxStrncmp(cc->name, np, len) == 0) if (wxCRT_StrlenNative(cc->name) == len && wxCRT_StrncmpNative(cc->name, np, len) == 0)
break; /* NOTE BREAK OUT */ break; /* NOTE BREAK OUT */
if (cc->name == NULL) { if (cc->name == NULL) {
ERR(REG_ECTYPE); ERR(REG_ECTYPE);

View File

@@ -38,7 +38,7 @@
/* must include this after ctype.h inclusion for CodeWarrior/Mac */ /* must include this after ctype.h inclusion for CodeWarrior/Mac */
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/chartype.h" #include "wx/chartype.h"
#include "wx/wxcrt.h" #include "wx/wxcrtbase.h"
/* /*
* Do not insert extras between the "begin" and "end" lines -- this * Do not insert extras between the "begin" and "end" lines -- this

View File

@@ -36,9 +36,15 @@ public:
private: private:
CPPUNIT_TEST_SUITE( CrtTestCase ); CPPUNIT_TEST_SUITE( CrtTestCase );
CPPUNIT_TEST( SetGetEnv ); CPPUNIT_TEST( SetGetEnv );
CPPUNIT_TEST( Strcmp );
CPPUNIT_TEST( Strspn );
CPPUNIT_TEST( Strcspn );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
void SetGetEnv(); void SetGetEnv();
void Strcmp();
void Strspn();
void Strcspn();
DECLARE_NO_COPY_CLASS(CrtTestCase) DECLARE_NO_COPY_CLASS(CrtTestCase)
}; };
@@ -61,3 +67,112 @@ void CrtTestCase::SetGetEnv()
CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) ); CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) );
CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false ); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false );
} }
void CrtTestCase::Strcmp()
{
// this code tests if all possible ways of calling wxStrcmp() compile:
const char * const char1 = "first";
const wchar_t * const wchar1 = L"first";
wxString str1("first");
wxCStrData cstr1(str1.c_str());
wxCharBuffer charbuf1(char1);
wxWCharBuffer wcharbuf1(wchar1);
const char * const char2 = "last";
const wchar_t * const wchar2 = L"last";
wxString str2("last");
wxCStrData cstr2(str2.c_str());
wxCharBuffer charbuf2(char2);
wxWCharBuffer wcharbuf2(wchar2);
CPPUNIT_ASSERT( wxStrcmp(char1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(char1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(char1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(char1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(char1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(char1, wcharbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wchar1, wcharbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(str1, wcharbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(cstr1, wcharbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(charbuf1, wcharbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, char2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, wchar2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, str2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, cstr2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, charbuf2) < 0 );
CPPUNIT_ASSERT( wxStrcmp(wcharbuf1, wcharbuf2) < 0 );
}
void CrtTestCase::Strspn()
{
const char *strMB = "hello, world";
const char *strWC = "hello, world";
const wxString strWX("hello, world");
CPPUNIT_ASSERT( wxStrspn(strMB, "xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWC, "xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWX, "xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strMB, L"xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWC, L"xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWX, L"xyz") == 0 );
CPPUNIT_ASSERT( wxStrspn(strMB, "hleo") == 5 );
CPPUNIT_ASSERT( wxStrspn(strWC, "hleo") == 5 );
CPPUNIT_ASSERT( wxStrspn(strWX, "hleo") == 5 );
CPPUNIT_ASSERT( wxStrspn(strMB, "ld") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWC, "ld") == 0 );
CPPUNIT_ASSERT( wxStrspn(strWX, "ld") == 0 );
CPPUNIT_ASSERT( wxStrspn(strMB, strWC) == strWX.length() );
CPPUNIT_ASSERT( wxStrspn(strWC, strWX) == strWX.length() );
CPPUNIT_ASSERT( wxStrspn(strWX, strMB) == strWX.length() );
}
void CrtTestCase::Strcspn()
{
const char *strMB = "hello, world";
const char *strWC = "hello, world";
const wxString strWX("hello, world");
CPPUNIT_ASSERT( wxStrcspn(strMB, strWX) == 0 );
CPPUNIT_ASSERT( wxStrcspn(strWC, strMB) == 0 );
CPPUNIT_ASSERT( wxStrcspn(strWX, strWC) == 0 );
CPPUNIT_ASSERT( wxStrcspn(strMB, ", ") == 5 );
CPPUNIT_ASSERT( wxStrcspn(strWC, ", ") == 5 );
CPPUNIT_ASSERT( wxStrcspn(strWX, ", ") == 5 );
CPPUNIT_ASSERT( wxStrcspn(strMB, "hel") == 0 );
CPPUNIT_ASSERT( wxStrcspn(strWC, "hel") == 0 );
CPPUNIT_ASSERT( wxStrcspn(strWX, "hel") == 0 );
CPPUNIT_ASSERT( wxStrcspn(strMB, "xy") == strWX.length() );
CPPUNIT_ASSERT( wxStrcspn(strWC, "xy") == strWX.length() );
CPPUNIT_ASSERT( wxStrcspn(strWX, "xy") == strWX.length() );
}

View File

@@ -322,6 +322,7 @@ wx/wfstream.h
wx/wx.h wx/wx.h
wx/wxchar.h wx/wxchar.h
wx/wxcrt.h wx/wxcrt.h
wx/wxcrtbase.h
wx/wxcrtvararg.h wx/wxcrtvararg.h
wx/wxprec.h wx/wxprec.h
wx/xti.h wx/xti.h

View File

@@ -225,6 +225,7 @@ wx/wfstream.h
wx/wx.h wx/wx.h
wx/wxchar.h wx/wxchar.h
wx/wxcrt.h wx/wxcrt.h
wx/wxcrtbase.h
wx/wxcrtvararg.h wx/wxcrtvararg.h
wx/wxprec.h wx/wxprec.h
wx/xti.h wx/xti.h

View File

@@ -250,6 +250,7 @@ wx/wfstream.h
wx/wx.h wx/wx.h
wx/wxchar.h wx/wxchar.h
wx/wxcrt.h wx/wxcrt.h
wx/wxcrtbase.h
wx/wxcrtvararg.h wx/wxcrtvararg.h
wx/wxprec.h wx/wxprec.h
wx/xti.h wx/xti.h