#endif
#include <stddef.h>
+#if _EMULATE_GLIBC
+/* GNU's glibc declares strcasecmp() and strncasecmp() in <string.h>,
+ * contravening POSIX.1-2008 which requires them to be declared only in
+ * <strings.h>; we may emulate this anomalous glibc behaviour, which is
+ * ostensibly to support BSD usage, (in spite of such usage now being
+ * obsolete in BSD), by simply including our <strings.h> here.
+ */
+#include <strings.h>
+#endif
+
_BEGIN_C_DECLS
#define __STRING_H_SOURCED__
/* MSVC's non-ANSI _stricmp() and _strnicmp() functions must also be
* prototyped here, but we need to share them with <strings.h>, where
* we declare their POSIX strcasecmp() and strncasecmp() equivalents;
- * get the requisite prototypes by selective <strings.h> inclusion.
+ * get the requisite prototypes by selective <strings.h> inclusion,
+ * (noting that we've already done so, if emulating glibc).
*/
+#if !_EMULATE_GLIBC
#include <strings.h>
+#endif
# ifdef __MSVCRT__
/* These were not present in the CRTDLL prior to the first release of
* the GCC breakage noted above. (Note that we implement strnlen() with
* the alternative external name, __mingw_strnlen() in libmingwex.a, to
* avoid possible link time collision with MSVCR80.DLL's implementation,
- * then map this to strnlen() via a preprocessor define, so that users
- * may use it conventionally, (including taking its address); this may
- * interfere with C++ namespace qualification, but since strnlen() is
- * not a standard C++ function, we do not anticipate any consequent
- * usage issues).
+ * then map this to strnlen() via a __CRT_ALIAS, with stubs designated
+ * for linking from within the appropriate oldname libraries.
*/
-#define strnlen __mingw_strnlen
extern size_t __mingw_strnlen (const char *, size_t);
+__JMPSTUB__(( LIB=coldname; FUNCTION=strnlen ))
+__CRT_ALIAS size_t strnlen (const char *__text, size_t __maxlen)
+{ return __mingw_strnlen (__text, __maxlen); }
+
#endif /* _POSIX_C_SOURCE >= 200809L */
#undef __STRING_H_SOURCED__