2016-10-13 Keith Marshall <keithmarshall@users.sourceforge.net>
+ Emulate glibc <string.h> POSIX.1 non-compliance.
+
+ * include/_mingw.h.in (_EMULATE_GLIBC): New feature test macro.
+ [_GNU_SOURCE || _BSD_SOURCE || !__STRICT_ANSI__]: Enable it when...
+ [_XOPEN_SOURCE || _POSIX_C_SOURCE || _POSIX_SOURCE]: ...none of
+ these have been pre-defined by the user.
+
+ * include/string.h [_EMULATE_GLIBC]: Include <strings.h> in full...
+ (strcasecmp, strncasecmp): ...so prototypes for these are declared.
+ [!_EMULATE_GLIBC]: Preserve partial <strings.h> include, guarded by...
+ [__STRING_H_SOURCED__]: ...this context selector, so suppressing the
+ declarations of those function prototypes.
+
+2016-10-13 Keith Marshall <keithmarshall@users.sourceforge.net>
+
Resolve some non-ANSI typedef omissions.
* include/sys/types.h (off_t, ssize_t): Always typedef them when...
*/
# define _POSIX_C_SOURCE 200809L
+# if ! defined _EMULATE_GLIBC && ! defined _POSIX_SOURCE
+ /* For this default case, unless it has already been specified
+ * otherwise, we enable some GNU glibc extensions, which may be
+ * considered as violations of strict POSIX.1 conformance.
+ */
+# define _EMULATE_GLIBC 1
+# endif
+
# elif defined _POSIX_SOURCE
/* Now formally deprecated by POSIX, some old code may specify this;
* it will enable a minimal level of POSIX support, in addition to the
#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