-#ifdef WINDOWS
-/* Windows doesn't have some functions. Include mswindows.h so we get
- their declarations, as well as some additional declarations and
- macros. This must come first, so it can set things up. */
-#include <mswindows.h>
-#endif /* WINDOWS */
-
-/* Watcom-specific stuff. In practice this is probably specific to
- Windows, although Watcom exists under other OS's too. For that
- reason, we keep this here. */
-
-#ifdef __WATCOMC__
-/* Watcom has its own alloca() defined in malloc.h malloc.h needs to
- be included in the sources to prevent 'undefined external' errors
- at the link phase. */
+/* The "namespace tweaks" below attempt to set a friendly "compilation
+ environment" under popular operating systems. Default compilation
+ environment often means that some functions that are "extensions"
+ are not declared -- `strptime' is one example.
+
+ But non-default environments can expose bugs in the system header
+ files, crippling compilation in _very_ non-obvious ways. Because
+ of that, we define them only on well-tested architectures where we
+ know they will work. */
+
+#undef NAMESPACE_TWEAKS
+
+#ifdef solaris
+# define NAMESPACE_TWEAKS
+#endif
+
+#if defined(__linux__) || defined(__GLIBC__)
+# define NAMESPACE_TWEAKS
+#endif
+
+#ifdef NAMESPACE_TWEAKS
+
+/* Request the "Unix 98 compilation environment". */
+#define _XOPEN_SOURCE 500
+
+#endif /* NAMESPACE_TWEAKS */
+
+
+/* Alloca declaration, based on recommendation in the Autoconf manual.
+ These have to be after the above namespace tweaks, but before any
+ non-preprocessor code. */
+
+#if HAVE_ALLOCA_H
+# include <alloca.h>
+#elif defined WINDOWS