Index: src/string.cpp =================================================================== --- src/string.cpp (revision 19861) +++ src/string.cpp (working copy) @@ -398,7 +398,7 @@ return length; } -#ifndef _GNU_SOURCE +#ifdef DEFINE_STRNDUP #include "core/math_func.hpp" char *strndup(const char *s, size_t len) { @@ -407,7 +407,7 @@ memcpy(tmp, s, len); return tmp; } -#endif /* !_GNU_SOURCE */ +#endif /* DEFINE_STRNDUP */ #ifdef DEFINE_STRCASESTR char *strcasestr(const char *haystack, const char *needle) Index: src/smallmap_gui.cpp =================================================================== --- src/smallmap_gui.cpp (revision 19861) +++ src/smallmap_gui.cpp (working copy) @@ -643,7 +643,7 @@ static const int MAX_ZOOM_INDEX = lengthof(zoomlevels) - 1; int new_index, cur_index, sub; - Point tile; + Point tile = {0, 0}; switch (change) { case ZLC_INITIALIZE: cur_index = - 1; // Definitely different from new_index. Index: src/string_func.h =================================================================== --- src/string_func.h (revision 19861) +++ src/string_func.h (working copy) @@ -251,10 +251,13 @@ #include #endif -#if !defined(_GNU_SOURCE) && !(defined(__NetBSD_Version__) && 400000000 < __NetBSD_Version__ ) /* strndup is a GNU extension */ +#if defined(_GNU_SOURCE) || (defined(__NetBSD_Version__) && 400000000 <= __NetBSD_Version__) +# undef DEFINE_STRNDUP +#else +# define DEFINE_STRNDUP char *strndup(const char *s, size_t len); -#endif /* !_GNU_SOURCE */ +#endif /* strndup is available */ /* 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))) || defined(_NETBSD_SOURCE)