cleaning up strdup/isascii definitions for compilers which lack them (should fix CW CFM build)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2004-10-05 21:57:40 +00:00
parent 3c4e4af64e
commit 27db421056
3 changed files with 42 additions and 40 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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