Changeset - r14352:2d48e17549d1
[Not reviewed]
master
0 2 0
glx - 15 years ago 2010-01-26 14:04:56
glx@openttd.org
(svn r18919) -Fix (r15371): strcasestr() return should not be const
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/string.cpp
Show inline comments
 
@@ -382,18 +382,18 @@ char *strndup(const char *s, size_t len)
 
	memcpy(tmp, s, len);
 
	return tmp;
 
}
 
#endif /* !_GNU_SOURCE */
 

	
 
#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 needle_len = strlen(needle);
 
	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++;
 
		hay_len--;
 
	}
 

	
 
	return NULL;
src/string_func.h
Show inline comments
 
@@ -253,10 +253,10 @@ char *strndup(const char *s, size_t len)
 

	
 
/* strcasestr is available for _GNU_SOURCE, BSD and some Apple */
 
#if defined(_GNU_SOURCE) || (defined(__BSD_VISIBLE) && __BSD_VISIBLE) || (defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)))
 
#	undef DEFINE_STRCASESTR
 
#else
 
#	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 /* STRING_FUNC_H */
0 comments (0 inline, 0 general)