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
Brad King
CMake
Commits
802a28fc
Commit
802a28fc
authored
Dec 30, 2013
by
Stephen Kelly
Browse files
Add cmHasLiteralSuffix API.
parent
dc081998
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/cmFindPackageCommand.cxx
View file @
802a28fc
...
...
@@ -1151,8 +1151,8 @@ void cmFindPackageCommand::AddPrefixesSystemEnvironment()
std
::
string
const
&
d
=
*
i
;
// If the path is a PREFIX/bin case then add its parent instead.
if
((
d
.
size
()
>=
4
&&
strcmp
(
d
.
c_str
()
+
d
.
size
()
-
4
,
"/bin"
)
==
0
)
||
(
d
.
size
()
>=
5
&&
strcmp
(
d
.
c_str
()
+
d
.
size
()
-
5
,
"/sbin"
)
==
0
))
if
((
cmHasLiteralSuffix
(
d
,
"/bin"
))
||
(
cmHasLiteralSuffix
(
d
,
"/sbin"
)))
{
this
->
AddPathInternal
(
cmSystemTools
::
GetFilenamePath
(
d
),
EnvPath
);
}
...
...
Source/cmStandardIncludes.h
View file @
802a28fc
...
...
@@ -391,6 +391,22 @@ inline bool cmHasLiteralPrefixImpl(const char* str1,
return
strncmp
(
str1
,
str2
,
N
)
==
0
;
}
inline
bool
cmHasLiteralSuffixImpl
(
const
std
::
string
&
str1
,
const
char
*
str2
,
size_t
N
)
{
size_t
len
=
str1
.
size
();
return
len
>=
N
&&
strcmp
(
str1
.
c_str
()
+
len
-
N
,
str2
)
==
0
;
}
inline
bool
cmHasLiteralSuffixImpl
(
const
char
*
str1
,
const
char
*
str2
,
size_t
N
)
{
size_t
len
=
strlen
(
str1
);
return
len
>=
N
&&
strcmp
(
str1
+
len
-
N
,
str2
)
==
0
;
}
#if defined(_MSC_VER) && _MSC_VER < 1300 \
|| defined(__GNUC__) && __GNUC__ < 3 \
|| defined(__BORLANDC__)
...
...
@@ -402,6 +418,9 @@ inline bool cmHasLiteralPrefixImpl(const char* str1,
#define cmHasLiteralPrefix(STR1, STR2) \
cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1)
#define cmHasLiteralSuffix(STR1, STR2) \
cmHasLiteralSuffixImpl(STR1, "" STR2 "", sizeof(STR2) - 1)
#else
template
<
typename
T
,
size_t
N
>
...
...
@@ -417,6 +436,12 @@ bool cmHasLiteralPrefix(T str1, const char (&str2)[N])
return
cmHasLiteralPrefixImpl
(
str1
,
str2
,
N
-
1
);
}
template
<
typename
T
,
size_t
N
>
bool
cmHasLiteralSuffix
(
T
str1
,
const
char
(
&
str2
)[
N
])
{
return
cmHasLiteralSuffixImpl
(
str1
,
str2
,
N
-
1
);
}
#endif
struct
cmStrCmp
{
...
...
Source/cmSystemTools.cxx
View file @
802a28fc
...
...
@@ -359,18 +359,11 @@ bool cmSystemTools::IsOn(const char* val)
bool
cmSystemTools
::
IsNOTFOUND
(
const
char
*
val
)
{
size_t
len
=
strlen
(
val
);
const
char
*
notfound
=
"-NOTFOUND"
;
const
size_t
lenNotFound
=
9
;
if
(
len
<
lenNotFound
-
1
)
if
(
strcmp
(
val
,
"NOTFOUND"
)
==
0
)
{
return
false
;
}
if
(
len
==
lenNotFound
-
1
)
{
return
(
strcmp
(
val
,
"NOTFOUND"
)
==
0
);
return
true
;
}
return
((
strncmp
((
val
+
(
len
-
lenNotFound
)),
notfound
,
lenNotFound
)
==
0
)
);
return
cmHasLiteralSuffix
(
val
,
"-NOTFOUND"
);
}
...
...
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