Added compare_string().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4184 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
84ba3a5265
commit
a7ef3b5651
@ -55,6 +55,30 @@ set_string(char *&location, const char *newValue)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compare_string
|
||||||
|
/*! \brief \c NULL aware strcmp().
|
||||||
|
|
||||||
|
\c NULL is considered the least of all strings. \c NULL equals \c NULL.
|
||||||
|
|
||||||
|
\param str1 First string.
|
||||||
|
\param str2 Second string.
|
||||||
|
\return A value less than 0, if \a str1 is less than \a str2,
|
||||||
|
0, if they are equal, or a value greater than 0, if
|
||||||
|
\a str1 is greater \a str2.
|
||||||
|
*/
|
||||||
|
static inline
|
||||||
|
int
|
||||||
|
compare_string(const char *str1, const char *str2)
|
||||||
|
{
|
||||||
|
if (str1 == NULL) {
|
||||||
|
if (str2 == NULL)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
} else if (str2 == NULL)
|
||||||
|
return -1;
|
||||||
|
return strcmp(str1, str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// locking
|
// locking
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user