typedef struct fnode fnode;
struct gfc_unit;
-#ifdef HAVE_NEWLOCALE
-/* We have POSIX 2008 extended locale stuff. */
+#if defined (HAVE_FREELOCALE) && defined (HAVE_NEWLOCALE) \
+ && defined (HAVE_USELOCALE)
+/* We have POSIX 2008 extended locale stuff. We only choose to use it
+ if all the functions required are present as some systems, e.g. NetBSD
+ do not have `uselocale'. */
+#define HAVE_POSIX_2008_LOCALE
extern locale_t c_locale;
internal_proto(c_locale);
#else
char *line_buffer;
struct format_data *fmt;
namelist_info *ionml;
-#ifdef HAVE_NEWLOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
locale_t old_locale;
#endif
/* Current position within the look-ahead line buffer. */
if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED)
{
-#ifdef HAVE_USELOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
dtp->u.p.old_locale = uselocale (c_locale);
#else
__gthread_mutex_lock (&old_locale_lock);
}
}
-#ifdef HAVE_USELOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
if (dtp->u.p.old_locale != (locale_t) 0)
{
uselocale (dtp->u.p.old_locale);
static char stderr_name[] = "stderr";
-#ifdef HAVE_NEWLOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
locale_t c_locale;
#else
/* If we don't have POSIX 2008 per-thread locales, we need to use the
{
gfc_unit *u;
-#ifdef HAVE_NEWLOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
c_locale = newlocale (0, "C", 0);
#else
#ifndef __GTHREAD_MUTEX_INIT
free (newunits);
-#ifdef HAVE_FREELOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
freelocale (c_locale);
#endif
}
p = strerror (errnum);
return p;
#elif defined(HAVE_STRERROR_R)
-#ifdef HAVE_USELOCALE
+#ifdef HAVE_POSIX_2008_LOCALE
/* Some targets (Darwin at least) have the POSIX 2008 extended
locale functions, but not strerror_l. So reset the per-thread
locale here. */