]> git.saurik.com Git - wxWidgets.git/commitdiff
cleaning up strdup/isascii definitions for compilers which lack them (should fix...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 5 Oct 2004 21:57:40 +0000 (21:57 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 5 Oct 2004 21:57:40 +0000 (21:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/wx_cw_cm.h
include/wx/wxchar.h
src/common/wxchar.cpp

index 43311efd2164dc18d4adfff82951096aa82fb535..a577e2860c5a10020f0e3fbce59a988bbf0110f4 100644 (file)
 
 #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
-
index 285b5d4872ad4913824cd66f6f6d8cf61f114325..d42b7701abf010eb0995139235a43f9f24928253 100644 (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 */
 
index e09e7e06b6fdffcf37c41031eedb57259141cd9c..6dfee33c811590ff7644f6f8a7ff5cac173a7ca7 100644 (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