Browse Source

Use cmJoin where possible.

Stephen Kelly 10 years ago
parent
commit
a281809384
4 changed files with 9 additions and 51 deletions
  1. 3 12
      Source/cmCoreTryCompile.cxx
  2. 2 11
      Source/cmFindBase.cxx
  3. 1 7
      Source/cmLocalUnixMakefileGenerator3.cxx
  4. 3 21
      Source/cmcmd.cxx

+ 3 - 12
Source/cmCoreTryCompile.cxx

@@ -260,14 +260,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
         err << "Unknown extension \"" << ext << "\" for file\n"
             << "  " << *si << "\n"
             << "try_compile() works only for enabled languages.  "
-            << "Currently these are:\n ";
+            << "Currently these are:\n  ";
         std::vector<std::string> langs;
         gg->GetEnabledLanguages(langs);
-        for(std::vector<std::string>::iterator l = langs.begin();
-            l != langs.end(); ++l)
-          {
-          err << " " << *l;
-          }
+        err << cmJoin(langs, " ");
         err << "\nSee project() command to enable other languages.";
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str());
         return -1;
@@ -373,12 +369,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
     // handle any compile flags we need to pass on
     if (!compileDefs.empty())
       {
-      fprintf(fout, "add_definitions( ");
-      for (size_t i = 0; i < compileDefs.size(); ++i)
-        {
-        fprintf(fout,"%s ",compileDefs[i].c_str());
-        }
-      fprintf(fout, ")\n");
+      fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
       }
 
     /* Use a random file name to avoid rapid creation and deletion

+ 2 - 11
Source/cmFindBase.cxx

@@ -350,19 +350,10 @@ void cmFindBase::PrintFindStuff()
   std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
   std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
   std::cerr << "CMakePathName " << this->CMakePathName << "\n";
-  std::cerr << "Names  ";
-  for(unsigned int i =0; i < this->Names.size(); ++i)
-    {
-    std::cerr << this->Names[i] << " ";
-    }
-  std::cerr << "\n";
+  std::cerr << "Names  " << cmJoin(this->Names, " ") << "\n";
   std::cerr << "\n";
   std::cerr << "SearchPathSuffixes  ";
-  for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i)
-    {
-    std::cerr << this->SearchPathSuffixes[i] << "\n";
-    }
-  std::cerr << "\n";
+  std::cerr << cmJoin(this->SearchPathSuffixes, "\n") << "\n";
   std::cerr << "SearchPaths\n";
   for(std::vector<std::string>::const_iterator i = this->SearchPaths.begin();
       i != this->SearchPaths.end(); ++i)

+ 1 - 7
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1330,13 +1330,7 @@ cmLocalUnixMakefileGenerator3
                       this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
     fout << "\n"
          << "# Per-language clean rules from dependency scanning.\n"
-         << "foreach(lang";
-    for(std::set<std::string>::const_iterator l = languages.begin();
-        l != languages.end(); ++l)
-      {
-      fout << " " << *l;
-      }
-    fout << ")\n"
+         << "foreach(lang " << cmJoin(languages, " ") << ")\n"
          << "  include(" << this->GetTargetDirectory(target)
          << "/cmake_clean_${lang}.cmake OPTIONAL)\n"
          << "endforeach()\n";

+ 3 - 21
Source/cmcmd.cxx

@@ -213,27 +213,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     // Echo string
     else if (args[1] == "echo" )
       {
-      unsigned int cc;
-      const char* space = "";
-      for ( cc = 2; cc < args.size(); cc ++ )
-        {
-        std::cout << space << args[cc];
-        space = " ";
-        }
-      std::cout << std::endl;
+      std::cout << cmJoin(cmRange(args).advance(2), " ") << std::endl;
       return 0;
       }
 
     // Echo string no new line
     else if (args[1] == "echo_append" )
       {
-      unsigned int cc;
-      const char* space = "";
-      for ( cc = 2; cc < args.size(); cc ++ )
-        {
-        std::cout << space << args[cc];
-        space = " ";
-        }
+      std::cout << cmJoin(cmRange(args).advance(2), " ");
       return 0;
       }
 
@@ -1329,12 +1316,7 @@ bool cmcmd::RunCommand(const char* comment,
   if(verbose)
     {
     std::cout << comment << ":\n";
-    for(std::vector<std::string>::iterator i = command.begin();
-        i != command.end(); ++i)
-      {
-      std::cout << *i << " ";
-      }
-    std::cout << "\n";
+    std::cout << cmJoin(command, " ") << "\n";
     }
   std::string output;
   int retCode =0;