[Cmake-commits] CMake branch, next, updated. v3.1.2-1204-g03d60ba

Stephen Kelly steveire at gmail.com
Tue Feb 10 18:50:11 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  03d60ba97b9790ec80a22be5b51d91492235a11f (commit)
       via  a7c8ee44932d6983dea9a55bf18857ee9aa3e75f (commit)
       via  f09d355d7dd7f1d66b7f43980523b673f12f6798 (commit)
       via  63dcb641c903d97f4e26a83e3efcf24acbb44f53 (commit)
       via  87680637654721c4827636f571f794865c2c0a55 (commit)
       via  709e3e17fbbc3fec6dc30d31c8f3a083f5e83d8e (commit)
       via  cc02a6647b5473d3c92318f134ffa6ef081564d7 (commit)
       via  780f75dc43f754e3ad10bf48328a33c1d2173463 (commit)
       via  d4cee4e382e48949920b81e7219ab48f06bfc398 (commit)
       via  1e57ca6f0f69efb3238a98434fb086c30f1a02f1 (commit)
       via  55a11552a49c59b786feb9c229ec2d4ee84a70e7 (commit)
       via  05097f44d032e65891746edf5fecc610017ef214 (commit)
       via  4d3b952d7b2d4d708d823914e49c07cd9c065880 (commit)
       via  ee1304531efb85b41d3c2f84f32c7d2901298be7 (commit)
       via  b4edadd2c32f881a06c79ab7c1385a27ddc4b971 (commit)
       via  7b92bdd86f6d180031d8bea2222f4dc971eab8d3 (commit)
       via  8da80aed2d8b2d82f0bd56804fe9366ea651d516 (commit)
       via  45795a9a2e8d51b72fb5f19a5de1db628c7dd2cb (commit)
       via  562a3ea3d4c4ba431f7c109c6fac41decba96e50 (commit)
       via  7e7d489030dbd63dfb00d407b4d61a33d55747b5 (commit)
       via  ac26d4b343aece40b6b9a931ab619fc88d4b9492 (commit)
      from  fd2cc9a1071279c0e3d41c38d670d0e669ab92bb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=03d60ba97b9790ec80a22be5b51d91492235a11f
commit 03d60ba97b9790ec80a22be5b51d91492235a11f
Merge: fd2cc9a a7c8ee4
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 18:50:01 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Feb 10 18:50:01 2015 -0500

    Merge topic 'use-cmRange' into next
    
    a7c8ee44 Convert loop into two algorithms.
    f09d355d Convert loop to the common pattern.
    63dcb641 Move loop inside of condition.
    87680637 Handle last element outside of the loop.
    709e3e17 cmTarget: Use a sorted vector in place of a set.
    cc02a664 cmSet: Replace loop with cmJoin.
    780f75dc cmFindBase: Replace loop with cmJoin on range.
    d4cee4e3 Convert loops to cmJoin algorithm with cmRange.
    1e57ca6f cmStringCommand: Accumulate with cmJoin and range adaptors.
    55a11552 cmAlgorithms: Add a range adaptor and API for adjusting a range.
    05097f44 Use cmJoin to accumulate string ranges.
    4d3b952d cmAlgorithms: Add a Range container and adaptor method.
    ee130453 Replace common loop pattern with cmJoin
    b4edadd2 Convert loops populating maybe-empty content into the common pattern.
    7b92bdd8 Convert loops into the commonly used pattern.
    8da80aed cmMacroCommand: Remove counting variable.
    ...


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7c8ee44932d6983dea9a55bf18857ee9aa3e75f
commit a7c8ee44932d6983dea9a55bf18857ee9aa3e75f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 24 18:07:37 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:15 2015 +0100

    Convert loop into two algorithms.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 359141a..a08c159 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2299,16 +2299,12 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
       {
       // Now add the rest of the components separated by the proper slash
       // direction for this platform.
-      const char* sep = "";
-      for(unsigned int i=1; i < components.size() - 1; ++i)
-        {
-        if(!components[i].empty())
-          {
-          result += sep;
-          result += components[i];
-          sep = slash;
-          }
-        }
+      std::vector<std::string>::const_iterator compEnd
+          = std::remove(components.begin() + 1, components.end() - 1,
+                          std::string());
+      std::vector<std::string>::const_iterator compStart
+          = components.begin() + 1;
+      result += cmJoin(cmRange(compStart, compEnd), slash);
       // Only the last component can be empty to avoid double slashes.
       result += slash;
       result += components.back();

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f09d355d7dd7f1d66b7f43980523b673f12f6798
commit f09d355d7dd7f1d66b7f43980523b673f12f6798
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jan 23 01:06:40 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:15 2015 +0100

    Convert loop to the common pattern.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 703ab27..359141a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2299,24 +2299,18 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
       {
       // Now add the rest of the components separated by the proper slash
       // direction for this platform.
-      bool first = true;
+      const char* sep = "";
       for(unsigned int i=1; i < components.size() - 1; ++i)
         {
         if(!components[i].empty())
           {
-          if(!first)
-            {
-            result += slash;
-            }
+          result += sep;
           result += components[i];
-          first = false;
+          sep = slash;
           }
         }
       // Only the last component can be empty to avoid double slashes.
-      if(!first)
-        {
-        result += slash;
-        }
+      result += slash;
       result += components.back();
       }
     }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=63dcb641c903d97f4e26a83e3efcf24acbb44f53
commit 63dcb641c903d97f4e26a83e3efcf24acbb44f53
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 23:09:03 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    Move loop inside of condition.
    
    The loop is only executed if the condition is true.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 32da821..703ab27 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2295,23 +2295,23 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
     // Begin the quoted result with the root component.
     result += components[0];
 
-    // Now add the rest of the components separated by the proper slash
-    // direction for this platform.
-    bool first = true;
-    for(unsigned int i=1; i < components.size() - 1; ++i)
+    if (components.size() > 1)
       {
-      if(!components[i].empty())
+      // Now add the rest of the components separated by the proper slash
+      // direction for this platform.
+      bool first = true;
+      for(unsigned int i=1; i < components.size() - 1; ++i)
         {
-        if(!first)
+        if(!components[i].empty())
           {
-          result += slash;
+          if(!first)
+            {
+            result += slash;
+            }
+          result += components[i];
+          first = false;
           }
-        result += components[i];
-        first = false;
         }
-      }
-    if (components.size() > 1)
-      {
       // Only the last component can be empty to avoid double slashes.
       if(!first)
         {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87680637654721c4827636f571f794865c2c0a55
commit 87680637654721c4827636f571f794865c2c0a55
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jan 23 01:03:45 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    Handle last element outside of the loop.
    
    There is no point in checking on each loop iteration whether
    it is the last element.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 54d330f..32da821 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2298,10 +2298,9 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
     // Now add the rest of the components separated by the proper slash
     // direction for this platform.
     bool first = true;
-    for(unsigned int i=1; i < components.size(); ++i)
+    for(unsigned int i=1; i < components.size() - 1; ++i)
       {
-      // Only the last component can be empty to avoid double slashes.
-      if(!components[i].empty() || (i == (components.size()-1)))
+      if(!components[i].empty())
         {
         if(!first)
           {
@@ -2311,6 +2310,15 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
         first = false;
         }
       }
+    if (components.size() > 1)
+      {
+      // Only the last component can be empty to avoid double slashes.
+      if(!first)
+        {
+        result += slash;
+        }
+      result += components.back();
+      }
     }
 
   // Close the quoted result.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=709e3e17fbbc3fec6dc30d31c8f3a083f5e83d8e
commit 709e3e17fbbc3fec6dc30d31c8f3a083f5e83d8e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:48:02 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    cmTarget: Use a sorted vector in place of a set.
    
    The vector has a more easy-to-use API.
    
    Join the string with cmJoin, and avoid erasing from the container
    in the loop.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f0bdea7..526a923 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -6687,40 +6687,33 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
 
   if (!prop.empty())
     {
-    // Use a std::set to keep the error message sorted.
-    std::set<std::string> props;
+    // Use a sorted std::vector to keep the error message sorted.
+    std::vector<std::string> props;
     std::set<std::string>::const_iterator i = emittedBools.find(prop);
     if (i != emittedBools.end())
       {
-      props.insert(strBool);
+      props.push_back(strBool);
       }
     i = emittedStrings.find(prop);
     if (i != emittedStrings.end())
       {
-      props.insert(strString);
+      props.push_back(strString);
       }
     i = emittedMinNumbers.find(prop);
     if (i != emittedMinNumbers.end())
       {
-      props.insert(strNumMin);
+      props.push_back(strNumMin);
       }
     i = emittedMaxNumbers.find(prop);
     if (i != emittedMaxNumbers.end())
       {
-      props.insert(strNumMax);
+      props.push_back(strNumMax);
       }
+    std::sort(props.begin(), props.end());
+
+    std::string propsString = cmJoin(cmRange(props).retreat(1), ", ");
+    propsString += " and the " + props.back();
 
-    std::string propsString = *props.begin();
-    props.erase(props.begin());
-    while (props.size() > 1)
-      {
-      propsString += ", " + *props.begin();
-      props.erase(props.begin());
-      }
-   if (props.size() == 1)
-     {
-     propsString += " and the " + *props.begin();
-     }
     std::ostringstream e;
     e << "Property \"" << prop << "\" appears in both the "
       << propsString <<

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc02a6647b5473d3c92318f134ffa6ef081564d7
commit cc02a6647b5473d3c92318f134ffa6ef081564d7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 23:26:58 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    cmSet: Replace loop with cmJoin.

diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 90d7b03..204d95b 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -108,17 +108,7 @@ bool cmSetCommand
     }
 
   // collect any values into a single semi-colon separated value list
-  if(static_cast<unsigned short>(args.size()) >
-     static_cast<unsigned short>(1 + ignoreLastArgs))
-    {
-    value = args[1];
-    size_t endPos = args.size() - ignoreLastArgs;
-    for(size_t i = 2; i < endPos; ++i)
-      {
-      value += ";";
-      value += args[i];
-      }
-    }
+  value = cmJoin(cmRange(args).advance(1).retreat(ignoreLastArgs), ";");
 
   if (parentScope)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=780f75dc43f754e3ad10bf48328a33c1d2173463
commit 780f75dc43f754e3ad10bf48328a33c1d2173463
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 22:23:41 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    cmFindBase: Replace loop with cmJoin on range.

diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 69991d5..6e55533 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -166,11 +166,9 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
       }
     else
       {
-      this->VariableDocumentation += "one of the " + this->Names[0];
-      for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
-        {
-        this->VariableDocumentation += ", " + this->Names[j];
-        }
+      this->VariableDocumentation += "one of the ";
+      this->VariableDocumentation += cmJoin(cmRange(this->Names).retreat(1),
+                                            ", ");
       this->VariableDocumentation += " or "
         + this->Names[this->Names.size() - 1] + " libraries be found";
       }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4cee4e382e48949920b81e7219ab48f06bfc398
commit d4cee4e382e48949920b81e7219ab48f06bfc398
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:53:20 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:35:14 2015 +0100

    Convert loops to cmJoin algorithm with cmRange.

diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 8d1657d..dd0cfa9 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -259,14 +259,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
     {
     listString += ";";
     }
-  const char* sep = "";
-  size_t cc;
-  for ( cc = 2; cc < args.size(); ++ cc )
-    {
-    listString += sep;
-    listString += args[cc];
-    sep = ";";
-    }
+  listString += cmJoin(cmRange(args).advance(2), ";");
 
   this->Makefile->AddDefinition(listName, listString.c_str());
   return true;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 05d8ab5..35956ad 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3016,13 +3016,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
     {
     relative += "/";
     }
-  const char* sep = "";
-  for(unsigned int i=common; i < remote.size(); ++i)
-    {
-    relative += sep;
-    relative += remote[i];
-    sep = "/";
-    }
+  relative += cmJoin(cmRange(remote).advance(common), "/");
 
   // Finally return the path.
   return relative;
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 14b241d..ecdd4a0 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -172,12 +172,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
                 }
               std::vector<std::string>::const_iterator eit
                   = expandedArgs.begin() + this->Args.size() - 1;
-              const char* sep = "";
-              for( ; eit != expandedArgs.end(); ++eit)
-                {
-                argnDef += sep + *eit;
-                sep = ";";
-                }
+              argnDef += cmJoin(cmRange(eit, expandedArgs.end()), ";");
               }
             argnDefInitialized = true;
             }
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 5260cb0..5c93975 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -406,12 +406,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     // Clock command
     else if (args[1] == "time" && args.size() > 2)
       {
-      std::string command = args[2];
-      for (std::string::size_type cc = 3; cc < args.size(); cc ++)
-        {
-        command += " ";
-        command += args[cc];
-        }
+      std::string command = cmJoin(cmRange(args).advance(2), " ");
 
       clock_t clock_start, clock_finish;
       time_t time_start, time_finish;
@@ -473,14 +468,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         }
 
       std::string command = "\"";
-      command += args[3];
+      command += cmJoin(cmRange(args).advance(3), "\" \"");
       command += "\"";
-      for (std::string::size_type cc = 4; cc < args.size(); cc ++)
-        {
-        command += " \"";
-        command += args[cc];
-        command += "\"";
-        }
       int retval = 0;
       int timeout = 0;
       if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e57ca6f0f69efb3238a98434fb086c30f1a02f1
commit 1e57ca6f0f69efb3238a98434fb086c30f1a02f1
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:23:41 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    cmStringCommand: Accumulate with cmJoin and range adaptors.

diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 3e606d7..edc6afc 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -303,13 +303,6 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
   std::string regex = args[2];
   std::string outvar = args[3];
 
-  // Concatenate all the last arguments together.
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -321,6 +314,9 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   if(re.find(input.c_str()))
@@ -352,13 +348,6 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
   std::string regex = args[2];
   std::string outvar = args[3];
 
-  // Concatenate all the last arguments together.
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -371,6 +360,9 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   const char* p = input.c_str();
@@ -456,13 +448,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
     l = r;
     }
 
-  // Concatenate all the last arguments together.
-  std::string input = args[5];
-  for(unsigned int i=6; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -475,6 +460,9 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(5), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   std::string::size_type base = 0;
@@ -673,11 +661,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
   const std::string& replaceExpression = args[2];
   const std::string& variableName = args[3];
 
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
 
   cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
                                     replaceExpression.c_str());
@@ -756,11 +740,7 @@ bool cmStringCommand
     }
 
   std::string const& variableName = args[1];
-  std::string value;
-  for(unsigned int i = 2; i < args.size(); ++i)
-    {
-    value += args[i];
-    }
+  std::string value = cmJoin(cmRange(args).advance(2), std::string());
 
   this->Makefile->AddDefinition(variableName, value.c_str());
   return true;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55a11552a49c59b786feb9c229ec2d4ee84a70e7
commit 55a11552a49c59b786feb9c229ec2d4ee84a70e7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:14:54 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    cmAlgorithms: Add a range adaptor and API for adjusting a range.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 6c03f51..851b105 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -122,6 +122,17 @@ struct Range
   const_iterator begin() const { return Begin; }
   const_iterator end() const { return End; }
   bool empty() const { return std::distance(Begin, End) == 0; }
+  Range& advance(size_t amount)
+  {
+    std::advance(Begin, amount);
+    return *this;
+  }
+
+  Range& retreat(size_t amount)
+  {
+    std::advance(End, -amount);
+    return *this;
+  }
 private:
   const_iterator Begin;
   const_iterator End;
@@ -135,6 +146,14 @@ ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end)
   return ContainerAlgorithms::Range<Iter1>(begin, end);
 }
 
+template<typename Range>
+ContainerAlgorithms::Range<typename Range::const_iterator>
+cmRange(Range const& range)
+{
+  return ContainerAlgorithms::Range<typename Range::const_iterator>(
+      range.begin(), range.end());
+}
+
 template<typename Container>
 void cmDeleteAll(Container const& c)
 {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05097f44d032e65891746edf5fecc610017ef214
commit 05097f44d032e65891746edf5fecc610017ef214
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 21:27:25 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    Use cmJoin to accumulate string ranges.
    
    Avoid using the std::accumulate algorithm which is designed for
    numeric types, not complex types.  It introduces unneccessary
    copies.
    
    Initialize variables where they are populated.

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8b893bc..212603c 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -217,7 +217,6 @@ bool cmFileCommand
 bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
   bool append)
 {
-  std::string message;
   std::vector<std::string>::const_iterator i = args.begin();
 
   i++; // Get rid of subcommand
@@ -231,10 +230,6 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
 
   i++;
 
-  for(;i != args.end(); ++i)
-    {
-    message += *i;
-    }
   if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
     {
     std::string e
@@ -272,6 +267,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
     this->SetError(error);
     return false;
     }
+  std::string message = cmJoin(cmRange(i, args.end()), std::string());
   file << message;
   file.close();
   if(mode)
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 88d6a77..0449c50 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -20,7 +20,6 @@ bool cmMessageCommand
     this->SetError("called with incorrect number of arguments");
     return false;
     }
-  std::string message;
   std::vector<std::string>::const_iterator i = args.begin();
 
   cmake::MessageType type = cmake::MESSAGE;
@@ -70,10 +69,7 @@ bool cmMessageCommand
     ++i;
     }
 
-  for(;i != args.end(); ++i)
-    {
-    message += *i;
-    }
+  std::string message = cmJoin(cmRange(i, args.end()), std::string());
 
   if (type != cmake::MESSAGE)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d3b952d7b2d4d708d823914e49c07cd9c065880
commit 4d3b952d7b2d4d708d823914e49c07cd9c065880
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:19:21 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    cmAlgorithms: Add a Range container and adaptor method.
    
    This can make a pair of iterators API compatible with the
    cmJoin algorithm and other range-based algorithms.
    
    Accept different iterator types in the cmRange adaptor so that
    a const and non-const iterator are accepted.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 4938140..6c03f51 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -112,6 +112,27 @@ struct DefaultDeleter<Container, /* valueTypeIsPair = */ true>
   }
 };
 
+template<typename const_iterator_>
+struct Range
+{
+  typedef const_iterator_ const_iterator;
+  typedef typename std::iterator_traits<const_iterator>::value_type value_type;
+  Range(const_iterator begin_, const_iterator end_)
+    : Begin(begin_), End(end_) {}
+  const_iterator begin() const { return Begin; }
+  const_iterator end() const { return End; }
+  bool empty() const { return std::distance(Begin, End) == 0; }
+private:
+  const_iterator Begin;
+  const_iterator End;
+};
+
+}
+
+template<typename Iter1, typename Iter2>
+ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end)
+{
+  return ContainerAlgorithms::Range<Iter1>(begin, end);
 }
 
 template<typename Container>

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee1304531efb85b41d3c2f84f32c7d2901298be7
commit ee1304531efb85b41d3c2f84f32c7d2901298be7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 21:31:46 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    Replace common loop pattern with cmJoin

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 7746980..fd9b236 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1064,26 +1064,11 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
     }
 
 
-  std::string tmp;
-  const char* sep ="";
-  for(size_t i=0; i<foundContents.size(); i++)
-    {
-    tmp += sep;
-    tmp += foundContents[i];
-    sep = ";";
-    }
-
+  std::string tmp = cmJoin(foundContents, ";");
   this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_FOUND",
                                                   tmp.c_str());
 
-  tmp = "";
-  sep = "";
-  for(size_t i=0; i<notFoundContents.size(); i++)
-    {
-    tmp += sep;
-    tmp += notFoundContents[i];
-    sep = ";";
-    }
+  tmp = cmJoin(notFoundContents, ";");
   this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_NOT_FOUND",
                                                   tmp.c_str());
 }
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index c33048c..2e71b01 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -194,11 +194,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
       {
       std::string name = this->Args[0];
       std::vector<std::string>::size_type cc;
-      name += "(";
-      for ( cc = 0; cc < this->Args.size(); cc ++ )
-        {
-        name += " " + this->Args[cc];
-        }
+      name += "( ";
+      name += cmJoin(this->Args, " ");
       name += " )";
 
       // create a new command and add it to cmake
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index c0e4683..84c00ba 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -34,15 +34,7 @@ bool cmGetCMakePropertyCommand
     std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
     if (!vars.empty())
       {
-      output = "";
-      const char* sep = "";
-      std::vector<std::string>::size_type cc;
-      for ( cc = 0; cc < vars.size(); ++cc )
-        {
-        output += sep;
-        output += vars[cc];
-        sep = ";";
-        }
+      output = cmJoin(vars, ";");
       }
     }
   else if ( args[1] == "MACROS" )
@@ -54,15 +46,7 @@ bool cmGetCMakePropertyCommand
     const std::set<std::string>* components
       = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
         ->GetInstallComponents();
-    std::set<std::string>::const_iterator compIt;
-    output = "";
-    const char* sep = "";
-    for (compIt = components->begin(); compIt != components->end(); ++compIt)
-      {
-      output += sep;
-      output += *compIt;
-      sep = ";";
-      }
+    output = cmJoin(*components, ";");
     }
   else
     {
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 27154d2..14b241d 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -197,14 +197,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
               {
               argvDef += ";";
               }
-            const char* sep = "";
-            std::vector<std::string>::const_iterator eit;
-            for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
-              {
-              argvDef += sep;
-              argvDef += *eit;
-              sep = ";";
-              }
+            argvDef += cmJoin(expandedArgs, ";");
             argvDefInitialized = true;
             }
           cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aca4413..ac5fec9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4202,15 +4202,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LISTFILE_STACK")
     {
-    const char* sep = "";
-    for (std::deque<std::string>::const_iterator
-        i = this->ListFileStack.begin();
-        i != this->ListFileStack.end(); ++i)
-      {
-      output += sep;
-      output += *i;
-      sep = ";";
-      }
+    output = cmJoin(this->ListFileStack, ";");
     return output.c_str();
     }
   else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
@@ -4220,14 +4212,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
       {
       cacheonly = 1;
       }
-    std::vector<std::string> vars = this->GetDefinitions(cacheonly);
-    const char* sep = "";
-    for (unsigned int cc = 0; cc < vars.size(); cc ++ )
-      {
-      output += sep;
-      output += vars[cc];
-      sep = ";";
-      }
+    output = cmJoin(this->GetDefinitions(cacheonly), ";");
     return output.c_str();
     }
   else if (prop == "MACROS")
@@ -4242,16 +4227,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LINK_DIRECTORIES")
     {
-    const char* sep = "";
-    for (std::vector<std::string>::const_iterator
-         it = this->GetLinkDirectories().begin();
-         it != this->GetLinkDirectories().end();
-         ++ it )
-      {
-      output += sep;
-      output += *it;
-      sep = ";";
-      }
+    output = cmJoin(this->GetLinkDirectories(), ";");
     return output.c_str();
     }
   else if (prop == "INCLUDE_DIRECTORIES")
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index e505440..60728ea 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -34,11 +34,7 @@ bool cmOptionCommand
   if(argError)
     {
     std::string m = "called with incorrect number of arguments: ";
-    for(size_t i =0; i < args.size(); ++i)
-      {
-      m += args[i];
-      m += " ";
-      }
+    m += cmJoin(args, " ");
     this->SetError(m);
     return false;
     }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4edadd2c32f881a06c79ab7c1385a27ddc4b971
commit b4edadd2c32f881a06c79ab7c1385a27ddc4b971
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 17 17:36:19 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:34 2015 +0100

    Convert loops populating maybe-empty content into the common pattern.

diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 107dca9..8d1657d 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -254,14 +254,18 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
   // expand the variable
   std::string listString;
   this->GetListString(listString, listName);
+
+  if(!listString.empty() && !args.empty())
+    {
+    listString += ";";
+    }
+  const char* sep = "";
   size_t cc;
   for ( cc = 2; cc < args.size(); ++ cc )
     {
-    if(!listString.empty())
-      {
-      listString += ";";
-      }
+    listString += sep;
     listString += args[cc];
+    sep = ";";
     }
 
   this->Makefile->AddDefinition(listName, listString.c_str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7afe05f..05d8ab5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3011,13 +3011,17 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
   // trailing slash in the input then the last iteration of the loop
   // will add a slash followed by an empty string which will preserve
   // the trailing slash in the output.
+
+  if(!relative.empty() && !remote.empty())
+    {
+    relative += "/";
+    }
+  const char* sep = "";
   for(unsigned int i=common; i < remote.size(); ++i)
     {
-    if(!relative.empty())
-      {
-      relative += "/";
-      }
+    relative += sep;
     relative += remote[i];
+    sep = "/";
     }
 
   // Finally return the path.
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 8ffd909..27154d2 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -166,15 +166,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
             {
             if (expandedArgs.size() > this->Args.size() - 1)
               {
+              if (!argnDef.empty() && !expandedArgs.empty())
+                {
+                argnDef += ";";
+                }
               std::vector<std::string>::const_iterator eit
                   = expandedArgs.begin() + this->Args.size() - 1;
+              const char* sep = "";
               for( ; eit != expandedArgs.end(); ++eit)
                 {
-                if (!argnDef.empty())
-                  {
-                  argnDef += ";";
-                  }
-                argnDef += *eit;
+                argnDef += sep + *eit;
+                sep = ";";
                 }
               }
             argnDefInitialized = true;
@@ -191,14 +193,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
           // repleace ARGV, compute it only once
           if (!argvDefInitialized)
             {
+            if (!argvDef.empty() && !expandedArgs.empty())
+              {
+              argvDef += ";";
+              }
+            const char* sep = "";
             std::vector<std::string>::const_iterator eit;
             for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
               {
-              if (!argvDef.empty())
-                {
-                argvDef += ";";
-                }
+              argvDef += sep;
               argvDef += *eit;
+              sep = ";";
               }
             argvDefInitialized = true;
             }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b92bdd86f6d180031d8bea2222f4dc971eab8d3
commit 7b92bdd86f6d180031d8bea2222f4dc971eab8d3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 17 17:47:10 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:33 2015 +0100

    Convert loops into the commonly used pattern.

diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index e193cf5..c0e4683 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -25,7 +25,6 @@ bool cmGetCMakePropertyCommand
     return false;
     }
 
-  std::vector<std::string>::size_type cc;
   std::string variable = args[0];
   std::string output = "NOTFOUND";
 
@@ -35,12 +34,15 @@ bool cmGetCMakePropertyCommand
     std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
     if (!vars.empty())
       {
-      output = vars[0];
-      }
-    for ( cc = 1; cc < vars.size(); ++cc )
-      {
-      output += ";";
-      output += vars[cc];
+      output = "";
+      const char* sep = "";
+      std::vector<std::string>::size_type cc;
+      for ( cc = 0; cc < vars.size(); ++cc )
+        {
+        output += sep;
+        output += vars[cc];
+        sep = ";";
+        }
       }
     }
   else if ( args[1] == "MACROS" )
@@ -54,13 +56,12 @@ bool cmGetCMakePropertyCommand
         ->GetInstallComponents();
     std::set<std::string>::const_iterator compIt;
     output = "";
+    const char* sep = "";
     for (compIt = components->begin(); compIt != components->end(); ++compIt)
       {
-      if (compIt != components->begin())
-        {
-        output += ";";
-        }
+      output += sep;
       output += *compIt;
+      sep = ";";
       }
     }
   else
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index eb68e49..aca4413 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3752,15 +3752,12 @@ void cmMakefile::GetListOfMacros(std::string& macros) const
 {
   StringStringMap::const_iterator it;
   macros = "";
-  int cc = 0;
+  const char* sep = "";
   for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it )
     {
-    if ( cc > 0 )
-      {
-      macros += ";";
-      }
+    macros += sep;
     macros += it->first;
-    cc ++;
+    sep = "";
     }
 }
 
@@ -4205,15 +4202,14 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LISTFILE_STACK")
     {
+    const char* sep = "";
     for (std::deque<std::string>::const_iterator
         i = this->ListFileStack.begin();
         i != this->ListFileStack.end(); ++i)
       {
-      if (i != this->ListFileStack.begin())
-        {
-        output += ";";
-        }
+      output += sep;
       output += *i;
+      sep = ";";
       }
     return output.c_str();
     }
@@ -4225,13 +4221,12 @@ const char *cmMakefile::GetProperty(const std::string& prop,
       cacheonly = 1;
       }
     std::vector<std::string> vars = this->GetDefinitions(cacheonly);
+    const char* sep = "";
     for (unsigned int cc = 0; cc < vars.size(); cc ++ )
       {
-      if ( cc > 0 )
-        {
-        output += ";";
-        }
+      output += sep;
       output += vars[cc];
+      sep = ";";
       }
     return output.c_str();
     }
@@ -4247,19 +4242,16 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LINK_DIRECTORIES")
     {
-    std::ostringstream str;
+    const char* sep = "";
     for (std::vector<std::string>::const_iterator
          it = this->GetLinkDirectories().begin();
          it != this->GetLinkDirectories().end();
          ++ it )
       {
-      if ( it != this->GetLinkDirectories().begin())
-        {
-        str << ";";
-        }
-      str << it->c_str();
+      output += sep;
+      output += *it;
+      sep = ";";
       }
-    output = str.str();
     return output.c_str();
     }
   else if (prop == "INCLUDE_DIRECTORIES")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8da80aed2d8b2d82f0bd56804fe9366ea651d516
commit 8da80aed2d8b2d82f0bd56804fe9366ea651d516
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:47:21 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:33 2015 +0100

    cmMacroCommand: Remove counting variable.
    
    Start iteration at correct starting point directly.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 743cd13..8ffd909 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -167,19 +167,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
             if (expandedArgs.size() > this->Args.size() - 1)
               {
               std::vector<std::string>::const_iterator eit
-                  = expandedArgs.begin();
-              std::vector<std::string>::size_type cnt = 0;
+                  = expandedArgs.begin() + this->Args.size() - 1;
               for( ; eit != expandedArgs.end(); ++eit)
                 {
-                if ( cnt >= this->Args.size()-1 )
+                if (!argnDef.empty())
                   {
-                  if (!argnDef.empty())
-                    {
-                    argnDef += ";";
-                    }
-                  argnDef += *eit;
+                  argnDef += ";";
                   }
-                cnt ++;
+                argnDef += *eit;
                 }
               }
             argnDefInitialized = true;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45795a9a2e8d51b72fb5f19a5de1db628c7dd2cb
commit 45795a9a2e8d51b72fb5f19a5de1db628c7dd2cb
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:44:49 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:33 2015 +0100

    cmMacroCommand: Execute loop only if it has an effect.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 5f7fa36..743cd13 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -164,20 +164,23 @@ bool cmMacroHelperCommand::InvokeInitialPass
           {
           if (!argnDefInitialized)
             {
-            std::vector<std::string>::const_iterator eit
-                = expandedArgs.begin();
-            std::vector<std::string>::size_type cnt = 0;
-            for( ; eit != expandedArgs.end(); ++eit)
+            if (expandedArgs.size() > this->Args.size() - 1)
               {
-              if ( cnt >= this->Args.size()-1 )
+              std::vector<std::string>::const_iterator eit
+                  = expandedArgs.begin();
+              std::vector<std::string>::size_type cnt = 0;
+              for( ; eit != expandedArgs.end(); ++eit)
                 {
-                if (!argnDef.empty())
+                if ( cnt >= this->Args.size()-1 )
                   {
-                  argnDef += ";";
+                  if (!argnDef.empty())
+                    {
+                    argnDef += ";";
+                    }
+                  argnDef += *eit;
                   }
-                argnDef += *eit;
+                cnt ++;
                 }
-              cnt ++;
               }
             argnDefInitialized = true;
             }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=562a3ea3d4c4ba431f7c109c6fac41decba96e50
commit 562a3ea3d4c4ba431f7c109c6fac41decba96e50
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:42:12 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:33 2015 +0100

    cmMacroCommand: Extract iteration starting point.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index a5804b2..5f7fa36 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -164,9 +164,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
           {
           if (!argnDefInitialized)
             {
-            std::vector<std::string>::const_iterator eit;
+            std::vector<std::string>::const_iterator eit
+                = expandedArgs.begin();
             std::vector<std::string>::size_type cnt = 0;
-            for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
+            for( ; eit != expandedArgs.end(); ++eit)
               {
               if ( cnt >= this->Args.size()-1 )
                 {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7e7d489030dbd63dfb00d407b4d61a33d55747b5
commit 7e7d489030dbd63dfb00d407b4d61a33d55747b5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 00:29:20 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 00:30:20 2015 +0100

    cmMacroCommand: Replace a loop with cmJoin.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 69fcca7..a5804b2 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -264,9 +264,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
       std::string name = this->Args[0];
       std::vector<std::string>::size_type cc;
       name += "(";
-      for ( cc = 0; cc < this->Args.size(); cc ++ )
+      if (!this->Args.empty())
         {
-        name += " " + this->Args[cc];
+        name += " ";
+        name += cmJoin(this->Args, " ");
         }
       name += " )";
       mf.AddMacro(this->Args[0].c_str(), name.c_str());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac26d4b343aece40b6b9a931ab619fc88d4b9492
commit ac26d4b343aece40b6b9a931ab619fc88d4b9492
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 21:50:16 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue Feb 10 22:14:18 2015 +0100

    Split cmAlgorithms into a separate header file.

diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index a07c29a..4626142 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -46,6 +46,7 @@
 #endif
 
 #include "cmCPackLog.h"
+#include "cmAlgorithms.h"
 
 
 //----------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 98bc9d7..6b84bab 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -13,6 +13,7 @@
 
 #include "cmCTest.h"
 #include "cmSystemTools.h"
+#include "cmAlgorithms.h"
 #include "cmXMLSafe.h"
 
 #include <cmsys/RegularExpression.hxx>
diff --git a/Source/cmStandardIncludes.h b/Source/cmAlgorithms.h
similarity index 52%
copy from Source/cmStandardIncludes.h
copy to Source/cmAlgorithms.h
index 77b4f62..4938140 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmAlgorithms.h
@@ -1,6 +1,6 @@
 /*============================================================================
   CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+  Copyright 2015 Stephen Kelly <steveire at gmail.com>
 
   Distributed under the OSI-approved BSD License (the "License");
   see accompanying file Copyright.txt for details.
@@ -9,154 +9,10 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-/**
- * Include header files as a function of the build process, compiler,
- * and operating system.
- */
-#ifndef cmStandardIncludes_h
-#define cmStandardIncludes_h
+#ifndef cmAlgorithms_h
+#define cmAlgorithms_h
 
-#include <cmConfigure.h>
-#include <cmsys/Configure.hxx>
-
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#pragma warning ( disable : 4503 )
-#endif
-
-
-#ifdef __ICL
-#pragma warning ( disable : 985 )
-#pragma warning ( disable : 1572 ) /* floating-point equality test */
-#endif
-
-// Provide fixed-size integer types.
-#include <cmIML/INT.h>
-
-// Include stream compatibility layer from KWSys.
-// This is needed to work with large file support
-// on some platforms whose stream operators do not
-// support the large integer types.
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <cmsys/IOStream.hxx>
-#endif
-
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <sstream>
-
-// we must have stl with the standard include style
-#include <vector>
-#include <string>
-#include <iterator>
-#include <algorithm>
-#include <functional>
-#include <map>
-#include <set>
-
-// include the "c" string header
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#if defined( _MSC_VER )
-typedef unsigned short mode_t;
-#endif
-
-// use this class to shrink the size of symbols in .o files
-// std::string is really basic_string<....lots of stuff....>
-// when combined with a map or set, the symbols can be > 2000 chars!
-#include <cmsys/String.hxx>
-//typedef cmsys::String std::string;
-
-/* Poison this operator to avoid common mistakes.  */
-extern void operator << (std::ostream&, const std::ostringstream&);
-
-/** Standard documentation entry for cmDocumentation's formatting.  */
-struct cmDocumentationEntry
-{
-  std::string Name;
-  std::string Brief;
-  cmDocumentationEntry(){}
-  cmDocumentationEntry(const char *doc[2])
-  { if (doc[0]) this->Name = doc[0];
-  if (doc[1]) this->Brief = doc[1];}
-  cmDocumentationEntry(const char *n, const char *b)
-  { if (n) this->Name = n; if (b) this->Brief = b; }
-};
-
-/** Data structure to represent a single command line.  */
-class cmCustomCommandLine: public std::vector<std::string>
-{
-public:
-  typedef std::vector<std::string> Superclass;
-  typedef Superclass::iterator iterator;
-  typedef Superclass::const_iterator const_iterator;
-};
-
-/** Data structure to represent a list of command lines.  */
-class cmCustomCommandLines: public std::vector<cmCustomCommandLine>
-{
-public:
-  typedef std::vector<cmCustomCommandLine> Superclass;
-  typedef Superclass::iterator iterator;
-  typedef Superclass::const_iterator const_iterator;
-};
-
-// All subclasses of cmCommand or cmCTestGenericHandler should
-// invoke this macro.
-#define cmTypeMacro(thisClass,superclass) \
-virtual const char* GetNameOfClass() { return #thisClass; } \
-typedef superclass Superclass; \
-static bool IsTypeOf(const char *type) \
-{ \
-  if ( !strcmp(#thisClass,type) ) \
-    { \
-    return true; \
-    } \
-  return Superclass::IsTypeOf(type); \
-} \
-virtual bool IsA(const char *type) \
-{ \
-  return thisClass::IsTypeOf(type); \
-} \
-static thisClass* SafeDownCast(cmObject *c) \
-{ \
-  if ( c && c->IsA(#thisClass) ) \
-    { \
-    return static_cast<thisClass *>(c); \
-    } \
-  return 0;\
-} \
-class cmTypeMacro_UseTrailingSemicolon
-
-template<typename Range>
-std::string cmJoin(Range const& r, const char* delimiter)
-{
-  if (r.empty())
-    {
-    return std::string();
-    }
-  std::ostringstream os;
-  typedef typename Range::value_type ValueType;
-  typedef typename Range::const_iterator InputIt;
-  InputIt first = r.begin();
-  InputIt last = r.end();
-  --last;
-  std::copy(first, last,
-      std::ostream_iterator<ValueType>(os, delimiter));
-
-  os << *last;
-
-  return os.str();
-}
-
-template<typename Range>
-std::string cmJoin(Range const& r, std::string delimiter)
-{
-  return cmJoin(r, delimiter.c_str());
-};
+#include "cmStandardIncludes.h"
 
 inline bool cmHasLiteralPrefixImpl(const std::string &str1,
                                  const char *str2,
@@ -265,4 +121,31 @@ void cmDeleteAll(Container const& c)
                 ContainerAlgorithms::DefaultDeleter<Container>());
 }
 
+template<typename Range>
+std::string cmJoin(Range const& r, const char* delimiter)
+{
+  if (r.empty())
+    {
+    return std::string();
+    }
+  std::ostringstream os;
+  typedef typename Range::value_type ValueType;
+  typedef typename Range::const_iterator InputIt;
+  InputIt first = r.begin();
+  InputIt last = r.end();
+  --last;
+  std::copy(first, last,
+      std::ostream_iterator<ValueType>(os, delimiter));
+
+  os << *last;
+
+  return os.str();
+}
+
+template<typename Range>
+std::string cmJoin(Range const& r, std::string delimiter)
+{
+  return cmJoin(r, delimiter.c_str());
+};
+
 #endif
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index 14812e4..4148fb5 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -12,6 +12,7 @@
 
 #include "cmExportSet.h"
 #include "cmTargetExport.h"
+#include "cmAlgorithms.h"
 
 cmExportSet::~cmExportSet()
 {
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index 14c4458..cf431c6 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -12,6 +12,7 @@
 
 #include "cmExportSetMap.h"
 #include "cmExportSet.h"
+#include "cmAlgorithms.h"
 
 cmExportSet* cmExportSetMap::operator[](const std::string &name)
 {
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index cf8e9a9..3710eb0 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -16,6 +16,7 @@
 
 #include "cmFileLock.h"
 #include "cmFileLockResult.h"
+#include "cmAlgorithms.h"
 
 cmFileLockPool::cmFileLockPool()
 {
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index 503f92c..cdb0866 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -13,6 +13,7 @@
 #define cmInstalledFile_h
 
 #include "cmGeneratorExpression.h"
+#include "cmAlgorithms.h"
 
 /** \class cmInstalledFile
  * \brief Represents a file intended for installation.
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index f4607c6..d20d999 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -12,6 +12,7 @@
 #include "cmRST.h"
 
 #include "cmSystemTools.h"
+#include "cmAlgorithms.h"
 #include "cmVersion.h"
 #include <cmsys/FStream.hxx>
 #include <ctype.h>
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 77b4f62..a9796b9 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -131,138 +131,4 @@ static thisClass* SafeDownCast(cmObject *c) \
 } \
 class cmTypeMacro_UseTrailingSemicolon
 
-template<typename Range>
-std::string cmJoin(Range const& r, const char* delimiter)
-{
-  if (r.empty())
-    {
-    return std::string();
-    }
-  std::ostringstream os;
-  typedef typename Range::value_type ValueType;
-  typedef typename Range::const_iterator InputIt;
-  InputIt first = r.begin();
-  InputIt last = r.end();
-  --last;
-  std::copy(first, last,
-      std::ostream_iterator<ValueType>(os, delimiter));
-
-  os << *last;
-
-  return os.str();
-}
-
-template<typename Range>
-std::string cmJoin(Range const& r, std::string delimiter)
-{
-  return cmJoin(r, delimiter.c_str());
-};
-
-inline bool cmHasLiteralPrefixImpl(const std::string &str1,
-                                 const char *str2,
-                                 size_t N)
-{
-  return strncmp(str1.c_str(), str2, N) == 0;
-}
-
-inline bool cmHasLiteralPrefixImpl(const char* str1,
-                                 const char *str2,
-                                 size_t N)
-{
-  return strncmp(str1, str2, N) == 0;
-}
-
-inline bool cmHasLiteralSuffixImpl(const std::string &str1,
-                                   const char *str2,
-                                   size_t N)
-{
-  size_t len = str1.size();
-  return len >= N && strcmp(str1.c_str() + len - N, str2) == 0;
-}
-
-inline bool cmHasLiteralSuffixImpl(const char* str1,
-                                   const char* str2,
-                                   size_t N)
-{
-  size_t len = strlen(str1);
-  return len >= N && strcmp(str1 + len - N, str2) == 0;
-}
-
-template<typename T, size_t N>
-const T* cmArrayBegin(const T (&a)[N]) { return a; }
-template<typename T, size_t N>
-const T* cmArrayEnd(const T (&a)[N]) { return a + N; }
-template<typename T, size_t N>
-size_t cmArraySize(const T (&)[N]) { return N; }
-
-template<typename T, size_t N>
-bool cmHasLiteralPrefix(T str1, const char (&str2)[N])
-{
-  return cmHasLiteralPrefixImpl(str1, str2, N - 1);
-}
-
-template<typename T, size_t N>
-bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
-{
-  return cmHasLiteralSuffixImpl(str1, str2, N - 1);
-}
-
-struct cmStrCmp {
-  cmStrCmp(const char *test) : m_test(test) {}
-  cmStrCmp(const std::string &test) : m_test(test) {}
-
-  bool operator()(const std::string& input) const
-  {
-    return m_test == input;
-  }
-
-  bool operator()(const char * input) const
-  {
-    return strcmp(input, m_test.c_str()) == 0;
-  }
-
-private:
-  const std::string m_test;
-};
-
-namespace ContainerAlgorithms {
-
-template<typename T>
-struct cmIsPair
-{
-  enum { value = false };
-};
-
-template<typename K, typename V>
-struct cmIsPair<std::pair<K, V> >
-{
-  enum { value = true };
-};
-
-template<typename Container,
-    bool valueTypeIsPair = cmIsPair<typename Container::value_type>::value>
-struct DefaultDeleter
-{
-  void operator()(typename Container::value_type value) {
-    delete value;
-  }
-};
-
-template<typename Container>
-struct DefaultDeleter<Container, /* valueTypeIsPair = */ true>
-{
-  void operator()(typename Container::value_type value) {
-    delete value.second;
-  }
-};
-
-}
-
-template<typename Container>
-void cmDeleteAll(Container const& c)
-{
-  std::for_each(c.begin(), c.end(),
-                ContainerAlgorithms::DefaultDeleter<Container>());
-}
-
 #endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7dd6121..bf496e9 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -11,6 +11,7 @@
 ============================================================================*/
 
 #include "cmSystemTools.h"
+#include "cmAlgorithms.h"
 #include <ctype.h>
 #include <errno.h>
 #include <time.h>
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index b8a6df2..57dde31 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -11,6 +11,8 @@
 ============================================================================*/
 #include "cmVariableWatch.h"
 
+#include "cmAlgorithms.h"
+
 static const char* const cmVariableWatchAccessStrings[] =
 {
     "READ_ACCESS",

-----------------------------------------------------------------------

Summary of changes:
 Source/CPack/cmCPackGeneratorFactory.cxx        |    1 +
 Source/CTest/cmCTestGIT.cxx                     |    1 +
 Source/{cmStandardIncludes.h => cmAlgorithms.h} |  219 ++++++++---------------
 Source/cmExportSet.cxx                          |    1 +
 Source/cmExportSetMap.cxx                       |    1 +
 Source/cmFileCommand.cxx                        |    6 +-
 Source/cmFileLockPool.cxx                       |    1 +
 Source/cmFindBase.cxx                           |    8 +-
 Source/cmFindPackageCommand.cxx                 |   19 +-
 Source/cmFunctionCommand.cxx                    |    7 +-
 Source/cmGetCMakePropertyCommand.cxx            |   19 +-
 Source/cmInstalledFile.h                        |    1 +
 Source/cmListCommand.cxx                        |   11 +-
 Source/cmLocalGenerator.cxx                     |   10 +-
 Source/cmLocalUnixMakefileGenerator3.cxx        |   24 ++-
 Source/cmMacroCommand.cxx                       |   31 ++--
 Source/cmMakefile.cxx                           |   44 +----
 Source/cmMessageCommand.cxx                     |    6 +-
 Source/cmOptionCommand.cxx                      |    6 +-
 Source/cmRST.cxx                                |    1 +
 Source/cmSetCommand.cxx                         |   12 +-
 Source/cmStandardIncludes.h                     |  134 --------------
 Source/cmStringCommand.cxx                      |   42 ++---
 Source/cmSystemTools.cxx                        |    1 +
 Source/cmTarget.cxx                             |   27 ++-
 Source/cmVariableWatch.cxx                      |    2 +
 Source/cmcmd.cxx                                |   15 +-
 27 files changed, 154 insertions(+), 496 deletions(-)
 copy Source/{cmStandardIncludes.h => cmAlgorithms.h} (53%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list