[Cmake-commits] CMake branch, master, updated. v3.9.2-806-g0865a24

Kitware Robot kwrobot at kitware.com
Thu Sep 14 07:45:09 EDT 2017


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  0865a24fc1c47d75f1381659ba398e6944c9a724 (commit)
       via  01b9d039e71aaaf69cf23330fc4129e888e40ea0 (commit)
       via  9c7bf6974f7e50e795e0ca960834909e14cdd7a0 (commit)
       via  5202075c66c242e00fc0da118b63428009d1947e (commit)
       via  208ac575312717223bfc61f57072ff61db790b86 (commit)
       via  badc892ff8ea48b499694bc1dc94b5bac272531b (commit)
       via  31f73eb12dd0888efc61c0333539d1354c7268ce (commit)
       via  f95dceccb5ccb1ba3ce54173dc4a0b7fdc4144a3 (commit)
       via  a3deae71990e0fd6b495bb3e925755cdbcaf89eb (commit)
       via  9f66fe9a01451cb5a6e883b05dbc05d6c6c6f4f7 (commit)
       via  64e973e991636f296cb2bf4f3c0e4ec26463a7b1 (commit)
       via  c5b5bb270f54dab4ff529688a26ea8aa271fa0e1 (commit)
       via  c2cc91a4a549346d5d8a76a5c4ac497e28b4bd3b (commit)
      from  fda9a94fe6061908e1d66c111f9030baa62cccf7 (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=0865a24fc1c47d75f1381659ba398e6944c9a724
commit 0865a24fc1c47d75f1381659ba398e6944c9a724
Merge: 01b9d03 badc892
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 14 07:41:02 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Sep 14 07:41:02 2017 -0400

    Merge branch 'release-3.9'


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=01b9d039e71aaaf69cf23330fc4129e888e40ea0
commit 01b9d039e71aaaf69cf23330fc4129e888e40ea0
Merge: 9c7bf69 31f73eb
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 14 11:39:08 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Sep 14 07:39:24 2017 -0400

    Merge topic 'get_filename_component-fix-program-split'
    
    31f73eb1 get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1251


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c7bf6974f7e50e795e0ca960834909e14cdd7a0
commit 9c7bf6974f7e50e795e0ca960834909e14cdd7a0
Merge: 5202075 c2cc91a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 14 11:38:08 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Sep 14 07:38:29 2017 -0400

    Merge topic 'remove-nmcl'
    
    c2cc91a4 Platforms: Remove Windows-NMcl
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1255


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5202075c66c242e00fc0da118b63428009d1947e
commit 5202075c66c242e00fc0da118b63428009d1947e
Merge: 208ac57 a3deae7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 14 11:37:30 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Sep 14 07:37:58 2017 -0400

    Merge topic 'bootstrap-twice-in-source'
    
    a3deae71 bootstrap: Fix running multiple times in-source
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1258


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=208ac575312717223bfc61f57072ff61db790b86
commit 208ac575312717223bfc61f57072ff61db790b86
Merge: fda9a94 64e973e
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 14 11:37:05 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Sep 14 07:37:16 2017 -0400

    Merge topic 'vs-fix-config-map'
    
    64e973e9 Merge branch 'backport-vs-fix-config-map' into vs-fix-config-map
    c5b5bb27 VS: Do not consider MAP_IMPORTED_CONFIG_<CONFIG> on non-imported targets
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1256


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=31f73eb12dd0888efc61c0333539d1354c7268ce
commit 31f73eb12dd0888efc61c0333539d1354c7268ce
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Sep 11 11:05:20 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Sep 13 10:47:04 2017 -0400

    get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics
    
    The KWSys `SystemTools::SplitProgramFromArgs` implementation goes into
    an infinite loop when the value is just " " (a space).  Since the
    "program path with unquoted spaces plus command-line arguments"
    operation it is trying to provide is poorly defined (string parsing
    should not depend on filesystem content), just stop using it.
    
    Instead consider the main two use cases the old approach tried to handle:
    
    * The value is the name or absolute path of a program with no quoting
      or escaping, but also no command-line arguments.  In this case we
      can use the value as given with no parsing, and assume no arguments.
    
    * The value is a command-line string containing the program name/path
      plus arguments.  In this case we now assume that the command line
      is properly quoted or escaped.
    
    Fixes: #17262

diff --git a/Help/release/dev/get_filename_component-fix-program-split.rst b/Help/release/dev/get_filename_component-fix-program-split.rst
new file mode 100644
index 0000000..55c8719
--- /dev/null
+++ b/Help/release/dev/get_filename_component-fix-program-split.rst
@@ -0,0 +1,9 @@
+get_filename_component-fix-program-split
+----------------------------------------
+
+* The :command:`get_filename_component` ``PROGRAM`` mode semantics
+  have been revised to not tolerate unquoted spaces in the path
+  to the program while also accepting arguments.  While technically
+  incompatible with the old behavior, it is expected that behavior
+  under typical use cases with properly-quoted command-lines has
+  not changed.
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index c23684c..1b358ab 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -60,7 +60,30 @@ bool cmGetFilenameComponentCommand::InitialPass(
         }
       }
     }
-    cmSystemTools::SplitProgramFromArgs(filename, result, programArgs);
+
+    // First assume the path to the program was specified with no
+    // arguments and with no quoting or escaping for spaces.
+    // Only bother doing this if there is non-whitespace.
+    if (!cmSystemTools::TrimWhitespace(filename).empty()) {
+      result = cmSystemTools::FindProgram(filename);
+    }
+
+    // If that failed then assume a command-line string was given
+    // and split the program part from the rest of the arguments.
+    if (result.empty()) {
+      std::string program;
+      if (cmSystemTools::SplitProgramFromArgs(filename, program,
+                                              programArgs)) {
+        if (cmSystemTools::FileExists(program)) {
+          result = program;
+        } else {
+          result = cmSystemTools::FindProgram(program);
+        }
+      }
+      if (result.empty()) {
+        programArgs.clear();
+      }
+    }
   } else if (args[2] == "EXT") {
     result = cmSystemTools::GetFilenameExtension(filename);
   } else if (args[2] == "NAME_WE") {
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5c63d98..2635d6d 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -603,6 +603,56 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
   return args;
 }
 
+bool cmSystemTools::SplitProgramFromArgs(std::string const& command,
+                                         std::string& program,
+                                         std::string& args)
+{
+  const char* c = command.c_str();
+
+  // Skip leading whitespace.
+  while (isspace(static_cast<unsigned char>(*c))) {
+    ++c;
+  }
+
+  // Parse one command-line element up to an unquoted space.
+  bool in_escape = false;
+  bool in_double = false;
+  bool in_single = false;
+  for (; *c; ++c) {
+    if (in_single) {
+      if (*c == '\'') {
+        in_single = false;
+      } else {
+        program += *c;
+      }
+    } else if (in_escape) {
+      in_escape = false;
+      program += *c;
+    } else if (*c == '\\') {
+      in_escape = true;
+    } else if (in_double) {
+      if (*c == '"') {
+        in_double = false;
+      } else {
+        program += *c;
+      }
+    } else if (*c == '"') {
+      in_double = true;
+    } else if (*c == '\'') {
+      in_single = true;
+    } else if (isspace(static_cast<unsigned char>(*c))) {
+      break;
+    } else {
+      program += *c;
+    }
+  }
+
+  // The remainder of the command line holds unparsed arguments.
+  args = c;
+
+  return !in_single && !in_escape && !in_double;
+}
+
 size_t cmSystemTools::CalculateCommandLineLengthLimit()
 {
   size_t sz =
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 9bec361..e7082e6 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -255,6 +255,11 @@ public:
   static void ParseUnixCommandLine(const char* command,
                                    std::vector<std::string>& args);
 
+  /** Split a command-line string into the parsed command and the unparsed
+      arguments.  Returns false on unfinished quoting or escaping.  */
+  static bool SplitProgramFromArgs(std::string const& command,
+                                   std::string& program, std::string& args);
+
   /**
    * Handle response file in an argument list and return a new argument list
    * **/
diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 7dfb55d..ac77ac3 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -80,6 +80,17 @@ get_filename_component(test_program_name "/ arg1 arg2" PROGRAM
 check("PROGRAM with args output: name" "${test_program_name}" "/")
 check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2")
 
+get_filename_component(test_program_name " " PROGRAM)
+check("PROGRAM with just a space" "${test_program_name}" "")
+
+get_filename_component(test_program_name "${CMAKE_CURRENT_LIST_FILE}" PROGRAM)
+check("PROGRAM specified explicitly without quoting" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+
+get_filename_component(test_program_name "\"${CMAKE_CURRENT_LIST_FILE}\" arg1 arg2" PROGRAM
+  PROGRAM_ARGS test_program_args)
+check("PROGRAM specified explicitly with arguments: name" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+check("PROGRAM specified explicitly with arguments: args" "${test_program_args}" " arg1 arg2")
+
 list(APPEND non_cache_vars test_program_name)
 list(APPEND non_cache_vars test_program_args)
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64e973e991636f296cb2bf4f3c0e4ec26463a7b1
commit 64e973e991636f296cb2bf4f3c0e4ec26463a7b1
Merge: 420874b c5b5bb2
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 13 09:43:24 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Sep 13 09:43:24 2017 -0400

    Merge branch 'backport-vs-fix-config-map' into vs-fix-config-map


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2cc91a4a549346d5d8a76a5c4ac497e28b4bd3b
commit c2cc91a4a549346d5d8a76a5c4ac497e28b4bd3b
Author:     Christian Pfeiffer <cpfeiffer at live.de>
AuthorDate: Wed Sep 13 14:41:39 2017 +0200
Commit:     Christian Pfeiffer <cpfeiffer at live.de>
CommitDate: Wed Sep 13 14:52:45 2017 +0200

    Platforms: Remove Windows-NMcl
    
    Since commit v2.8.10~148^2~2 (Modernize MSVC compiler information files,
    2012-08-23), the Windows-NMcl platform has been broken.
    It's most likely not needed anymore.

diff --git a/Modules/Platform/Windows-NMcl.cmake b/Modules/Platform/Windows-NMcl.cmake
deleted file mode 100644
index 7add0b0..0000000
--- a/Modules/Platform/Windows-NMcl.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-# this is for the numega compiler which is really a front
-# end for visual studio, but adds memory checking code.
-
-include(Platform/Windows-cl)

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

Summary of changes:
 .../get_filename_component-fix-program-split.rst   |    9 ++++
 Modules/Platform/Windows-NMcl.cmake                |    4 --
 Source/cmGetFilenameComponentCommand.cxx           |   25 +++++++++-
 Source/cmGlobalVisualStudio71Generator.cxx         |   14 ++++--
 Source/cmGlobalVisualStudio8Generator.cxx          |   14 ++++--
 Source/cmSystemTools.cxx                           |   50 ++++++++++++++++++++
 Source/cmSystemTools.h                             |    5 ++
 .../get_filename_component/KnownComponents.cmake   |   11 +++++
 bootstrap                                          |    6 +++
 9 files changed, 125 insertions(+), 13 deletions(-)
 create mode 100644 Help/release/dev/get_filename_component-fix-program-split.rst
 delete mode 100644 Modules/Platform/Windows-NMcl.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list