]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxIsascii() function and use it instead of isascii() in our code.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:28:11 +0000 (00:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:28:11 +0000 (00:28 +0000)
isascii() is non-ANSI and is not available under all platforms. While we
currently define it ourselves in wx/wxcrtbase.h in this case, it's not a good
idea as this can't be easily done correctly for all platforms so start
transitioning away from using isascii() by adding wxIsascii() and using it in
our own code.

The only remaining occurrences of isascii() are in Scintilla code which we
probably don't want to modify.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/wxcrt.h
src/common/accelcmn.cpp
src/generic/accel.cpp
src/generic/grideditors.cpp
src/generic/helpext.cpp
src/motif/accel.cpp
src/motif/textctrl.cpp

index b99543cf3b021f3577301da581444bbc3e22fa4d..9eccfe4cb046377d87ff0b09fcf1b0a905cc780b 100644 (file)
@@ -987,4 +987,6 @@ wxDEPRECATED( inline int wxIsctrl(const wxUniChar& c) );
 inline int wxIsctrl(const wxUniChar& c) { return wxIscntrl(c); }
 #endif // WXWIN_COMPATIBILITY_2_8
 
+inline bool wxIsascii(const wxUniChar& c) { return c.IsAscii(); }
+
 #endif /* _WX_WXCRT_H_ */
index 611fdfd97fa83411d30f62ed06ac8ad37bf6ab45..ee99542df250842798f9310aa0c3d4d179b2d489 100644 (file)
@@ -323,7 +323,9 @@ wxString wxAcceleratorEntry::ToString() const
             // must be a simple key
             if (
 #if !wxUSE_UNICODE
-                 isascii(code) &&
+                 // we can't call wxIsalnum() for non-ASCII characters in ASCII
+                 // build as they're only defined for the ASCII range (or EOF)
+                 wxIsascii(code) &&
 #endif // ANSI
                     wxIsalnum(code) )
             {
index 29893831feab4238eb7d108f8893982a7336fdcc..15054cb15803b83bdd88872e5af026831ca60ade 100644 (file)
@@ -94,8 +94,8 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]
         const wxAcceleratorEntry& entry = entries[i];
 
         int keycode = entry.GetKeyCode();
-        if ( isascii(keycode) )
-            keycode = toupper(keycode);
+        if ( wxIsascii(keycode) )
+            keycode = wxToupper(keycode);
 
         M_ACCELDATA->m_accels.Append(new wxAcceleratorEntry(entry.GetFlags(),
                                                             keycode,
index c07eb137223ddc713d4f725c07fdf4c3ec0987b8..6ec2505ac8af1e89894865825f2acffcba18c231 100644 (file)
@@ -1027,13 +1027,8 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event)
     if ( wxGridCellEditor::IsAcceptedKey(event) )
     {
         const int keycode = event.GetKeyCode();
-        if ( isascii(keycode) )
+        if ( wxIsascii(keycode) )
         {
-            char tmpbuf[2];
-            tmpbuf[0] = (char) keycode;
-            tmpbuf[1] = '\0';
-            wxString strbuf(tmpbuf, *wxConvCurrent);
-
 #if wxUSE_INTL
             const wxString decimalPoint =
                 wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
index b6e4b63812f8922bcff12681e799309476542c58..4f1f2543c4bc47f588aecb14966bec78a12a77cc 100644 (file)
@@ -172,7 +172,7 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
     const wxChar *p = line.c_str();
 
     // skip whitespace
-    while ( isascii(*p) && isspace(*p) )
+    while ( isascii(*p) && wxIsspace(*p) )
         p++;
 
     // skip empty lines and comments
@@ -187,16 +187,16 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
         return false;
 
     p = end;
-    while ( isascii(*p) && isspace(*p) )
+    while ( isascii(*p) && wxIsspace(*p) )
         p++;
 
     // next should be the URL
     wxString url;
     url.reserve(line.length());
-    while ( isascii(*p) && !isspace(*p) )
+    while ( isascii(*p) && !wxIsspace(*p) )
         url += *p++;
 
-    while ( isascii(*p) && isspace(*p) )
+    while ( isascii(*p) && wxIsspace(*p) )
         p++;
 
     // and finally the optional description of the entry after comment
@@ -204,7 +204,7 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
     if ( *p == WXEXTHELP_COMMENTCHAR )
     {
         p++;
-        while ( isascii(*p) && isspace(*p) )
+        while ( isascii(*p) && wxIsspace(*p) )
             p++;
         doc = p;
     }
index 3aad0fb5b533a8f29bf1d9e62a1b00d064c5421c..ba59df93dd71daa315493d545859cc70ca12b741 100644 (file)
@@ -108,8 +108,8 @@ bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
     bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
     int  accKeyCode = GetKeyCode();
     int  accKeyCode2 = GetKeyCode();
-    if (isascii(accKeyCode2))
-        accKeyCode2 = tolower(accKeyCode2);
+    if (wxIsascii(accKeyCode2))
+        accKeyCode2 = wxTolower(accKeyCode2);
 
     return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
         (eventShiftDown == accShiftDown) &&
index 92ea827279d08e71fcc7f00130714dc4fecb07ae..4cd726bc0434eeaed8541f0f60f1e15fd7d43e64 100644 (file)
@@ -387,7 +387,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
         XmTextVerifyCallbackStruct *textStruct =
             (XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
         textStruct->doit = True;
-        if (isascii(event.m_keyCode) && (textStruct->text->length == 1))
+        if (wxIsascii(event.m_keyCode) && (textStruct->text->length == 1))
         {
             textStruct->text->ptr[0] = (char)((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
         }