From 898dfe5a2deff445d501f3991b7553c3b3332dff Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Fri, 21 Jul 2006 13:05:56 -0400 Subject: ENH: Cleanup. Replace c-style cast with static_cast and replace sprintf with cmOStringStream --- Source/cmake.cxx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 71af58c..f3b28bf 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -942,13 +942,13 @@ int cmake::ExecuteCMakeCommand(std::vector& args) clock_finish = clock(); time(&time_finish); - double clocks_per_sec = (double)CLOCKS_PER_SEC; + double clocks_per_sec = static_cast(CLOCKS_PER_SEC); std::cout << "Elapsed time: " - << (long)(time_finish - time_start) << " s. (time)" - << ", " - << (double)(clock_finish - clock_start) / clocks_per_sec - << " s. (clock)" - << "\n"; + << static_cast(time_finish - time_start) << " s. (time)" + << ", " + << static_cast(clock_finish - clock_start) / clocks_per_sec + << " s. (clock)" + << "\n"; return 0; } @@ -2368,7 +2368,6 @@ void cmake::GenerateGraphViz(const char* fileName) std::map targetDeps; std::map targetPtrs; std::map targetNamesNodes; - char tgtName[2048]; int cnt = 0; // First pass get the list of all cmake targets for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) @@ -2384,8 +2383,9 @@ void cmake::GenerateGraphViz(const char* fileName) continue; } //std::cout << "Found target: " << tit->first.c_str() << std::endl; - sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); - targetNamesNodes[realTargetName] = tgtName; + cmOStringStream ostr; + ostr << graphNodePrefix << cnt++; + targetNamesNodes[realTargetName] = ostr.str(); targetPtrs[realTargetName] = &tit->second; } } @@ -2421,10 +2421,11 @@ void cmake::GenerateGraphViz(const char* fileName) } if ( tarIt == targetNamesNodes.end() ) { - sprintf(tgtName, "%s%d", graphNodePrefix, cnt++); + cmOStringStream ostr; + ostr << graphNodePrefix << cnt++; targetDeps[libName] = 2; - targetNamesNodes[libName] = tgtName; - //str << " \"" << tgtName << "\" [ label=\"" << libName + targetNamesNodes[libName] = ostr.str(); + //str << " \"" << ostr.c_str() << "\" [ label=\"" << libName //<< "\" shape=\"ellipse\"];" << std::endl; } else -- cgit v0.12