This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: patch: PR libc/2254: make locale(1) report errors and improve help
- From: Petter Reinholdtsen <pere at hungry dot com>
- To: Petter Reinholdtsen <pere at hungry dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: 21 May 2003 11:05:26 +0200
- Subject: Re: patch: PR libc/2254: make locale(1) report errors and improve help
- References: <E19HNpx-0006ty-00@minerva.hungry.com>
- Reply-by: Tue, 1 Jan 1801 04:37:40 +1000
[Petter Reinholdtsen]
> Here is a patch to solve the problems reported in PR libc/2254.
Here is a new version of the patch. Roland had some comments on the
code style and the error messages. Both are slightly changed.
2003-05-21 Petter Reinholdtsen <pere@hungry.com>
* locale/programs/locale.c (main): Report an error if setlocale()
fails. [PR libc/2254].
* locale/programs/locale.c (more_help) Document some examples of
valid names to use as arguments to the locale program. [PR
libc/2254]
Index: locale/programs/locale.c
===================================================================
RCS file: /cvs/glibc/libc/locale/programs/locale.c,v
retrieving revision 1.48
diff -u -3 -p -u -r1.48 locale.c
--- locale/programs/locale.c 27 Apr 2003 08:58:05 -0000 1.48
+++ locale/programs/locale.c 21 May 2003 09:02:26 -0000
@@ -191,8 +191,10 @@ main (int argc, char *argv[])
/* Set locale. Do not set LC_ALL because the other categories must
not be affected (according to POSIX.2). */
- setlocale (LC_CTYPE, "");
- setlocale (LC_MESSAGES, "");
+ if (setlocale (LC_CTYPE, "") == NULL)
+ error (0, errno, gettext ("Cannot set LC_CTYPE to default locale"));
+ if (setlocale (LC_MESSAGES, "") == NULL)
+ error (0, errno, gettext ("Cannot set LC_MESSAGES to default locale"));
/* Initialize the message catalog. */
textdomain (PACKAGE);
@@ -203,7 +205,9 @@ main (int argc, char *argv[])
/* `-a' requests the names of all available locales. */
if (do_all != 0)
{
- setlocale (LC_COLLATE, "");
+ if (setlocale (LC_COLLATE, "") == NULL)
+ error (0, errno,
+ gettext ("Cannot set LC_COLLATE to default locale"));
write_locales ();
exit (EXIT_SUCCESS);
}
@@ -218,7 +222,8 @@ main (int argc, char *argv[])
/* Specific information about the current locale are requested.
Change to this locale now. */
- setlocale (LC_ALL, "");
+ if (setlocale (LC_ALL, "") = NULL)
+ error (0, errno, gettext ("Cannot set LC_ALL to default locale"));
/* If no real argument is given we have to print the contents of the
current locale definition variables. These are LANG and the LC_*. */
@@ -271,8 +276,11 @@ more_help (int key, const char *text, vo
{
case ARGP_KEY_HELP_EXTRA:
/* We print some extra information. */
- return xstrdup (gettext ("\
-Report bugs using the `glibcbug' script to <bugs@gnu.org>.\n"));
+ return xstrdup (gettext ("\n"
+"NAME is the name of a locale data entry. Examples are 'charmap' and\n"
+"'int_curr_symbol' See the source for the full list.\n"
+"\n"
+"Report bugs using the `glibcbug' script to <bugs@gnu.org>.\n"));
default:
break;
}