[Cmake-commits] CMake branch, master, updated. v3.11.1-675-g5e455ac

Kitware Robot kwrobot at kitware.com
Wed May 2 11:35:06 EDT 2018


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, master has been updated
       via  5e455ac120fd596a0ad1a4216c5734bb52ac1b75 (commit)
       via  0c47ed643046428617161959a5784d3d70cf5a1f (commit)
       via  e13fa223fc870ea95c6a1cfa09b61b527a1c2db5 (commit)
       via  b542e0c74f543954ba26048ce38776269b9ba203 (commit)
      from  e90fa38f8ddfd89fb23264ac6f767b9b693111ff (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5e455ac120fd596a0ad1a4216c5734bb52ac1b75
commit 5e455ac120fd596a0ad1a4216c5734bb52ac1b75
Merge: e90fa38 0c47ed6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed May 2 15:33:21 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed May 2 11:33:33 2018 -0400

    Merge topic 'code-improvements'
    
    0c47ed6430 cmMakefile: Convert private helpers to file static functions
    e13fa223fc cmMakefile: Improve ExpandVariablesInString return type
    b542e0c74f cmCPluginAPI: Remove a few unnecessary c_str() calls
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Rejected-by: Marc Chevrier <marc.chevrier at gmail.com>
    Merge-request: !2018


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c47ed643046428617161959a5784d3d70cf5a1f
commit 0c47ed643046428617161959a5784d3d70cf5a1f
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Mon Apr 30 10:50:23 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue May 1 10:25:49 2018 -0400

    cmMakefile: Convert private helpers to file static functions
    
    The two-argument forms of `AddDefineFlag` and `RemoveDefineFlag`
    need no access to `cmMakefile` class members.  They are used only
    within the implementation file.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 53f0a3d..33e76b2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1130,57 +1130,38 @@ cmTarget* cmMakefile::AddUtilityCommand(
   return target;
 }
 
-void cmMakefile::AddDefineFlag(std::string const& flag)
-{
-  if (flag.empty()) {
-    return;
-  }
-
-  // Update the string used for the old DEFINITIONS property.
-  this->AddDefineFlag(flag, this->DefineFlagsOrig);
-
-  // If this is really a definition, update COMPILE_DEFINITIONS.
-  if (this->ParseDefineFlag(flag, false)) {
-    return;
-  }
-
-  // Add this flag that does not look like a definition.
-  this->AddDefineFlag(flag, this->DefineFlags);
-}
-
-void cmMakefile::AddDefineFlag(std::string const& flag, std::string& dflags)
+static void s_AddDefineFlag(std::string const& flag, std::string& dflags)
 {
   // remove any \n\r
   std::string::size_type initSize = dflags.size();
-  dflags += std::string(" ") + flag;
+  dflags += ' ';
+  dflags += flag;
   std::string::iterator flagStart = dflags.begin() + initSize + 1;
   std::replace(flagStart, dflags.end(), '\n', ' ');
   std::replace(flagStart, dflags.end(), '\r', ' ');
 }
 
-void cmMakefile::RemoveDefineFlag(std::string const& flag)
+void cmMakefile::AddDefineFlag(std::string const& flag)
 {
-  // Check the length of the flag to remove.
   if (flag.empty()) {
     return;
   }
-  std::string::size_type const len = flag.length();
+
   // Update the string used for the old DEFINITIONS property.
-  this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
+  s_AddDefineFlag(flag, this->DefineFlagsOrig);
 
   // If this is really a definition, update COMPILE_DEFINITIONS.
-  if (this->ParseDefineFlag(flag, true)) {
+  if (this->ParseDefineFlag(flag, false)) {
     return;
   }
 
-  // Remove this flag that does not look like a definition.
-  this->RemoveDefineFlag(flag, len, this->DefineFlags);
+  // Add this flag that does not look like a definition.
+  s_AddDefineFlag(flag, this->DefineFlags);
 }
 
-void cmMakefile::RemoveDefineFlag(std::string const& flag,
-                                  std::string::size_type len,
-                                  std::string& dflags)
+static void s_RemoveDefineFlag(std::string const& flag, std::string& dflags)
 {
+  std::string::size_type const len = flag.length();
   // Remove all instances of the flag that are surrounded by
   // whitespace or the beginning/end of the string.
   for (std::string::size_type lpos = dflags.find(flag, 0);
@@ -1195,6 +1176,25 @@ void cmMakefile::RemoveDefineFlag(std::string const& flag,
   }
 }
 
+void cmMakefile::RemoveDefineFlag(std::string const& flag)
+{
+  // Check the length of the flag to remove.
+  if (flag.empty()) {
+    return;
+  }
+
+  // Update the string used for the old DEFINITIONS property.
+  s_RemoveDefineFlag(flag, this->DefineFlagsOrig);
+
+  // If this is really a definition, update COMPILE_DEFINITIONS.
+  if (this->ParseDefineFlag(flag, true)) {
+    return;
+  }
+
+  // Remove this flag that does not look like a definition.
+  s_RemoveDefineFlag(flag, this->DefineFlags);
+}
+
 void cmMakefile::AddCompileDefinition(std::string const& option)
 {
   this->AppendProperty("COMPILE_DEFINITIONS", option.c_str());
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 7a688b3..9f32c4f 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -885,9 +885,6 @@ protected:
   std::string DefineFlags;
 
   // Track the value of the computed DEFINITIONS property.
-  void AddDefineFlag(std::string const& flag, std::string&);
-  void RemoveDefineFlag(std::string const& flag, std::string::size_type,
-                        std::string&);
   std::string DefineFlagsOrig;
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e13fa223fc870ea95c6a1cfa09b61b527a1c2db5
commit e13fa223fc870ea95c6a1cfa09b61b527a1c2db5
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Fri Apr 27 11:28:30 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue May 1 10:24:31 2018 -0400

    cmMakefile: Improve ExpandVariablesInString return type
    
    Return `std::string const&` instead of a `const char*` that points
    into a string anyway.  Update call sites accordingly.

diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index e6d7f8f..8e7e3ad 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -405,7 +405,8 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source,
 {
   cmMakefile* mf = static_cast<cmMakefile*>(arg);
   std::string barf = source;
-  std::string result = mf->ExpandVariablesInString(barf, escapeQuotes, atOnly);
+  std::string const& result =
+    mf->ExpandVariablesInString(barf, escapeQuotes, atOnly);
   return strdup(result.c_str());
 }
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index b6bf08b..53f0a3d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2412,12 +2412,13 @@ std::vector<std::string> cmMakefile::GetDefinitions() const
   return res;
 }
 
-const char* cmMakefile::ExpandVariablesInString(std::string& source) const
+const std::string& cmMakefile::ExpandVariablesInString(
+  std::string& source) const
 {
   return this->ExpandVariablesInString(source, false, false);
 }
 
-const char* cmMakefile::ExpandVariablesInString(
+const std::string& cmMakefile::ExpandVariablesInString(
   std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly,
   const char* filename, long line, bool removeEmpty, bool replaceAt) const
 {
@@ -2433,7 +2434,7 @@ const char* cmMakefile::ExpandVariablesInString(
     this->IssueMessage(cmake::INTERNAL_ERROR,
                        "ExpandVariablesInString @ONLY called "
                        "on something with escapes.");
-    return source.c_str();
+    return source;
   }
 
   // Variables used in the WARN case.
@@ -2515,7 +2516,7 @@ const char* cmMakefile::ExpandVariablesInString(
     this->IssueMessage(cmake::AUTHOR_WARNING, msg);
   }
 
-  return source.c_str();
+  return source;
 }
 
 cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 16b2047..7a688b3 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -565,12 +565,11 @@ public:
    * entry in the this->Definitions map.  Also \@var\@ is
    * expanded to match autoconf style expansions.
    */
-  const char* ExpandVariablesInString(std::string& source) const;
-  const char* ExpandVariablesInString(std::string& source, bool escapeQuotes,
-                                      bool noEscapes, bool atOnly = false,
-                                      const char* filename = nullptr,
-                                      long line = -1, bool removeEmpty = false,
-                                      bool replaceAt = false) const;
+  const std::string& ExpandVariablesInString(std::string& source) const;
+  const std::string& ExpandVariablesInString(
+    std::string& source, bool escapeQuotes, bool noEscapes,
+    bool atOnly = false, const char* filename = nullptr, long line = -1,
+    bool removeEmpty = false, bool replaceAt = false) const;
 
   /**
    * Remove any remaining variables in the string. Anything with ${var} or

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b542e0c74f543954ba26048ce38776269b9ba203
commit b542e0c74f543954ba26048ce38776269b9ba203
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Mon Apr 30 10:25:34 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue May 1 10:21:53 2018 -0400

    cmCPluginAPI: Remove a few unnecessary c_str() calls

diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 1ec76ac..e6d7f8f 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -664,7 +664,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
   // First try and see whether the listed file can be found
   // as is without extensions added on.
   std::string hname = pathname;
-  if (cmSystemTools::FileExists(hname.c_str())) {
+  if (cmSystemTools::FileExists(hname)) {
     sf->SourceName = cmSystemTools::GetFilenamePath(name);
     if (!sf->SourceName.empty()) {
       sf->SourceName += "/";
@@ -691,7 +691,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
     hname = pathname;
     hname += ".";
     hname += *ext;
-    if (cmSystemTools::FileExists(hname.c_str())) {
+    if (cmSystemTools::FileExists(hname)) {
       sf->SourceExtension = *ext;
       sf->FullPath = hname;
       return;
@@ -704,7 +704,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
     hname = pathname;
     hname += ".";
     hname += *ext;
-    if (cmSystemTools::FileExists(hname.c_str())) {
+    if (cmSystemTools::FileExists(hname)) {
       sf->SourceExtension = *ext;
       sf->FullPath = hname;
       return;

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

Summary of changes:
 Source/cmCPluginAPI.cxx |    9 ++++---
 Source/cmMakefile.cxx   |   69 ++++++++++++++++++++++++-----------------------
 Source/cmMakefile.h     |   14 ++++------
 3 files changed, 45 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list