BUG: Fix windows command line escape for empty arg

On Windows the KWSys System package generates escapes for command-line
arguments.  This fix enables quoting of the empty string as an argument.
This also adds a test to pass an empty argument to a custom command.
This commit is contained in:
Brad King 2008-12-18 13:36:58 -05:00
parent adb6bf82b0
commit 0a83aa6f57
2 changed files with 9 additions and 3 deletions

View File

@ -170,6 +170,12 @@ flag later when we understand applications of this better.
static int kwsysSystem_Shell__ArgumentNeedsQuotes(const char* in, int isUnix, static int kwsysSystem_Shell__ArgumentNeedsQuotes(const char* in, int isUnix,
int flags) int flags)
{ {
/* The empty string needs quotes. */
if(!*in)
{
return 1;
}
/* Scan the string for characters that require quoting. */ /* Scan the string for characters that require quoting. */
{ {
const char* c; const char* c;

View File

@ -346,7 +346,7 @@ ENDIF(NOT MINGW)
# | < > << >> &> 2>&1 1>&2 # | < > << >> &> 2>&1 1>&2
# to allow custom commands to perform redirection. # to allow custom commands to perform redirection.
FOREACH(arg ${CHECK_ARGS}) FOREACH(arg ${CHECK_ARGS} "")
SET(ARG "${arg}") SET(ARG "${arg}")
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}") STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
STRING(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}") STRING(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}")
@ -367,7 +367,7 @@ ADD_CUSTOM_COMMAND(
COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line
${CHECK_ARGS} ${CHECK_ARGS} ""
VERBATIM VERBATIM
COMMENT "Checking custom command line escapes (single'quote)" COMMENT "Checking custom command line escapes (single'quote)"
) )
@ -377,7 +377,7 @@ ADD_CUSTOM_TARGET(do_check_command_line ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check
COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes"
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line
${CHECK_ARGS} ${CHECK_ARGS} ""
VERBATIM VERBATIM
COMMENT "Checking custom target command line escapes ($dollar-signs$)" COMMENT "Checking custom target command line escapes ($dollar-signs$)"
) )