cmOutputConverter: Adopt EscapeWindowsShellArgument method

Move it out of cmSystemTools and into cmOutputConverter.
This commit is contained in:
Brad King 2015-07-07 14:31:46 -04:00
parent cedd6e65d2
commit bb7eefe4dd
5 changed files with 27 additions and 25 deletions

View File

@ -411,6 +411,26 @@ std::string cmOutputConverter::EscapeForCMake(const std::string& str)
return result; return result;
} }
//----------------------------------------------------------------------------
std::string
cmOutputConverter::EscapeWindowsShellArgument(const char* arg, int shell_flags)
{
char local_buffer[1024];
char* buffer = local_buffer;
int size = cmsysSystem_Shell_GetArgumentSizeForWindows(arg, shell_flags);
if(size > 1024)
{
buffer = new char[size];
}
cmsysSystem_Shell_GetArgumentForWindows(arg, buffer, shell_flags);
std::string result(buffer);
if(buffer != local_buffer)
{
delete [] buffer;
}
return result;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmOutputConverter::FortranFormat cmOutputConverter::FortranFormat
cmOutputConverter::GetFortranFormat(const char* value) cmOutputConverter::GetFortranFormat(const char* value)

View File

@ -71,6 +71,11 @@ public:
static std::string EscapeForCMake(const std::string& str); static std::string EscapeForCMake(const std::string& str);
/** Compute an escaped version of the given argument for use in a
windows shell. */
static std::string EscapeWindowsShellArgument(const char* arg,
int shell_flags);
enum FortranFormat enum FortranFormat
{ {
FortranFormatNone, FortranFormatNone,

View File

@ -556,25 +556,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command,
argv.Store(args); argv.Store(args);
} }
std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
int shell_flags)
{
char local_buffer[1024];
char* buffer = local_buffer;
int size = cmsysSystem_Shell_GetArgumentSizeForWindows(arg, shell_flags);
if(size > 1024)
{
buffer = new char[size];
}
cmsysSystem_Shell_GetArgumentForWindows(arg, buffer, shell_flags);
std::string result(buffer);
if(buffer != local_buffer)
{
delete [] buffer;
}
return result;
}
std::vector<std::string> cmSystemTools::ParseArguments(const char* command) std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
{ {
std::vector<std::string> args; std::vector<std::string> args;

View File

@ -256,11 +256,6 @@ public:
static void ParseUnixCommandLine(const char* command, static void ParseUnixCommandLine(const char* command,
std::vector<std::string>& args); 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. */
static std::string EscapeWindowsShellArgument(const char* arg,
int shell_flags);
static void EnableMessages() { s_DisableMessages = false; } static void EnableMessages() { s_DisableMessages = false; }
static void DisableMessages() { s_DisableMessages = true; } static void DisableMessages() { s_DisableMessages = true; }
static void DisableRunCommandOutput() {s_DisableRunCommandOutput = true; } static void DisableRunCommandOutput() {s_DisableRunCommandOutput = true; }

View File

@ -1,4 +1,5 @@
#include "cmVisualStudioGeneratorOptions.h" #include "cmVisualStudioGeneratorOptions.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <cmsys/System.h> #include <cmsys/System.h>
#include "cmVisualStudio10TargetGenerator.h" #include "cmVisualStudio10TargetGenerator.h"
@ -246,7 +247,7 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
// This option is not known. Store it in the output flags. // This option is not known. Store it in the output flags.
this->FlagString += " "; this->FlagString += " ";
this->FlagString += this->FlagString +=
cmSystemTools::EscapeWindowsShellArgument( cmOutputConverter::EscapeWindowsShellArgument(
flag, flag,
cmsysSystem_Shell_Flag_AllowMakeVariables | cmsysSystem_Shell_Flag_AllowMakeVariables |
cmsysSystem_Shell_Flag_VSIDE); cmsysSystem_Shell_Flag_VSIDE);