bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

localcharset is conditional on HAVE_SETLOCALE


From: Paul Eggert
Subject: localcharset is conditional on HAVE_SETLOCALE
Date: Tue, 17 Oct 2006 09:30:58 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> The reason is that HAVE_SETLOCALE is tested, but nowhere defined. Since one
> can assume setlocale() already for ca. 5 years, there is no risk in removing
> the HAVE_SETLOCALE.

I just checked, and coreutils tests for setlocale, but only because
localcharset does.  The localcharset test slows down 'configure' and
does not affect how the code actually behaves.  OK to install this?

2006-10-17  Paul Eggert  <address@hidden>

        Simplify localcharset code a bit and speed up configuration
        by removing test for setlocale.
        * lib/localcharset.c: Do not include <locale.h> or
        check HAVE_SETLOCALE, since the code never invokes setlocale
        anyway.  This change doesn't affect runtime behavior.
        * m4/localcharset.m4 (gl_LOCALCHARSET): Don't check for setlocale.

Index: lib/localcharset.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/localcharset.c,v
retrieving revision 1.25
diff -p -c -r1.25 localcharset.c
*** lib/localcharset.c  14 Sep 2006 14:18:36 -0000      1.25
--- lib/localcharset.c  17 Oct 2006 16:30:26 -0000
***************
*** 40,49 ****
  #if !defined WIN32_NATIVE
  # if HAVE_LANGINFO_CODESET
  #  include <langinfo.h>
- # else
- #  if HAVE_SETLOCALE
- #   include <locale.h>
- #  endif
  # endif
  # ifdef __CYGWIN__
  #  define WIN32_LEAN_AND_MEAN
--- 40,45 ----
*************** locale_charset (void)
*** 344,368 ****
  
  # else
  
!   /* On old systems which lack it, use setlocale or getenv.  */
!   const char *locale = NULL;
! 
!   /* But most old systems don't have a complete set of locales.  Some
       (like SunOS 4 or DJGPP) have only the C locale.  Therefore we don't
       use setlocale here; it would return "C" when it doesn't support the
       locale name the user has set.  */
! #  if HAVE_SETLOCALE && 0
!   locale = setlocale (LC_CTYPE, NULL);
! #  endif
    if (locale == NULL || locale[0] == '\0')
      {
!       locale = getenv ("LC_ALL");
        if (locale == NULL || locale[0] == '\0')
!       {
!         locale = getenv ("LC_CTYPE");
!         if (locale == NULL || locale[0] == '\0')
!           locale = getenv ("LANG");
!       }
      }
  
    /* On some old systems, one used to set locale = "iso8859_1". On others,
--- 340,357 ----
  
  # else
  
!   /* On old systems which lack it, use getenv.
!      Most old systems don't have a complete set of locales.  Some
       (like SunOS 4 or DJGPP) have only the C locale.  Therefore we don't
       use setlocale here; it would return "C" when it doesn't support the
       locale name the user has set.  */
!   const char *locale = getenv ("LC_ALL");
! 
    if (locale == NULL || locale[0] == '\0')
      {
!       locale = getenv ("LC_CTYPE");
        if (locale == NULL || locale[0] == '\0')
!       locale = getenv ("LANG");
      }
  
    /* On some old systems, one used to set locale = "iso8859_1". On others,
Index: m4/localcharset.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/localcharset.m4,v
retrieving revision 1.5
diff -p -c -r1.5 localcharset.m4
*** m4/localcharset.m4  31 Jul 2006 16:09:08 -0000      1.5
--- m4/localcharset.m4  17 Oct 2006 16:30:26 -0000
*************** AC_DEFUN([gl_LOCALCHARSET],
*** 9,15 ****
    dnl Prerequisites of lib/localcharset.c.
    AC_REQUIRE([AM_LANGINFO_CODESET])
    AC_CHECK_DECLS_ONCE(getc_unlocked)
-   AC_CHECK_FUNCS_ONCE(setlocale)
  
    dnl Prerequisites of the lib/Makefile.am snippet.
    AC_REQUIRE([AC_CANONICAL_HOST])
--- 9,14 ----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]