FreeBSD/gnu/usr.bin/grep/hard-locale.c
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
   can't get away with assuming traditional C or POSIX behavior.  */
Return nonzero if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior.
Return nonzero if the current CATEGORY locale is hard i . e . if you can ' t get away with assuming traditional C or POSIX behavior .
int
hard_locale (int category)
{
#if ! HAVE_SETLOCALE
  return 0;
#else
  int hard = 1;
  char const *p = setlocale (category, 0);
  if (p)
    {
# if defined(__FreeBSD__) || (defined __GLIBC__ && __GLIBC__ >= 2)
      if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
	hard = 0;
# else
      char *locale = alloca (strlen (p) + 1);
      strcpy (locale, p);
      if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
	  || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
	hard = 0;
      setlocale (category, locale);
# endif
    }
  return hard;
#endif
}
int hard_locale ( int category ) { #if ! HAVE_SETLOCALE return 0 ; #else int hard = 1 ; char const * p = setlocale ( category , 0 ) ; if ( p ) { # if defined ( __FreeBSD__ ) || ( defined __GLIBC__ && __GLIBC__ >= 2 ) if ( strcmp ( p , " " ) == 0 || strcmp ( p , " " ) == 0 ) hard = 0 ; # else char * locale = alloca ( strlen ( p ) + 1 ) ; strcpy ( locale , p ) ; if ( ( ( p = setlocale ( category , " " ) ) && strcmp ( p , locale ) == 0 ) || ( ( p = setlocale ( category , " " ) ) && strcmp ( p , locale ) == 0 ) ) hard = 0 ; setlocale ( category , locale ) ; # endif } return hard ; #endif }
Return nonzero if the current CATEGORY locale is hard, i.e.
Return nonzero if the current CATEGORY locale is hard i . e .
/* Temporarily set the locale to the "C" and "POSIX" locales to
	 find their names, so that we can determine whether one or the
	 other is the caller's locale.  */ /* Restore the caller's locale.  */