Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
fd93b360
Commit
fd93b360
authored
Oct 04, 2016
by
Stephen Kelly
Browse files
cmOutputConverter: Add a flag for IsUnix
Remove the need for method parameters to represent the distinction.
parent
1365e18b
Pipeline
#29735
passed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Source/cmOutputConverter.cxx
View file @
fd93b360
...
...
@@ -239,9 +239,11 @@ std::string cmOutputConverter::EscapeForShell(const std::string& str,
if
(
this
->
GetState
()
->
UseNMake
())
{
flags
|=
Shell_Flag_NMake
;
}
if
(
!
this
->
GetState
()
->
UseWindowsShell
())
{
flags
|=
Shell_Flag_IsUnix
;
}
return
Shell__GetArgument
(
str
.
c_str
(),
!
this
->
GetState
()
->
UseWindowsShell
(),
flags
);
return
Shell__GetArgument
(
str
.
c_str
(),
flags
);
}
std
::
string
cmOutputConverter
::
EscapeForCMake
(
const
std
::
string
&
str
)
...
...
@@ -270,7 +272,7 @@ std::string cmOutputConverter::EscapeForCMake(const std::string& str)
std
::
string
cmOutputConverter
::
EscapeWindowsShellArgument
(
const
char
*
arg
,
int
shell_flags
)
{
return
Shell__GetArgument
(
arg
,
0
,
shell_flags
);
return
Shell__GetArgument
(
arg
,
shell_flags
);
}
cmOutputConverter
::
FortranFormat
cmOutputConverter
::
GetFortranFormat
(
...
...
@@ -356,10 +358,10 @@ int cmOutputConverter::Shell__CharNeedsQuotesOnWindows(char c)
(
c
==
'>'
)
||
(
c
==
'|'
)
||
(
c
==
'^'
));
}
int
cmOutputConverter
::
Shell__CharNeedsQuotes
(
char
c
,
int
isUnix
,
int
flags
)
int
cmOutputConverter
::
Shell__CharNeedsQuotes
(
char
c
,
int
flags
)
{
/* On Windows the built-in command shell echo never needs quotes. */
if
(
!
i
sUnix
&&
(
flags
&
Shell_Flag_EchoWindows
))
{
if
(
!
(
flags
&
Shell_Flag_I
sUnix
)
&&
(
flags
&
Shell_Flag_EchoWindows
))
{
return
0
;
}
...
...
@@ -368,7 +370,7 @@ int cmOutputConverter::Shell__CharNeedsQuotes(char c, int isUnix, int flags)
return
1
;
}
if
(
i
sUnix
)
{
if
(
flags
&
Shell_Flag_I
sUnix
)
{
/* On UNIX several special characters need quotes to preserve them. */
if
(
Shell__CharNeedsQuotesOnUnix
(
c
))
{
return
1
;
...
...
@@ -426,8 +428,7 @@ flag later when we understand applications of this better.
*/
#define KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES 0
int
cmOutputConverter
::
Shell__ArgumentNeedsQuotes
(
const
char
*
in
,
int
isUnix
,
int
flags
)
int
cmOutputConverter
::
Shell__ArgumentNeedsQuotes
(
const
char
*
in
,
int
flags
)
{
/* The empty string needs quotes. */
if
(
!*
in
)
{
...
...
@@ -459,14 +460,14 @@ int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix,
}
/* Check whether this character needs quotes. */
if
(
Shell__CharNeedsQuotes
(
*
c
,
isUnix
,
flags
))
{
if
(
Shell__CharNeedsQuotes
(
*
c
,
flags
))
{
return
1
;
}
}
}
/* On Windows some single character arguments need quotes. */
if
(
!
i
sUnix
&&
*
in
&&
!*
(
in
+
1
))
{
if
(
flags
&
Shell_Flag_I
sUnix
&&
*
in
&&
!*
(
in
+
1
))
{
char
c
=
*
in
;
if
((
c
==
'?'
)
||
(
c
==
'&'
)
||
(
c
==
'^'
)
||
(
c
==
'|'
)
||
(
c
==
'#'
))
{
return
1
;
...
...
@@ -476,8 +477,7 @@ int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix,
return
0
;
}
std
::
string
cmOutputConverter
::
Shell__GetArgument
(
const
char
*
in
,
int
isUnix
,
int
flags
)
std
::
string
cmOutputConverter
::
Shell__GetArgument
(
const
char
*
in
,
int
flags
)
{
std
::
ostringstream
out
;
...
...
@@ -488,11 +488,11 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix,
int
windows_backslashes
=
0
;
/* Whether the argument must be quoted. */
int
needQuotes
=
Shell__ArgumentNeedsQuotes
(
in
,
isUnix
,
flags
);
int
needQuotes
=
Shell__ArgumentNeedsQuotes
(
in
,
flags
);
if
(
needQuotes
)
{
/* Add the opening quote for this argument. */
if
(
flags
&
Shell_Flag_WatcomQuote
)
{
if
(
i
sUnix
)
{
if
(
flags
&
Shell_Flag_I
sUnix
)
{
out
<<
'"'
;
}
out
<<
'\''
;
...
...
@@ -524,7 +524,7 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix,
}
/* Check whether this character needs escaping for the shell. */
if
(
i
sUnix
)
{
if
(
flags
&
Shell_Flag_I
sUnix
)
{
/* On Unix a few special characters need escaping even inside a
quoted argument. */
if
(
*
c
==
'\\'
||
*
c
==
'"'
||
*
c
==
'`'
||
*
c
==
'$'
)
{
...
...
@@ -621,7 +621,7 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix,
/* Add the closing quote for this argument. */
if
(
flags
&
Shell_Flag_WatcomQuote
)
{
out
<<
'\''
;
if
(
i
sUnix
)
{
if
(
flags
&
Shell_Flag_I
sUnix
)
{
out
<<
'"'
;
}
}
else
{
...
...
Source/cmOutputConverter.h
View file @
fd93b360
...
...
@@ -66,7 +66,9 @@ public:
Shell_Flag_AllowMakeVariables
=
(
1
<<
6
),
/** The target shell quoting uses extra single Quotes for Watcom tools. */
Shell_Flag_WatcomQuote
=
(
1
<<
7
)
Shell_Flag_WatcomQuote
=
(
1
<<
7
),
Shell_Flag_IsUnix
=
(
1
<<
8
)
};
std
::
string
EscapeForShell
(
const
std
::
string
&
str
,
bool
makeVars
=
false
,
...
...
@@ -116,11 +118,11 @@ private:
static
int
Shell__CharIsWhitespace
(
char
c
);
static
int
Shell__CharNeedsQuotesOnUnix
(
char
c
);
static
int
Shell__CharNeedsQuotesOnWindows
(
char
c
);
static
int
Shell__CharNeedsQuotes
(
char
c
,
int
isUnix
,
int
flags
);
static
int
Shell__CharNeedsQuotes
(
char
c
,
int
flags
);
static
int
Shell__CharIsMakeVariableName
(
char
c
);
static
const
char
*
Shell__SkipMakeVariables
(
const
char
*
c
);
static
int
Shell__ArgumentNeedsQuotes
(
const
char
*
in
,
int
isUnix
,
int
flags
);
static
std
::
string
Shell__GetArgument
(
const
char
*
in
,
int
isUnix
,
int
flags
);
static
int
Shell__ArgumentNeedsQuotes
(
const
char
*
in
,
int
flags
);
static
std
::
string
Shell__GetArgument
(
const
char
*
in
,
int
flags
);
private:
cmState
::
Snapshot
StateSnapshot
;
...
...
Brad King
@brad.king
Mentioned in commit
9c4d1056
·
Oct 07, 2016
Mentioned in commit
9c4d1056
Mentioned in commit 9c4d105680c99e194c6d6063315ee2affd2a7b63
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment