Use #ifdef instead of #if for NLS symbols.
 #include <stdlib.h>
 #endif
 
 #include <stdlib.h>
 #endif
 
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
 #if (defined(VMS) || defined(MSDOS)) && !defined(HAVE_STRING_H)
 #define HAVE_STRING_H 1
 #endif
 #if (defined(VMS) || defined(MSDOS)) && !defined(HAVE_STRING_H)
 #define HAVE_STRING_H 1
 #endif
 /* memory.h and strings.h conflict on some systems.  */
 #endif /* not STDC_HEADERS and not HAVE_STRING_H */
 
 /* memory.h and strings.h conflict on some systems.  */
 #endif /* not STDC_HEADERS and not HAVE_STRING_H */
 
+#if defined(STDC_HEADERS) || defined(HAVE_CTYPE_H)
+#include <ctype.h>
+#endif
+
+#ifdef HAVE_LOCALE_H
 # include <locale.h>
 #endif
 # include <locale.h>
 #endif
 # define setlocale(Category, Locale)
 #endif
 
 # define setlocale(Category, Locale)
 #endif
 
 # include <libintl.h>
 # define _(Text) gettext (Text)
 #else
 # include <libintl.h>
 # define _(Text) gettext (Text)
 #else