diff --git a/include/wx/wx_cw_cm.h b/include/wx/wx_cw_cm.h index 43311efd21..a577e2860c 100644 --- a/include/wx/wx_cw_cm.h +++ b/include/wx/wx_cw_cm.h @@ -68,16 +68,3 @@ #define USE_DEFINE -// in order to avoid problems further down in wxWidgets - -#ifdef __cplusplus - -extern "C" -{ -#endif - char *strdup(const char *s) ; - int isascii( int c ) ; -#ifdef __cplusplus -} -#endif - diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index 285b5d4872..d42b7701ab 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -841,10 +841,30 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c)) #endif /* VC++ */ -#if defined(__MWERKS__) && !defined(isascii) - #define isascii(c) ((unsigned)(c) < 0x7f) +/* + a few compilers don't have the (non standard but common) isascii function, + define it ourselves for them + */ +#ifndef isascii + #if defined(__MWERKS__) + #define wxNEED_ISASCII + #elif defined(_WIN32_WCE) + #if _WIN32_WCE <= 211 + #define wxNEED_ISASCII + #endif + #endif +#endif /* isascii */ + +#ifdef wxNEED_ISASCII + inline int isascii(int c) { return (unsigned)c < 0x80; } #endif +#ifdef _WIN32_WCE + #if _WIN32_WCE <= 211 + #define isspace(c) ((c) == _T(' ') || (c) == _T('\t')) + #endif +#endif /* _WIN32_WCE */ + /* we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the initial versions of this header -- now it is too late to remove it so @@ -855,6 +875,20 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ /* string.h functions */ +#ifndef strdup + #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000) + #define wxNEED_STRDUP + #elif defined(__WXWINCE__) + #if _WIN32_WCE <= 211 + #define wxNEED_STRDUP + #endif + #endif +#endif /* strdup */ + +#ifdef wxNEED_STRDUP + WXDLLIMPEXP_BASE char *strdup(const char* s); +#endif + /* VZ: this is never defined neither currently */ #ifdef wxNEED_WX_STRING_H WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src); @@ -957,13 +991,7 @@ WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep); #if (_WIN32_WCE < 300) WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size ); #endif -WXDLLIMPEXP_BASE char* strdup(const char* s); - -#if _WIN32_WCE <= 211 -WXDLLIMPEXP_BASE int isspace(int c); -WXDLLIMPEXP_BASE int isascii( int c ); -#endif -#endif +#endif /* _WIN32_WCE */ /* multibyte to wide char conversion functions and macros */ diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index e09e7e06b6..6dfee33c81 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -1427,8 +1427,8 @@ WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_pt // missing C RTL functions // ---------------------------------------------------------------------------- -#if (defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)) || \ - defined(__WXWINCE__) +#if wxNEED_STRDUP + char *strdup(const char *s) { char *dest = (char*) malloc( strlen( s ) + 1 ) ; @@ -1436,30 +1436,17 @@ char *strdup(const char *s) strcpy( dest , s ) ; return dest ; } -#endif -#if (defined(__MWERKS__) && !defined(__MACH__)) || (defined(__WXWINCE__) && _WIN32_WCE <= 211) - -int isascii( int c ) -{ - return ( c >= 0 && c < 128 ); -} -#endif +#endif // wxNEED_STRDUP #if defined(__WXWINCE__) && (_WIN32_WCE <= 211) -#if (_WIN32_WCE < 300) + void *calloc( size_t num, size_t size ) { void** ptr = (void **)malloc(num * size); memset( ptr, 0, num * size); return ptr; } -#endif -int isspace(int c) -{ - return (c == ' '); -} - -#endif +#endif // __WXWINCE__ <= 211