ENH: Cleanup. Replace c-style cast with static_cast and replace sprintf with cmOStringStream

This commit is contained in:
Andy Cedilnik 2006-07-21 13:05:56 -04:00
parent ef6cf109ed
commit 898dfe5a2d
1 changed files with 13 additions and 12 deletions

View File

@ -942,13 +942,13 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
clock_finish = clock(); clock_finish = clock();
time(&time_finish); time(&time_finish);
double clocks_per_sec = (double)CLOCKS_PER_SEC; double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC);
std::cout << "Elapsed time: " std::cout << "Elapsed time: "
<< (long)(time_finish - time_start) << " s. (time)" << static_cast<long>(time_finish - time_start) << " s. (time)"
<< ", " << ", "
<< (double)(clock_finish - clock_start) / clocks_per_sec << static_cast<double>(clock_finish - clock_start) / clocks_per_sec
<< " s. (clock)" << " s. (clock)"
<< "\n"; << "\n";
return 0; return 0;
} }
@ -2368,7 +2368,6 @@ void cmake::GenerateGraphViz(const char* fileName)
std::map<cmStdString, int> targetDeps; std::map<cmStdString, int> targetDeps;
std::map<cmStdString, cmTarget*> targetPtrs; std::map<cmStdString, cmTarget*> targetPtrs;
std::map<cmStdString, cmStdString> targetNamesNodes; std::map<cmStdString, cmStdString> targetNamesNodes;
char tgtName[2048];
int cnt = 0; int cnt = 0;
// First pass get the list of all cmake targets // First pass get the list of all cmake targets
for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit )
@ -2384,8 +2383,9 @@ void cmake::GenerateGraphViz(const char* fileName)
continue; continue;
} }
//std::cout << "Found target: " << tit->first.c_str() << std::endl; //std::cout << "Found target: " << tit->first.c_str() << std::endl;
sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); cmOStringStream ostr;
targetNamesNodes[realTargetName] = tgtName; ostr << graphNodePrefix << cnt++;
targetNamesNodes[realTargetName] = ostr.str();
targetPtrs[realTargetName] = &tit->second; targetPtrs[realTargetName] = &tit->second;
} }
} }
@ -2421,10 +2421,11 @@ void cmake::GenerateGraphViz(const char* fileName)
} }
if ( tarIt == targetNamesNodes.end() ) if ( tarIt == targetNamesNodes.end() )
{ {
sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); cmOStringStream ostr;
ostr << graphNodePrefix << cnt++;
targetDeps[libName] = 2; targetDeps[libName] = 2;
targetNamesNodes[libName] = tgtName; targetNamesNodes[libName] = ostr.str();
//str << " \"" << tgtName << "\" [ label=\"" << libName //str << " \"" << ostr.c_str() << "\" [ label=\"" << libName
//<< "\" shape=\"ellipse\"];" << std::endl; //<< "\" shape=\"ellipse\"];" << std::endl;
} }
else else