<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39849 >
Naive trunk implementation:
Index: utility/support.c =================================================================== --- utility/support.c (revision 13930) +++ utility/support.c (working copy) @@ -156,6 +156,40 @@ } /*************************************************************** + Return the needle in the haystack (or NULL). + Naive implementation. +***************************************************************/ +char *mystrcasestr(const char *haystack, const char *needle) +{ +#ifdef HAVE_STRCASESTR + return strcasestr(haystack, needle); +#else + size_t haystacks; + size_t needles; + const char *p; + + if (NULL == needle || '\0' == *needle) { + return (char *)haystack; + } + if (NULL == haystack || '\0' == *haystack) { + return NULL; + } + haystacks = strlen(haystack); + needles = strlen(needle); + if (haystacks < needles) { + return NULL; + } + + for (p = haystack; p <= &haystack[haystacks - needles]; p++) { + if (0 == mystrncasecmp(p, needle, needles)) { + return (char *)p; + } + } + return NULL; +#endif +} + +/*************************************************************** Return a string which describes a given error (errno-style.) ***************************************************************/ const char *mystrerror(void) Index: utility/support.h =================================================================== --- utility/support.h (revision 13930) +++ utility/support.h (working copy) @@ -74,6 +74,8 @@ int mystrncasecmp(const char *str0, const char *str1, size_t n); int mystrncasequotecmp(const char *str0, const char *str1, size_t n); +char *mystrcasestr(const char *haystack, const char *needle); + const char *mystrerror(void); void myusleep(unsigned long usec); Index: server/ruleset.c =================================================================== --- server/ruleset.c (revision 13930) +++ server/ruleset.c (working copy) @@ -2286,7 +2286,7 @@ * Note that the section name is unique (by definition). * The sub-strings are carefully crafted for this function. */ - if (NULL != strcasestr(isection, name)) { + if (NULL != mystrcasestr(isection, name)) { city_names[j].terrain[i] = setting; handled = TRUE; break;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev