mirror of https://github.com/OpenTTD/OpenTTD
(svn r18919) -Fix (r15371): strcasestr() return should not be const
parent
078e1edabc
commit
918b3aff5e
|
@ -385,12 +385,12 @@ char *strndup(const char *s, size_t len)
|
||||||
#endif /* !_GNU_SOURCE */
|
#endif /* !_GNU_SOURCE */
|
||||||
|
|
||||||
#ifdef DEFINE_STRCASESTR
|
#ifdef DEFINE_STRCASESTR
|
||||||
const char *strcasestr(const char *haystack, const char *needle)
|
char *strcasestr(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
size_t hay_len = strlen(haystack);
|
size_t hay_len = strlen(haystack);
|
||||||
size_t needle_len = strlen(needle);
|
size_t needle_len = strlen(needle);
|
||||||
while (hay_len >= needle_len) {
|
while (hay_len >= needle_len) {
|
||||||
if (strncasecmp(haystack, needle, needle_len) == 0) return haystack;
|
if (strncasecmp(haystack, needle, needle_len) == 0) return const_cast<char *>(haystack);
|
||||||
|
|
||||||
haystack++;
|
haystack++;
|
||||||
hay_len--;
|
hay_len--;
|
||||||
|
|
|
@ -256,7 +256,7 @@ char *strndup(const char *s, size_t len);
|
||||||
# undef DEFINE_STRCASESTR
|
# undef DEFINE_STRCASESTR
|
||||||
#else
|
#else
|
||||||
# define DEFINE_STRCASESTR
|
# define DEFINE_STRCASESTR
|
||||||
const char *strcasestr(const char *haystack, const char *needle);
|
char *strcasestr(const char *haystack, const char *needle);
|
||||||
#endif /* strcasestr is available */
|
#endif /* strcasestr is available */
|
||||||
|
|
||||||
#endif /* STRING_FUNC_H */
|
#endif /* STRING_FUNC_H */
|
||||||
|
|
Loading…
Reference in New Issue