Add wxIsascii() function and use it instead of isascii() in our code.

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
This commit is contained in:
Vadim Zeitlin
2010-01-18 00:28:11 +00:00
parent f030eeed1e
commit 7a0079d5a4
7 changed files with 16 additions and 17 deletions

View File

@@ -987,4 +987,6 @@ wxDEPRECATED( inline int wxIsctrl(const wxUniChar& c) );
inline int wxIsctrl(const wxUniChar& c) { return wxIscntrl(c); } inline int wxIsctrl(const wxUniChar& c) { return wxIscntrl(c); }
#endif // WXWIN_COMPATIBILITY_2_8 #endif // WXWIN_COMPATIBILITY_2_8
inline bool wxIsascii(const wxUniChar& c) { return c.IsAscii(); }
#endif /* _WX_WXCRT_H_ */ #endif /* _WX_WXCRT_H_ */

View File

@@ -323,7 +323,9 @@ wxString wxAcceleratorEntry::ToString() const
// must be a simple key // must be a simple key
if ( if (
#if !wxUSE_UNICODE #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 #endif // ANSI
wxIsalnum(code) ) wxIsalnum(code) )
{ {

View File

@@ -94,8 +94,8 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]
const wxAcceleratorEntry& entry = entries[i]; const wxAcceleratorEntry& entry = entries[i];
int keycode = entry.GetKeyCode(); int keycode = entry.GetKeyCode();
if ( isascii(keycode) ) if ( wxIsascii(keycode) )
keycode = toupper(keycode); keycode = wxToupper(keycode);
M_ACCELDATA->m_accels.Append(new wxAcceleratorEntry(entry.GetFlags(), M_ACCELDATA->m_accels.Append(new wxAcceleratorEntry(entry.GetFlags(),
keycode, keycode,

View File

@@ -1027,13 +1027,8 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event)
if ( wxGridCellEditor::IsAcceptedKey(event) ) if ( wxGridCellEditor::IsAcceptedKey(event) )
{ {
const int keycode = event.GetKeyCode(); 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 #if wxUSE_INTL
const wxString decimalPoint = const wxString decimalPoint =
wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);

View File

@@ -172,7 +172,7 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
const wxChar *p = line.c_str(); const wxChar *p = line.c_str();
// skip whitespace // skip whitespace
while ( isascii(*p) && isspace(*p) ) while ( isascii(*p) && wxIsspace(*p) )
p++; p++;
// skip empty lines and comments // skip empty lines and comments
@@ -187,16 +187,16 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
return false; return false;
p = end; p = end;
while ( isascii(*p) && isspace(*p) ) while ( isascii(*p) && wxIsspace(*p) )
p++; p++;
// next should be the URL // next should be the URL
wxString url; wxString url;
url.reserve(line.length()); url.reserve(line.length());
while ( isascii(*p) && !isspace(*p) ) while ( isascii(*p) && !wxIsspace(*p) )
url += *p++; url += *p++;
while ( isascii(*p) && isspace(*p) ) while ( isascii(*p) && wxIsspace(*p) )
p++; p++;
// and finally the optional description of the entry after comment // and finally the optional description of the entry after comment
@@ -204,7 +204,7 @@ bool wxExtHelpController::ParseMapFileLine(const wxString& line)
if ( *p == WXEXTHELP_COMMENTCHAR ) if ( *p == WXEXTHELP_COMMENTCHAR )
{ {
p++; p++;
while ( isascii(*p) && isspace(*p) ) while ( isascii(*p) && wxIsspace(*p) )
p++; p++;
doc = p; doc = p;
} }

View File

@@ -108,8 +108,8 @@ bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT); bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
int accKeyCode = GetKeyCode(); int accKeyCode = GetKeyCode();
int accKeyCode2 = GetKeyCode(); int accKeyCode2 = GetKeyCode();
if (isascii(accKeyCode2)) if (wxIsascii(accKeyCode2))
accKeyCode2 = tolower(accKeyCode2); accKeyCode2 = wxTolower(accKeyCode2);
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) && return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
(eventShiftDown == accShiftDown) && (eventShiftDown == accShiftDown) &&

View File

@@ -387,7 +387,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
XmTextVerifyCallbackStruct *textStruct = XmTextVerifyCallbackStruct *textStruct =
(XmTextVerifyCallbackStruct *) m_tempCallbackStruct; (XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
textStruct->doit = True; 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); textStruct->text->ptr[0] = (char)((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
} }