X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/386d53dc2e27c5f0e5c0d34fd50e3f7cbf51407e..31ad423e4fb556ec225a63b161154d3bf3445c1b:/include/wx/wxchar.h diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index eb2dd42e9c..dd6ca93a71 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -2,10 +2,10 @@ * Name: wx/wxchar.h * Purpose: Declarations common to wx char/wchar_t usage (wide chars) * Author: Joel Farley, Ove Kåven - * Modified by: Vadim Zeitlin, Robert Roebling + * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee * Created: 1998/06/12 * RCS-ID: $Id$ - * Copyright: (c) 1998-2002 wxWindows dev team + * Copyright: (c) 1998-2002 wxWidgets dev team * Licence: wxWindows licence */ @@ -22,10 +22,7 @@ /* check whether we have wchar_t and which size it is if we do */ #if !defined(wxUSE_WCHAR_T) - #if defined(__WIN16__) - /* no wchar_t under Win16 regadrless of compiler used */ - #define wxUSE_WCHAR_T 0 - #elif defined(__UNIX__) + #if defined(__UNIX__) #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__) #define wxUSE_WCHAR_T 1 #else @@ -51,7 +48,7 @@ /* Standard headers we need here. - NB: don't include any wxWindows headers here because almost of them include + NB: don't include any wxWidgets headers here because almost of them include this one! */ @@ -76,6 +73,11 @@ #define HAVE_WCHAR_H #endif #endif +#if defined(__MWERKS__) && !defined(__MACH__) + #ifndef HAVE_WCSLEN + #define HAVE_WCSLEN + #endif +#endif #if wxUSE_WCHAR_T #ifdef HAVE_WCHAR_H @@ -114,6 +116,8 @@ #include #elif defined(__WATCOMC__) #define wxHAVE_TCHAR_SUPPORT +#elif defined(__DMC__) + #define wxHAVE_TCHAR_SUPPORT #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 ) #define wxHAVE_TCHAR_SUPPORT #include @@ -174,7 +178,7 @@ typedef wchar_t wxSChar; typedef wchar_t wxUChar; #else /* __WCHAR_TYPE__ and gcc < 2.96 */ - /* VS: wxWindows used to define wxChar as __WCHAR_TYPE__ here. However, */ + /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. However, */ /* this doesn't work with new GCC 3.x compilers because wchar_t is */ /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */ /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */ @@ -208,7 +212,7 @@ /* although global macros with such names are normally bad, we want to have */ /* another name for _T() which should be used to avoid confusion between _T() */ -/* and _() in wxWindows sources */ +/* and _() in wxWidgets sources */ #define wxT(x) _T(x) /* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */ @@ -250,8 +254,13 @@ #define wxIsspace _istspace #define wxIsupper _istupper #define wxIsxdigit _istxdigit - #define wxTolower _totlower - #define wxToupper _totupper + + /* + There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with + signed chars < 0, so "fix" it here. + */ + #define wxTolower(c) _totlower((wxUChar)(c)) + #define wxToupper(c) _totupper((wxUChar)(c)) /* locale.h functons */ #define wxSetlocale _tsetlocale @@ -300,7 +309,18 @@ #define wxPutchar _puttchar #define wxPuts _putts #define wxScanf _tscanf - #define wxSprintf _stprintf + #if defined(__DMC__) + #if wxUSE_UNICODE + /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */ + int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ; + #else + /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */ + #define wxSprintf sprintf + #endif + #else + #define wxSprintf _stprintf + #endif + #define wxSscanf _stscanf #define wxTmpnam _ttmpnam #define wxUngetc _tungetc @@ -345,7 +365,7 @@ #include /* this is probably glibc-specific */ - #if defined(__WCHAR_TYPE__) + #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__) /* ctype.h functions (wctype.h) */ #define wxIsalnum iswalnum #define wxIsalpha iswalpha @@ -400,22 +420,33 @@ #define wxGets getws #define wxUngetc ungetwc - #ifdef HAVE_FPUTWC - #define wxPutc wputc - #define wxPutchar wputchar - #define wxPuts putws - #define wxFputs fputws + #ifdef HAVE_FPUTWS + #define wxFputs fputws #else - #define wxNEED_FPUTWC - + #define wxNEED_FPUTS #include - int wxFputs(const wxChar *ch, FILE *stream); + #endif + + #ifdef HAVE_WPUTC + #define wxPutc wputc + #else + #define wxNEED_PUTC + #include int wxPutc(wxChar ch, FILE *stream); + #endif - #define wxPuts(ws) wxFputs(ws, stdout) + #ifdef HAVE_WPUTCHAR + #define wxPutchar wputchar + #else #define wxPutchar(wch) wxPutc(wch, stdout) #endif + + #ifdef HAVE_PUTWS + #define wxPuts putws + #else + #define wxPuts(ws) wxFputs(ws, stdout) + #endif /* we need %s to %ls conversion for printf and scanf etc */ #define wxNEED_PRINTF_CONVERSION @@ -425,7 +456,7 @@ #define wxNEED_WX_STDIO_H #define wxNEED_WX_STDLIB_H #define wxNEED_WX_TIME_H - #elif defined(__MWERKS__) && ( defined(macintosh) || defined(__MACH__) ) + #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) ) /* ctype.h functions (wctype.h) */ #define wxIsalnum iswalnum #define wxIsalpha iswalpha @@ -482,32 +513,20 @@ #define wxNEED_WX_STDIO_H /* stdlib.h functions */ + #ifdef __MACH__ + #define wxNEED_WX_STDLIB_H + #else #define wxAtof watof #define wxAtoi watoi #define wxAtol watol #define wxGetenv(a) ((wxChar*)NULL) #define wxSystem(a) ((int)NULL) - + #endif /* time.h functions */ #define wxAsctime wasciitime #define wxCtime wctime /* #define wxStrftime wcsftime */ - /* - #define wxNEED_FPUTWC - - #include - - int wxFputs(const wxChar *ch, FILE *stream); - int wxPutc(wxChar ch, FILE *stream); - - #define wxPuts(ws) wxFputs(ws, stdout) - #define wxPutchar(wch) wxPutc(wch, stdout) - - #define wxNEED_PRINTF_CONVERSION - #define wxNEED_WX_STDIO_H - #define wxNEED_WX_STDLIB_H - */ #define wxNEED_WX_TIME_H #else /* !metrowerks for apple */ #error "Please define wide character functions for your environment" @@ -626,7 +645,7 @@ #elif defined(__UNIX__) || defined(__GNUWIN32__) #define wxStricmp strcasecmp #define wxStrnicmp strncasecmp - /* #else -- use wxWindows implementation */ + /* #else -- use wxWidgets implementation */ #endif #endif /* !defined(wxStricmp) */ @@ -637,6 +656,10 @@ #ifdef HAVE_WCSLEN #define wxWcslen wcslen #else + #if defined( __WXMAC_XCODE__ ) && !defined( __cplusplus ) + /* xcode native targets are giving multiply defined symbols on regex */ + static + #endif inline size_t wxWcslen(const wchar_t *s) { size_t n = 0; @@ -710,7 +733,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ #define wxVsnprintf_ vswprintf #endif #else /* ASCII */ - /* all versions of CodeWarrior supported by wxWindows apparently have */ + /* all versions of CodeWarrior supported by wxWidgets apparently have */ /* vsnprintf() */ #if defined(HAVE_VSNPRINTF) || defined(__MWERKS__) || defined(__WATCOMC__) /* assume we have snprintf() too if we have vsnprintf() */ @@ -750,12 +773,7 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ We choose to always emulate Windows behaviour as more useful for us so even if we have wprintf() we still must wrap it in a non trivial wxPrintf(). - 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. */ -#ifndef wxVsnprintf_ - #undef wxNEED_PRINTF_CONVERSION -#endif #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF) /* @@ -780,7 +798,11 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ /* these 2 can be simply mapped to the versions with underscore at the end */ /* if we don't have to do the conversion */ -#ifdef wxNEED_PRINTF_CONVERSION +/* + 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. +*/ +#if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_) int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3; int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap ); #else @@ -920,6 +942,12 @@ WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz); const wxChar *fmt, const struct tm *tm); #endif /* wxNEED_WX_TIME_H */ +#ifndef wxCtime +#include +WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep); +#endif + + /* missing functions in some WinCE versions */ #ifdef _WIN32_WCE #if (_WIN32_WCE < 300)