X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7cf98a658a11f0ea3fb723ea686a77b8adb39718..884470b12ee25b20796bfef11a9bfa5fb1e1511c:/src/common/utilscmn.cpp diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 55fbb44630..1488ca866c 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -51,8 +51,14 @@ #endif #endif #include +#ifndef __MWERKS__ #include #include +#endif + +#ifdef __SALFORDC__ +#include +#endif // Pattern matching code. // Yes, this path is deliberate (for Borland compilation) @@ -70,6 +76,36 @@ extern char *wxBuffer; +#ifdef __WXMAC__ +int strcasecmp(const char *str_1, const char *str_2) +{ + register char c1, c2; + do { + c1 = tolower(*str_1++); + c2 = tolower(*str_2++); + } while ( c1 && (c1 == c2) ); + + return c1 - c2; +} + +int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) +{ + + register char c1, c2; + while( maxchar--) + { + c1 = tolower(*str_1++); + c2 = tolower(*str_2++); + + if ( !c1 || c1!=c2 ) + return c1 - c2; + + } ; + + return 0 ; + +} +#endif #ifdef __VMS__ // we have no strI functions under VMS, therefore I have implemented // an inefficient but portable version: convert copies of strings to lowercase @@ -118,8 +154,13 @@ int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) #ifdef __WINDOWS__ #ifndef __GNUWIN32__ +#ifndef __MWERKS__ #define strcasecmp stricmp #define strncasecmp strnicmp +#else +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif #endif #ifdef _MSC_VER @@ -390,6 +431,14 @@ char *wxStripMenuCodes (char *in, char *out) return tmpOut; } +wxString wxStripMenuCodes(const wxString& str) +{ + char *buf = new char[str.Length() + 1]; + wxStripMenuCodes((char*) (const char*) str, buf); + wxString str1(buf); + delete[] buf; + return str1; +} /* * Window search functions @@ -437,7 +486,7 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent) if (parent) { - for (wxNode * node = parent->GetChildren()->First (); node; node = node->Next ()) + for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) { wxWindow *win = (wxWindow *) node->Data (); wxWindow *retwin = wxFindWindowByLabel1 (title, win); @@ -493,7 +542,7 @@ wxFindWindowByName1 (const wxString& title, wxWindow * parent) if (parent) { - for (wxNode * node = parent->GetChildren()->First (); node; node = node->Next ()) + for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) { wxWindow *win = (wxWindow *) node->Data (); wxWindow *retwin = wxFindWindowByName1 (title, win); @@ -517,54 +566,6 @@ wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& i return menuBar->FindMenuItem (menuString, itemString); } -/* - * wxDebugStreamBuf - */ -#if !defined(_WINDLL) - -wxDebugStreamBuf::wxDebugStreamBuf(void) -{ - // usage doesn't need this, and i have no idea how to simulate it. -#if wxUSE_IOSTREAMH - if (allocate()) - setp(base(),ebuf()); -#endif -} - -int wxDebugStreamBuf::overflow(int WXUNUSED(i)) -{ - int len = pptr() - pbase(); - char *txt = new char[len+1]; - strncpy(txt, pbase(), len); - txt[len] = '\0'; -#ifdef __WXMSW__ - OutputDebugString((LPCSTR)txt); -#else - fprintf(stderr, txt); -#endif - setp(pbase(), epptr()); - delete[] txt; - return EOF; -} - -int wxDebugStreamBuf::sync(void) -{ - int len = pptr() - pbase(); - char *txt = new char[len+1]; - strncpy(txt, pbase(), len); - txt[len] = '\0'; -#ifdef __WXMSW__ - OutputDebugString((LPCSTR)txt); -#else - fprintf(stderr, txt); -#endif - setp(pbase(), epptr()); - delete[] txt; - return 0; -} - -#endif - /* On Fri, 21 Jul 1995, Paul Craven wrote: @@ -799,3 +800,52 @@ wxString wxGetTextFromUser(const wxString& message, const wxString& caption, return wxString(""); } +#ifdef __MWERKS__ +char *strdup(const char *s) +{ + return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ; +} + +int isascii( int c ) +{ + return ( c >= 0 && c < 128 ) ; +} +#endif + +// Overloaded functions, taking a wxString +bool wxGetHostName(wxString& name) +{ + bool success = wxGetHostName(wxBuffer, 500); + if (success) + { + name = wxBuffer; + return TRUE; + } + else + return FALSE; +} + +bool wxGetUserId(wxString& buf) +{ + bool success = wxGetUserId(wxBuffer, 500); + if (success) + { + buf = wxBuffer; + return TRUE; + } + else + return FALSE; +} + +bool wxGetUserName(wxString& buf) +{ + bool success = wxGetUserName(wxBuffer, 500); + if (success) + { + buf = wxBuffer; + return TRUE; + } + else + return FALSE; +} +