/* Implementation of the locale program according to POSIX 9945-2.
- Copyright (C) 1995-1997, 1999-2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-1997, 1999-2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2 as
+ published by the Free Software Foundation.
- The GNU C Library is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
};
/* Short description of program. */
-static const char doc[] = N_("Get locale-specific information.");
+static const char doc[] = N_("Get locale-specific information.\v\
+For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n");
/* Strings for arguments in help texts. */
static const char args_doc[] = N_("NAME\n[-a|-m]");
/* Prototype for option handler. */
static error_t parse_opt (int key, char *arg, struct argp_state *state);
-/* Function to print some extra text in the help message. */
-static char *more_help (int key, const char *text, void *input);
-
/* Data structure to communicate with argp functions. */
static struct argp argp =
{
- options, parse_opt, args_doc, doc, NULL, more_help
+ options, parse_opt, args_doc, doc
};
/* 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);
/* `-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);
}
/* 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_*. */
}
-static char *
-more_help (int key, const char *text, void *input)
-{
- switch (key)
- {
- case ARGP_KEY_HELP_EXTRA:
- /* We print some extra information. */
- return xstrdup (gettext ("\
-Report bugs using the `glibcbug' script to <bugs@gnu.org>.\n"));
- default:
- break;
- }
- return (char *) text;
-}
-
/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "2003");
+"), "2005");
fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
}
{
size_t cat_no;
const char *lcall = getenv ("LC_ALL");
- const char *lang = getenv ("LANG") ? : "POSIX";
+ const char *lang = getenv ("LANG") ? : "";
auto void get_source (const char *name);
char *val = getenv (name);
if ((lcall ?: "")[0] != '\0' || val == NULL)
- printf ("%s=\"%s\"\n", name, (lcall ?: "")[0] ? lcall : lang);
+ printf ("%s=\"%s\"\n", name,
+ (lcall ?: "")[0] ? lcall : (lang ?: "")[0] ? lang : "POSIX");
else
printf ("%s=%s\n", name, val);
}
printf ("%s=", item->name);
if (val != NULL)
- printf ("%d", *val == CHAR_MAX ? -1 : *val);
+ printf ("%d", *val == '\177' ? -1 : *val);
putchar ('\n');
}
break;
while (cnt > 1)
{
- printf ("%d;", *val == CHAR_MAX ? -1 : *val);
+ printf ("%d;", *val == '\177' ? -1 : *val);
--cnt;
++val;
}
- printf ("%d\n", cnt == 0 || *val == CHAR_MAX ? -1 : *val);
+ printf ("%d\n", cnt == 0 || *val == '\177' ? -1 : *val);
}
break;
case word:
{
- unsigned int val =
- (unsigned int) (unsigned long int) nl_langinfo (item->item_id);
+ union { unsigned int word; char *string; } val;
+ val.string = nl_langinfo (item->item_id);
if (show_keyword_name)
printf ("%s=", item->name);
- printf ("%d\n", val);
+ printf ("%d\n", val.word);
}
break;
case wstring: