aboutsummaryrefslogtreecommitdiff
path: root/locale/newlocale.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-24 21:03:16 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-24 21:03:16 +0000
commit5bef282098d6c920c12e46dea5bac099e5cb3abf (patch)
treea8eadab44e26951b9bf0abdcfc964afbe06cdbc1 /locale/newlocale.c
parentf3d5834e69eeb4dca353ef35c600adb74d604f22 (diff)
downloadglibc-5bef282098d6c920c12e46dea5bac099e5cb3abf.tar
glibc-5bef282098d6c920c12e46dea5bac099e5cb3abf.tar.gz
glibc-5bef282098d6c920c12e46dea5bac099e5cb3abf.tar.bz2
glibc-5bef282098d6c920c12e46dea5bac099e5cb3abf.zip
Update.
2000-07-24 Jakub Jelinek <jakub@redhat.com> * libio/wfiledoalloc.c (_IO_wfile_doallocate): Measure size in wide characters, not bytes. * libio/tst_putwc.c (do_test): Add test for writing lots of data into file. 2000-07-22 Bruno Haible <haible@clisp.cons.org> * locale/nl_langinfo.c (nl_langinfo): Accept items belonging to the new categories LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, LC_IDENTIFICATION. * locale/xlocale.h (struct __locale_struct): Increase size of __locales array. * locale/duplocale.c (__duplocale): Copy newly added categories as well. * locale/freelocale.c (__freelocale): Free newly added categories. * locale/newlocale.c (__newlocale): Fix typo in sanity check. If a base is given, use it, don't simply return it. 2000-07-22 Bruno Haible <haible@clisp.cons.org> * crypt/md5-crypt.c (__md5_crypt_r): Avoid gcc warnings: Use pointer variables, copied_key and copied_salt, instead of boolean variables.
Diffstat (limited to 'locale/newlocale.c')
-rw-r--r--locale/newlocale.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/locale/newlocale.c b/locale/newlocale.c
index 4a2f14513f..5c0d7ba46a 100644
--- a/locale/newlocale.c
+++ b/locale/newlocale.c
@@ -1,5 +1,5 @@
/* Return a reference to locale information record.
- Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -54,7 +54,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
category_mask = (1 << __LC_LAST) - 1 - (1 << LC_ALL);
/* Sanity check for CATEGORY argument. */
- if ((category_mask & ~((1 << LC_ALL) - 1 - (1 << LC_ALL))) != 0)
+ if ((category_mask & ~((1 << __LC_LAST) - 1 - (1 << LC_ALL))) != 0)
ERROR_RETURN;
/* `newlocale' does not support asking for the locale name. */
@@ -63,28 +63,25 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
/* Allocate memory for the result. */
if (base != NULL)
- {
- if (base != NULL)
- return base;
-
- result = *base;
- }
+ result = *base;
else
{
- /* Fill with pointers to C locale data to . */
+ /* Fill with pointers to C locale data. */
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL)
result.__locales[cnt] = _nl_C[cnt];
+ }
- /* If no category is to be set we return BASE if available or a
- dataset using the C locale data. */
- if (category_mask == 0)
- {
- result_ptr = (__locale_t) malloc (sizeof (struct __locale_struct));
- *result_ptr = result;
+ /* If no category is to be set we return BASE if available or a
+ dataset using the C locale data. */
+ if (category_mask == 0)
+ {
+ result_ptr = (__locale_t) malloc (sizeof (struct __locale_struct));
+ if (result_ptr == NULL)
+ return NULL;
+ *result_ptr = result;
- goto update;
- }
+ goto update;
}
/* We perhaps really have to load some data. So we determine the
@@ -175,12 +172,12 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
update:
{
union locale_data_value *ctypes = result_ptr->__locales[LC_CTYPE]->values;
- result_ptr->__ctype_b = (const unsigned short int *)
- (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_CLASS)] .string);
- result_ptr->__ctype_tolower = (const int *)
- (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER)].string);
- result_ptr->__ctype_toupper = (const int *)
- (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER)].string);
+ result_ptr->__ctype_b = (const unsigned short int *)
+ (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_CLASS)].string);
+ result_ptr->__ctype_tolower = (const int *)
+ (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER)].string);
+ result_ptr->__ctype_toupper = (const int *)
+ (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER)].string);
}
return result_ptr;