Print this page
2964 need POSIX 2008 locale object support
*** 2,11 ****
--- 2,16 ----
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*** 45,73 ****
* Because localeconv() may be called many times (especially by library
* routines like printf() & strtod()), the approprate members of the
* lconv structure are computed only when the monetary or numeric
* locale has been changed.
*/
- int __mlocale_changed = 1;
- int __nlocale_changed = 1;
/*
* Return the current locale conversion.
*/
struct lconv *
! localeconv(void)
{
! static struct lconv ret;
! if (__mlocale_changed) {
/* LC_MONETARY part */
struct lc_monetary_T *mptr;
! #define M_ASSIGN_STR(NAME) (ret.NAME = (char *)mptr->NAME)
! #define M_ASSIGN_CHAR(NAME) (ret.NAME = mptr->NAME[0])
! mptr = __get_current_monetary_locale();
M_ASSIGN_STR(int_curr_symbol);
M_ASSIGN_STR(currency_symbol);
M_ASSIGN_STR(mon_decimal_point);
M_ASSIGN_STR(mon_thousands_sep);
M_ASSIGN_STR(mon_grouping);
--- 50,77 ----
* Because localeconv() may be called many times (especially by library
* routines like printf() & strtod()), the approprate members of the
* lconv structure are computed only when the monetary or numeric
* locale has been changed.
*/
/*
* Return the current locale conversion.
*/
struct lconv *
! localeconv_l(locale_t loc)
{
! FIX_LOCALE(loc);
! struct lconv *ret = &loc->lconv;
! if (loc->monetary_locale_changed) {
/* LC_MONETARY part */
struct lc_monetary_T *mptr;
! #define M_ASSIGN_STR(NAME) (ret->NAME = (char *)mptr->NAME)
! #define M_ASSIGN_CHAR(NAME) (ret->NAME = mptr->NAME[0])
! mptr = __get_current_monetary_locale(loc);
M_ASSIGN_STR(int_curr_symbol);
M_ASSIGN_STR(currency_symbol);
M_ASSIGN_STR(mon_decimal_point);
M_ASSIGN_STR(mon_thousands_sep);
M_ASSIGN_STR(mon_grouping);
*** 85,107 ****
M_ASSIGN_CHAR(int_n_cs_precedes);
M_ASSIGN_CHAR(int_p_sep_by_space);
M_ASSIGN_CHAR(int_n_sep_by_space);
M_ASSIGN_CHAR(int_p_sign_posn);
M_ASSIGN_CHAR(int_n_sign_posn);
! __mlocale_changed = 0;
}
! if (__nlocale_changed) {
/* LC_NUMERIC part */
struct lc_numeric_T *nptr;
! #define N_ASSIGN_STR(NAME) (ret.NAME = (char *)nptr->NAME)
! nptr = __get_current_numeric_locale();
N_ASSIGN_STR(decimal_point);
N_ASSIGN_STR(thousands_sep);
N_ASSIGN_STR(grouping);
! __nlocale_changed = 0;
}
! return (&ret);
}
--- 89,117 ----
M_ASSIGN_CHAR(int_n_cs_precedes);
M_ASSIGN_CHAR(int_p_sep_by_space);
M_ASSIGN_CHAR(int_n_sep_by_space);
M_ASSIGN_CHAR(int_p_sign_posn);
M_ASSIGN_CHAR(int_n_sign_posn);
! loc->monetary_locale_changed = 0;
}
! if (loc->numeric_locale_changed) {
/* LC_NUMERIC part */
struct lc_numeric_T *nptr;
! #define N_ASSIGN_STR(NAME) (ret->NAME = (char *)nptr->NAME)
! nptr = __get_current_numeric_locale(loc);
N_ASSIGN_STR(decimal_point);
N_ASSIGN_STR(thousands_sep);
N_ASSIGN_STR(grouping);
! loc->numeric_locale_changed = 0;
}
! return (ret);
! }
!
! struct lconv *
! localeconv(void)
! {
! return (localeconv_l(__get_locale()));
}