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.
*** 52,73 ****
/*
* 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);
--- 57,79 ----
/*
* 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);
*** 88,107 ****
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);
}
--- 94,119 ----
M_ASSIGN_CHAR(int_p_sign_posn);
M_ASSIGN_CHAR(int_n_sign_posn);
__mlocale_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();
N_ASSIGN_STR(decimal_point);
N_ASSIGN_STR(thousands_sep);
N_ASSIGN_STR(grouping);
__nlocale_changed = 0;
}
! return (ret);
! }
!
! struct lconv *
! localeconv(void)
! {
! return (localeconv_l(__get_locale()));
}