[Cmake-commits] [cmake-commits] king committed cmSystemTools.cxx 1.397 1.398 cmSystemTools.h 1.161 1.162

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jul 13 16:22:50 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv5676/Source

Modified Files:
	cmSystemTools.cxx cmSystemTools.h 
Log Message:
ENH: Add cmSystemTools::ParseUnixCommandLine

This method is a C++ wrapper around the KWSys System library function to
parse unix-style command lines.


Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.161
retrieving revision 1.162
diff -C 2 -d -r1.161 -r1.162
*** cmSystemTools.h	24 Jun 2009 19:09:50 -0000	1.161
--- cmSystemTools.h	13 Jul 2009 20:22:48 -0000	1.162
***************
*** 240,243 ****
--- 240,247 ----
                                        std::vector<std::string>& args);
  
+   /** Parse arguments out of a unix command line string.  */
+   static void ParseUnixCommandLine(const char* command,
+                                    std::vector<std::string>& args);
+ 
    /** Compute an escaped version of the given argument for use in a
        windows shell.  See kwsys/System.h.in for details.  */

Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.397
retrieving revision 1.398
diff -C 2 -d -r1.397 -r1.398
*** cmSystemTools.cxx	24 Jun 2009 19:09:50 -0000	1.397
--- cmSystemTools.cxx	13 Jul 2009 20:22:48 -0000	1.398
***************
*** 449,452 ****
--- 449,484 ----
  }
  
+ //----------------------------------------------------------------------------
+ class cmSystemToolsArgV
+ {
+   char** ArgV;
+ public:
+   cmSystemToolsArgV(char** argv): ArgV(argv) {}
+   ~cmSystemToolsArgV()
+     {
+     for(char** arg = this->ArgV; arg && *arg; ++arg)
+       {
+       free(*arg);
+       }
+     free(this->ArgV);
+     }
+   void Store(std::vector<std::string>& args) const
+     {
+     for(char** arg = this->ArgV; arg && *arg; ++arg)
+       {
+       args.push_back(*arg);
+       }
+     }
+ };
+ 
+ //----------------------------------------------------------------------------
+ void cmSystemTools::ParseUnixCommandLine(const char* command,
+                                          std::vector<std::string>& args)
+ {
+   // Invoke the underlying parser.
+   cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0);
+   argv.Store(args);
+ }
+ 
  std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
                                                        int shell_flags)



More information about the Cmake-commits mailing list