Skip to content

Commit

Permalink
- Contrib plugins: Use %zu when formatting size_t.
Browse files Browse the repository at this point in the history
Remove "static_cast<unsigned long>()" calls.


git-svn-id: https://svn.code.sf.net/p/codeblocks/code/trunk@13103 2a5c6006-c6dd-42ca-98ab-0921f2732cef
  • Loading branch information
wh11204 committed Dec 9, 2022
1 parent eeab53a commit c055b1d
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 43 deletions.
11 changes: 5 additions & 6 deletions src/plugins/codecompletion/cctest/cctest_frame.cpp
Expand Up @@ -305,7 +305,7 @@ void CCTestFrame::Start()
wxDir::GetAllFiles(wxGetCwd(), &testFiles, wxT("ccc_*.cpp"));
if (testFiles.size() > 0)
{
m_ProgDlg->Update(-1, wxString::Format(_("Adding %lu ccc_*.cpp files."), static_cast<unsigned long>(testFiles.size())));
m_ProgDlg->Update(-1, wxString::Format(_("Adding %zu ccc_*.cpp files."), testFiles.size()));
wxString filename = testFiles[0];
// only test the first matched file
CCTestAppGlobal::s_fileQueue.Add(filename);
Expand All @@ -319,7 +319,7 @@ void CCTestFrame::Start()
{
m_ProgDlg->Update(-1, _("Collecting cc_*.cpp files..."));
wxDir::GetAllFiles(wxGetCwd(), &testFiles, wxT("cc_*.cpp"));
m_ProgDlg->Update(-1, wxString::Format(_("Adding %lu cc_*.cpp files."), static_cast<unsigned long>(testFiles.size())));
m_ProgDlg->Update(-1, wxString::Format(_("Adding %zu cc_*.cpp files."), testFiles.size()));
for (size_t i=0; i<testFiles.size(); i++)
CCTestAppGlobal::s_fileQueue.Add(testFiles[i]);
}
Expand Down Expand Up @@ -359,9 +359,9 @@ void CCTestFrame::AppendToLog(const wxString& log)
{
Freeze();

m_LogCtrl->AppendText( wxString::Format(wxT("%06lu. "), static_cast<unsigned long>(++m_LogCount)) );
m_LogCtrl->AppendText( wxString::Format("%06zu. ", ++m_LogCount) );
m_LogCtrl->AppendText( log );
m_LogCtrl->AppendText( wxT("\r\n") );
m_LogCtrl->AppendText( "\r\n" );

m_LogCtrl->SetInsertionPoint(m_LogCtrl->GetLastPosition());

Expand Down Expand Up @@ -733,8 +733,7 @@ void CCTestFrame::OnPrintTree(cb_unused wxCommandEvent& event)
TokenTree* tt = m_NativeParser.m_Parser.GetTokenTree();
if (tt)
{
AppendToLog((wxString::Format(_("The parser contains %lu tokens, found in %lu files."),
static_cast<unsigned long>(tt->size()), static_cast<unsigned long>(tt->m_FileMap.size()))));
AppendToLog((wxString::Format(_("The parser contains %zu tokens, found in %zu files."), tt->size(), tt->m_FileMap.size())));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/codecompletion/cctest/nativeparser_test.cpp
Expand Up @@ -85,7 +85,7 @@ bool NativeParserTest::TestExpression(wxString& expression,
ResolveExpression(m_Parser.GetTokenTree(), components, searchScope, result, true, true /*isPrefix*/);

if (s_DebugSmartSense)
CCLogger::Get()->DebugLog(F(_T("NativeParserTest::TestExpression, returned %lu results"), static_cast<unsigned long>(result.size())));
CCLogger::Get()->DebugLog(wxString::Format("NativeParserTest::TestExpression, returned %zu results", result.size()));

return true;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ bool NativeParserTest::ParseAndCodeCompletion(wxString filename, bool isLocalFil
if (pass)
--passCount;
pass = false;
element = wxString::Format(_T("%s \"%s\""), token->m_Name.wx_str(), match_doc.wx_str());
element = wxString::Format("%s \"%s\"", token->m_Name, match_doc);
break;
}
}
Expand All @@ -347,13 +347,13 @@ bool NativeParserTest::ParseAndCodeCompletion(wxString filename, bool isLocalFil
}
if (pass == false)
{
message = wxString::Format(_T("- FAIL: %s %s"), expression.wx_str(), element.wx_str());
message = wxString::Format("- FAIL: %s %s", expression, element);
testResult << message << wxT("\n");
wxLogMessage(message);
failCount++;
}
}
// wxLogMessage(_T("Result have %lu matches"), static_cast<unsigned long>(result.size()));
// wxLogMessage(wxString::Format("Result have %zu matches", result.size()));
}
else
break; // if the line is not started with //, then we just stop testing
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/codecompletion/parser/profiletimer.cpp
Expand Up @@ -52,12 +52,12 @@ ProfileTimerHelper::~ProfileTimerHelper()
{
const long totalTime = it->first->m_StopWatch.Time();
wxString log;
log.Printf(_T("\"%s\" used time is %ld minute(s), %ld.%03ld seconds; call times is %lu."),
it->second.wx_str(),
log.Printf(wxString::Format("\"%s\" used time is %ld minute(s), %ld.%03ld seconds; call times is %zu.",
it->second,
(totalTime / 60000),
(totalTime / 1000) % 60,
(totalTime % 1000),
static_cast<unsigned long>(it->first->m_CallTimes));
it->first->m_CallTimes));
#ifndef CC_PARSER_TEST
Manager::Get()->GetLogManager()->DebugLog(log);
#endif
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/contrib/BrowseTracker/BrowseTrackerLayout.cpp
Expand Up @@ -284,18 +284,17 @@ void BrowseTrackerLayout::DumpBrowse_Marks( const wxString /*hashType*/, FileBro
// ----------------------------------------------------------------------------
{
#if defined(LOGGING)
LOGIT( _T("--- DumpBrowseData ---[%s]"), hashType.c_str() );
LOGIT(wxString::Format("--- DumpBrowseData ---[%s]", hashType));

FileBrowse_MarksHash* phash = &m_FileBrowse_MarksArchive;
#if defined(LOGGING)
LOGIT( _T("Dump_%s Size[%lu]"), hashType.wx_str(), static_cast<unsigned long>(phash->size()) );
LOGIT(wxString::Format("Dump_%s Size[%zu]", hashType, phash->size()));
#endif
for (FileBrowse_MarksHash::iterator it = phash->begin(); it != phash->end(); ++it)
{
wxString filename = it->first;
BrowseMarks* p = it->second;
LOGIT( _T("Filename[%s]%s*[%p]name[%s]"), filename.c_str(), hashType.c_str(), p,
(p ? p->GetFilePath().c_str() : ""));
LOGIT(wxString::Format("Filename[%s]%s*[%p]name[%s]"), filename, hashType, p, (p ? p->GetFilePath() : wxString()));
if (p)
{
//dump the browse marks
Expand Down
10 changes: 4 additions & 6 deletions src/plugins/contrib/BrowseTracker/ProjectData.cpp
Expand Up @@ -244,13 +244,12 @@ void ProjectData::DumpHash( const wxString
FileBrowse_MarksHash* phash = &m_FileBrowse_MarksArchive;
FileBrowse_MarksHash& hash = *phash;

LOGIT( _T("--- DumpProjectHash ---[%s]Count[%lu]Name[%s]"), hashType.wx_str(),
static_cast<unsigned long>(hash.size()), m_ProjectFilename.wx_str() );
LOGIT(wxString::Format("--- DumpProjectHash ---[%s]Count[%zu]Name[%s]", hashType, hash.size(), m_ProjectFilename));
for (FileBrowse_MarksHash::iterator it = hash.begin(); it != hash.end(); it++)
{
wxString filename = it->first; //an Editor filename withing this project
BrowseMarks* p = it->second; // ptr to array of Editor Browse/Book mark cursor positions
LOGIT( _T("filename[%s]BrowseMark*[%p]name[%s]"), filename.c_str(), p, p->GetFilePath().c_str() );
LOGIT(wxString::Format("filename[%s]BrowseMark*[%p]name[%s]", filename, p, p->GetFilePath()));
}

#endif
Expand All @@ -270,14 +269,13 @@ void ProjectData::DumpBrowse_Marks( const wxString
FileBrowse_MarksHash* phash = &m_FileBrowse_MarksArchive;
FileBrowse_MarksHash& hash = *phash;

LOGIT( _T("Dump_%s Size[%lu]"), hashType.wx_str(), static_cast<unsigned long>(hash.size()) );
LOGIT(wxString::Format("Dump_%s Size[%zu]", hashType, hash.size()));

for (FileBrowse_MarksHash::iterator it = hash.begin(); it != hash.end(); ++it)
{
wxString filename = it->first;
BrowseMarks* p = it->second;
LOGIT( _T("Filename[%s]%s*[%p]name[%s]"), filename.c_str(), hashType.c_str(), p,
(p ? p->GetFilePath().c_str() : ""));
LOGIT(wxString::Format("Filename[%s]%s*[%p]name[%s]", filename, hashType, p, (p ? p->GetFilePath() : wxString())));
if (p)
{
//dump the browse marks
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contrib/MouseSap/MouseSap.cpp
Expand Up @@ -362,7 +362,7 @@ void MouseSap::DetachAllWindows()
{
// delete all handlers
#if defined(LOGGING)
LOGIT(wxT("MMSap:DetachAll - detaching all [%lu] targets"), static_cast<unsigned long>(m_EditorPtrs.GetCount()) );
LOGIT(wxString::Format("MMSap:DetachAll - detaching all [%zu] targets", m_EditorPtrs.GetCount()));
#endif

// Detach from memorized windows and remove event handlers
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contrib/ThreadSearch/TextFileSearcher.cpp
Expand Up @@ -158,7 +158,7 @@ TextFileSearcher::eFileSearcherReturn TextFileSearcher::FindInFile(const wxStrin

line.Trim(true);

foundLines.Add(wxString::Format(wxT("%lu"), static_cast<unsigned long>(i + 1)));
foundLines.Add(wxString::Format("%zu", i + 1));
foundLines.Add(line);

// We have to compensate any trimming on the left. If we don't do it the matched
Expand Down
Expand Up @@ -460,7 +460,7 @@ void ThreadSearchLoggerList::OnSearchBegin(const ThreadSearchFindData& findData)

void ThreadSearchLoggerList::OnSearchEnd()
{
wxString message = wxString::Format(_("%lu matches found."), static_cast<unsigned long>(m_TotalLinesFound));
wxString message = wxString::Format(_("%zu matches found."), m_TotalLinesFound);
long index = m_pListLog->GetItemCount();
m_pListLog->InsertItem(index, _("=> Search complete. "));
m_pListLog->SetItem(index, ListColumns::Text, message);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contrib/dragscroll/dragscroll.cpp
Expand Up @@ -921,7 +921,7 @@ void cbDragScroll::DetachAll()
{
// delete all handlers
#if defined(LOGGING)
LOGIT(wxT("cbDS:DetachAll - detaching all [%lu] targets"), static_cast<unsigned long>(m_WindowPtrs.GetCount()) );
LOGIT(wxString::Format("cbDS:DetachAll - detaching all [%zu] targets", m_WindowPtrs.GetCount()));
#endif

// Detach from memorized windows and remove event handlers
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/contrib/envvars/envvars_cfgdlg.cpp
Expand Up @@ -137,8 +137,7 @@ void EnvVarsConfigDlg::LoadSettings()

// Load all envvar sets available
choSet->Set(nsEnvVars::GetEnvvarSetNames());
EV_DBGLOG("Found %lu envvar sets in config.",
static_cast <unsigned long> (choSet->GetCount()));
EV_DBGLOG("Found %lu envvar sets in config.", static_cast<unsigned long>(choSet->GetCount()));

// Read the currently active envvar set and select it
m_active_set = nsEnvVars::GetActiveSetName();
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/contrib/envvars/envvars_common.cpp
Expand Up @@ -222,9 +222,7 @@ wxArrayString nsEnvVars::GetEnvvarsBySetPath(const wxString& set_path)
EV_DBGLOG("Warning: empty envvar '%s' detected and skipped.", envvars_keys[i]);
}

EV_DBGLOG("Read %lu/%u envvars in path '%s'.",
static_cast <unsigned long> (envvars.GetCount()),
num_envvars, set_path);
EV_DBGLOG("Read %lu/%u envvars in path '%s'.", static_cast<unsigned long>(envvars.GetCount()), num_envvars, set_path.wx_str());

return envvars;
}// GetEnvvarsBySetPath
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/contrib/headerfixup/execution.cpp
Expand Up @@ -376,8 +376,7 @@ void Execution::LoadSettings()
{
for (size_t i=0; i<m_Sets->GetCount(); i++)
{
wxString Sel; Sel.Printf(_T("/selection%lu"), static_cast<unsigned long>(i));
m_Sets->Check(i, cfg->ReadBool(Sel, true));
m_Sets->Check(i, cfg->ReadBool(wxString::Format("/selection%zu", i), true));
}
}
}// LoadSettings
Expand Down Expand Up @@ -418,8 +417,7 @@ void Execution::SaveSettings()
{
for (size_t i=0; i<m_Sets->GetCount(); i++)
{
wxString Sel; Sel.Printf(_T("/selection%lu"), static_cast<unsigned long>(i));
cfg->Write(Sel, m_Sets->IsChecked(i));
cfg->Write(wxString::Format("/selection%zu", i), m_Sets->IsChecked(i));
}
}
}// SaveSettings
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contrib/keybinder/keybinder.cpp
Expand Up @@ -881,7 +881,7 @@ int wxKeyBinder::MergeSubMenu(wxMenu* pMenu, int& modified) //+v0.4.25
// menu items will never match causing constant update overhead
AddShortcut(nMenuItemID, menuItemKeyStr, true );
#ifdef LOGGING
wxLogMessage(_("Merge change type[%d]:item[%lu]:id[%d]:@[%p]text[%s]key[%s]"), changed, static_cast<unsigned long>(j), nMenuItemID, pMenuItem, pMenuItem->GetItemLabel().wx_str(), menuItemKeyStr.wx_str() );
wxLogMessage(_("Merge change type[%d]:item[%zu]:id[%d]:@[%p]text[%s]key[%s]"), changed, j, nMenuItemID, pMenuItem, pMenuItem->GetItemLabel(), menuItemKeyStr);
#endif
}//if changed
else
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contrib/symtab/symtabexec.cpp
Expand Up @@ -502,7 +502,7 @@ int SymTabExecDlg::ParseOutputSuccess(wxString lib, wxString filter)
return 0;
}

Manager::Get()->GetLogManager()->DebugLog(F(_T("SymTab: Parsing %lu items..."), static_cast<unsigned long>(count)));
Manager::Get()->GetLogManager()->DebugLog(wxString::Format("SymTab: Parsing %zu items...", count));

wxProgressDialog* progress = nullptr;
if (count>2000) // avoid flickering for small libs
Expand Down
Expand Up @@ -349,7 +349,7 @@ bool wxsAngularMeter::OnXmlWrite(TiXmlElement *Element, bool IsXRC, bool IsExtra
{
for(size_t i = 0;i < m_arrSectors.Count();i++){
SectorDesc *Desc = m_arrSectors[i];
wxString s = wxString::Format(wxT("sector_%lu_colour"), static_cast<unsigned long>(i + 1));
wxString s = wxString::Format("sector_%zu_colour", i + 1);
TiXmlElement *msg = new TiXmlElement(s.mb_str());
wxString sClrHex = wxString::Format(_T("#%02X%02X%02X"),
(unsigned int)Desc->colour.Red(),
Expand Down
Expand Up @@ -311,7 +311,7 @@ bool wxsAngularRegulator::OnXmlWrite(TiXmlElement *Element, bool IsXRC, bool IsE
{
for(size_t i = 0;i < m_arrTags.Count();i++){
TagDesc *Desc = m_arrTags[i];
wxString s = wxString::Format(wxT("tag_%lu_value"), static_cast<unsigned long>(i + 1));
wxString s = wxString::Format("tag_%zu_value", i + 1);
TiXmlElement *msg = new TiXmlElement(s.mb_str());
msg->LinkEndChild(new TiXmlText(wxString::Format(wxT("%d"), Desc->val).mb_str()));
Element->LinkEndChild(msg);
Expand Down
Expand Up @@ -255,7 +255,7 @@ bool wxsBmpSwitcher::OnXmlWrite(TiXmlElement *Element, bool IsXRC, bool IsExtra)

for(size_t i = 0;i < m_arrBmps.Count();i++){
BmpDesc *Desc = m_arrBmps[i];
wxString s = wxString::Format(wxT("bitmap_%lu"), static_cast<unsigned long>(i + 1));
wxString s = wxString::Format("bitmap_%zu", i + 1);
TiXmlElement *msg = new TiXmlElement(s.mb_str());
msg->LinkEndChild(new TiXmlText(Desc->sPath.mb_str()));
tags->LinkEndChild(msg);
Expand Down
Expand Up @@ -368,7 +368,7 @@ bool wxsLinearMeter::OnXmlWrite(TiXmlElement *Element, bool IsXRC, bool IsExtra)
// }
for(size_t i = 0;i < m_arrTags.Count();i++){
TagDesc *Desc = m_arrTags[i];
wxString s = wxString::Format(wxT("tag_%lu_value"), static_cast<unsigned long>(i + 1));
wxString s = wxString::Format("tag_%zu_value", i + 1);
TiXmlElement *msg = new TiXmlElement(s.mb_str());
msg->LinkEndChild(new TiXmlText(wxString::Format(wxT("%d"), Desc->val).mb_str()));
Element->LinkEndChild(msg);
Expand Down
Expand Up @@ -348,7 +348,7 @@ bool wxsLinearRegulator::OnXmlWrite(TiXmlElement *Element, bool IsXRC, bool IsEx
{
for(size_t i = 0;i < m_arrTags.Count();i++){
TagDesc *Desc = m_arrTags[i];
wxString s = wxString::Format(wxT("tag_%lu_value"), static_cast<unsigned long>(i + 1));
wxString s = wxString::Format("tag_%zu_value", i + 1);
TiXmlElement *msg = new TiXmlElement(s.mb_str());
msg->LinkEndChild(new TiXmlText(wxString::Format(wxT("%d"), Desc->val).mb_str()));
Element->LinkEndChild(msg);
Expand Down

0 comments on commit c055b1d

Please sign in to comment.