For non-Unicode added #include <ctype.h> and <string.h> to avoid some missing

declaration warnings, added wxAtof, changed wxStrtok declaration, added
conditional declarations for functions in wxchar.cpp


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven
1999-04-12 20:01:51 +00:00
parent c9e089e9f4
commit e97a90f0a8

View File

@@ -69,7 +69,7 @@ typedef _TUCHAR wxUChar;
#define wxStrspn _tcsspn #define wxStrspn _tcsspn
#define wxStrstr _tcsstr #define wxStrstr _tcsstr
#define wxStrtod _tcstod #define wxStrtod _tcstod
#define wxStrtok _tcstok // is there a _tcstok[_r] ?
#define wxStrtol _tcstol #define wxStrtol _tcstol
#define wxStrtoul _tcstoul #define wxStrtoul _tcstoul
#define wxStrxfrm _tcsxfrm #define wxStrxfrm _tcsxfrm
@@ -104,6 +104,7 @@ typedef _TUCHAR wxUChar;
#define wxVsprintf _vstprintf #define wxVsprintf _vstprintf
// stdlib.h functions // stdlib.h functions
#define wxAtof _ttof /* does this exist? */
#define wxAtoi _ttoi #define wxAtoi _ttoi
#define wxAtol _ttol #define wxAtol _ttol
#define wxGetenv _tgetenv #define wxGetenv _tgetenv
@@ -172,13 +173,18 @@ typedef unsigned __WCHAR_TYPE__ wxUChar;
#define wxStrxfrm wcsxfrm #define wxStrxfrm wcsxfrm
// glibc doesn't have wc equivalents of the other stuff // glibc doesn't have wc equivalents of the other stuff
// do we need to write wrappers for them? #define wxNEED_WX_STDIO_H
#define wxNEED_WX_STDLIB_H
#define wxNEED_WX_TIME_H
#else #else
#error "Please define your compiler's Unicode conventions in wxChar.h" #error "Please define your compiler's Unicode conventions in wxChar.h"
#endif #endif
#else//!Unicode #else//!Unicode
#include <ctype.h>
#include <string.h>
#if 0 // temporary - preserve binary compatibilty #if 0 // temporary - preserve binary compatibilty
typedef char wxChar; typedef char wxChar;
typedef signed char wxSChar; typedef signed char wxSChar;
@@ -216,6 +222,7 @@ typedef unsigned char wxUChar;
#define wxStrcoll strcoll #define wxStrcoll strcoll
#define wxStrcpy strcpy #define wxStrcpy strcpy
#define wxStrcspn strcspn #define wxStrcspn strcspn
#define wxStrdup strdup
#define wxStrncat strncat #define wxStrncat strncat
#define wxStrncmp strncmp #define wxStrncmp strncmp
#define wxStrncpy strncpy #define wxStrncpy strncpy
@@ -224,7 +231,7 @@ typedef unsigned char wxUChar;
#define wxStrspn strspn #define wxStrspn strspn
#define wxStrstr strstr #define wxStrstr strstr
#define wxStrtod strtod #define wxStrtod strtod
#define wxStrtok strtok // #define wxStrtok strtok_r // this needs a configure check
#define wxStrtol strtol #define wxStrtol strtol
#define wxStrtoul strtoul #define wxStrtoul strtoul
#define wxStrxfrm strxfrm #define wxStrxfrm strxfrm
@@ -259,6 +266,7 @@ typedef unsigned char wxUChar;
#define wxVsprintf vsprintf #define wxVsprintf vsprintf
// stdlib.h functions // stdlib.h functions
#define wxAtof atof
#define wxAtoi atoi #define wxAtoi atoi
#define wxAtol atol #define wxAtol atol
#define wxGetenv getenv #define wxGetenv getenv
@@ -323,17 +331,46 @@ inline int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2)
#error "Please define string case-insensitive compare for your OS/compiler" #error "Please define string case-insensitive compare for your OS/compiler"
#endif // OS/compiler #endif // OS/compiler
/// portable strdup // multibyte<->widechar conversion
inline wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz) size_t WXDLLEXPORT wxMB2WC(wchar_t *buf, const char *psz, size_t n);
#if !wxUSE_UNICODE size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *psz, size_t n);
{ return strdup(psz); } #if wxUSE_UNICODE
#define wxMB2WX wxMB2WC
#define wxWX2MB wxWC2MB
#define wxWC2WX wxStrncpy
#define wxWX2WC wxStrncpy
#else #else
{ #define wxMB2WX wxStrncpy
size_t size = (wxStrlen(psz) + 1) * sizeof(wxChar); #define wxWX2MB wxStrncpy
wxChar *ret = (wxChar *) malloc(size); #define wxWC2WX wxWC2MB
memcpy(ret, psz, size); #define wxWX2WC wxMB2WC
return ret; #endif
}
// if libc versions are not available, use replacements defined in wxchar.cpp
#ifndef wxStrdup
wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz);
#endif
#ifndef wxStrtok
wxChar * WXDLLEXPORT wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
#endif
#ifndef wxSetlocale
wxChar * WXDLLEXPORT wxSetlocale(int category, const wxChar *locale);
#endif
#ifdef wxNEED_WX_STDIO_H
#include <stdarg.h>
int WXDLLEXPORT wxSprintf(wxChar *buf, const wxChar *fmt, ...);
int WXDLLEXPORT wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr);
#endif
#ifdef wxNEED_WX_STDLIB_H
double WXDLLEXPORT wxAtof(const wxChar *psz);
int WXDLLEXPORT wxAtoi(const wxChar *psz);
long WXDLLEXPORT wxAtol(const wxChar *psz);
wxChar * WXDLLEXPORT wxGetenv(const wxChar *name);
int WXDLLEXPORT wxSystem(const wxChar *psz);
#endif #endif
#endif #endif