Mercurial > hg > octave-shane > gnulib-hg
changeset 3203:3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Don't return NULL.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Tue, 06 Mar 2001 18:11:20 +0000 |
parents | 283d780ab032 |
children | 237c10fd3d57 |
files | lib/localcharset.c |
diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000-2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -191,7 +191,7 @@ into one of the canonical names listed in config.charset. The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical - name or NULL. */ + name. */ #ifdef STATIC STATIC @@ -211,10 +211,14 @@ # else - /* On old systems which lack it, use setlocale and getenv. */ + /* On old systems which lack it, use setlocale or getenv. */ const char *locale = NULL; -# if HAVE_SETLOCALE + /* 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') @@ -245,7 +249,10 @@ #endif - if (codeset != NULL && codeset[0] != '\0') + if (codeset == NULL) + /* The canonical name cannot be determined. */ + codeset = ""; + else if (codeset[0] != '\0') { /* Resolve alias. */ for (aliases = get_charset_aliases ();