From 9611b7975f7c5cd86f0be0d6adcc67f7ddd98c72 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 2 Jul 2009 22:43:31 +0000 Subject: [PATCH] use WXSIZEOF(x) instead of sizeof(x)/sizeof(x[0]) (closes #10701) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetime.cpp | 4 ++-- src/common/memory.cpp | 6 +++--- src/osx/carbon/font.cpp | 6 +++--- src/osx/carbon/graphics.cpp | 18 +++++++++--------- src/osx/carbon/textctrl.cpp | 2 +- src/richtext/richtextsymboldlg.cpp | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 928d2effc3..e13ac2e808 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -934,7 +934,7 @@ void wxDateTime::GetAmPmStrings(wxString *am, wxString *pm) // assert, even though it is a perfectly legal use. if ( am ) { - if (wxStrftime(buffer, sizeof(buffer)/sizeof(wxChar), _T("%p"), &tm) > 0) + if (wxStrftime(buffer, WXSIZEOF(buffer), _T("%p"), &tm) > 0) *am = wxString(buffer); else *am = wxString(); @@ -942,7 +942,7 @@ void wxDateTime::GetAmPmStrings(wxString *am, wxString *pm) if ( pm ) { tm.tm_hour = 13; - if (wxStrftime(buffer, sizeof(buffer)/sizeof(wxChar), _T("%p"), &tm) > 0) + if (wxStrftime(buffer, WXSIZEOF(buffer), _T("%p"), &tm) > 0) *pm = wxString(buffer); else *pm = wxString(); diff --git a/src/common/memory.cpp b/src/common/memory.cpp index c55af4d9bc..71658b74db 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -831,13 +831,13 @@ void wxDebugContext::OutputDumpLine(const wxChar *szFormat, ...) int count; va_list argptr; va_start(argptr, szFormat); - buf[sizeof(buf)/sizeof(wxChar)-1] = _T('\0'); + buf[WXSIZEOF(buf)-1] = _T('\0'); // keep 3 bytes for a \r\n\0 - count = wxVsnprintf(buf, sizeof(buf)/sizeof(wxChar)-3, szFormat, argptr); + count = wxVsnprintf(buf, WXSIZEOF(buf)-3, szFormat, argptr); if ( count < 0 ) - count = sizeof(buf)/sizeof(wxChar)-3; + count = WXSIZEOF(buf)-3; buf[count]=_T('\r'); buf[count+1]=_T('\n'); buf[count+2]=_T('\0'); diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index c68ff2bd84..3295417d81 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -442,7 +442,7 @@ void wxFontRefData::MacFindFont() kATSUQDCondensedTag , kATSUQDExtendedTag , }; - ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ByteCount atsuSizes[WXSIZEOF(atsuTags)] = { sizeof( ATSUFontID ) , sizeof( Fixed ) , @@ -460,7 +460,7 @@ void wxFontRefData::MacFindFont() Fixed atsuSize = IntToFixed( m_info.m_pointSize ); ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; FMFontStyle addQDStyle = m_info.m_atsuAdditionalQDStyles; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] = { &m_info.m_atsuFontID , &atsuSize , @@ -474,7 +474,7 @@ void wxFontRefData::MacFindFont() status = ::ATSUSetAttributes( (ATSUStyle)m_macATSUStyle, - sizeof(atsuTags) / sizeof(ATSUAttributeTag) , + WXSIZEOF(atsuTags), atsuTags, atsuSizes, atsuValues); wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ); diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 4a1e139f31..b446fc502c 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -869,19 +869,19 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere kATSUSizeTag , kATSUColorTag , }; - ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ByteCount atsuSizes[WXSIZEOF(atsuTags)] = { sizeof( Fixed ) , sizeof( RGBColor ) , }; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] = { &atsuSize , &atsuColor , }; status = ::ATSUSetAttributes( - m_macATSUIStyle, sizeof(atsuTags) / sizeof(ATSUAttributeTag) , + m_macATSUIStyle, WXSIZEOF(atsuTags), atsuTags, atsuSizes, atsuValues); wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ); @@ -2268,15 +2268,15 @@ void wxMacCoreGraphicsContext::DoDrawRotatedText(const wxString &str, { kATSULineRotationTag , }; - ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ByteCount atsuSizes[WXSIZEOF(atsuTags)] = { sizeof( Fixed ) , }; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] = { &atsuAngle , }; - status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag), + status = ::ATSUSetLayoutControls(atsuLayout , WXSIZEOF(atsuTags), atsuTags, atsuSizes, atsuValues ); } @@ -2285,15 +2285,15 @@ void wxMacCoreGraphicsContext::DoDrawRotatedText(const wxString &str, { kATSUCGContextTag , }; - ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ByteCount atsuSizes[WXSIZEOF(atsuTags)] = { sizeof( CGContextRef ) , }; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = + ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] = { &m_cgContext , }; - status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag), + status = ::ATSUSetLayoutControls(atsuLayout , WXSIZEOF(atsuTags), atsuTags, atsuSizes, atsuValues ); } diff --git a/src/osx/carbon/textctrl.cpp b/src/osx/carbon/textctrl.cpp index 57c315012a..e0089b8859 100644 --- a/src/osx/carbon/textctrl.cpp +++ b/src/osx/carbon/textctrl.cpp @@ -893,7 +893,7 @@ void wxMacMLTEControl::AdjustCreationAttributes(const wxColour &background, } ; err = TXNSetTypeAttributes( - m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes), + m_txn, WXSIZEOF(typeAttr), typeAttr, kTXNStartOffset, kTXNEndOffset ); verify_noerr( err ); diff --git a/src/richtext/richtextsymboldlg.cpp b/src/richtext/richtextsymboldlg.cpp index 5c83e5f66e..d455090b8d 100644 --- a/src/richtext/richtextsymboldlg.cpp +++ b/src/richtext/richtextsymboldlg.cpp @@ -515,7 +515,7 @@ bool wxSymbolPickerDialog::TransferDataToWindow() { // Insert items into subset combo int i; - for (i = 0; i < (int) (sizeof(g_UnicodeSubsetTable)/sizeof(g_UnicodeSubsetTable[0])); i++) + for (i = 0; i < (int) WXSIZEOF(g_UnicodeSubsetTable); i++) { m_subsetCtrl->Append(g_UnicodeSubsetTable[i].m_name); } @@ -617,7 +617,7 @@ void wxSymbolPickerDialog::OnSymbolSelected( wxCommandEvent& event ) { // Need to make the subset selection reflect the current symbol int i; - for (i = 0; i < (int) (sizeof(g_UnicodeSubsetTable)/sizeof(g_UnicodeSubsetTable[0])); i++) + for (i = 0; i < (int) WXSIZEOF(g_UnicodeSubsetTable); i++) { if (sel >= g_UnicodeSubsetTable[i].m_low && sel <= g_UnicodeSubsetTable[i].m_high) { -- 2.45.2