Add lconv declaration and localeconv(3)

lconv is taken from ndk/sources/android/support/include/locale.h and
matches
bsd/glibc upstream.
Keep old declaration for 32-bits for compatibility.
localeconv.c and deps are taken from openbsd upstream.
Changed strtod.c accordingly.

Change-Id: I9fcc4d15f5674d192950d80edf26f36006cd31b4
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
This commit is contained in:
Pavel Chupin
2014-03-25 13:43:04 +04:00
committed by Calin Juravle
parent a58b3f78e1
commit 50282f72bb
13 changed files with 340 additions and 5 deletions

View File

@@ -0,0 +1,18 @@
/* $OpenBSD: _def_messages.c,v 1.5 2005/08/08 08:05:35 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <sys/localedef.h>
#include <locale.h>
const _MessagesLocale _DefaultMessagesLocale =
{
"^[Yy]",
"^[Nn]",
"yes",
"no"
} ;
const _MessagesLocale *_CurrentMessagesLocale = &_DefaultMessagesLocale;

View File

@@ -0,0 +1,30 @@
/* $OpenBSD: _def_monetary.c,v 1.4 2005/08/08 08:05:35 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <sys/localedef.h>
#include <limits.h>
#include <locale.h>
const _MonetaryLocale _DefaultMonetaryLocale =
{
"",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX
};
const _MonetaryLocale *_CurrentMonetaryLocale = &_DefaultMonetaryLocale;

View File

@@ -0,0 +1,17 @@
/* $OpenBSD: _def_numeric.c,v 1.4 2005/08/08 08:05:35 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <sys/localedef.h>
#include <locale.h>
const _NumericLocale _DefaultNumericLocale =
{
".",
"",
""
};
const _NumericLocale *_CurrentNumericLocale = &_DefaultNumericLocale;

View File

@@ -0,0 +1,36 @@
/* $OpenBSD: _def_time.c,v 1.5 2011/10/09 06:39:53 ajacoutot Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <sys/localedef.h>
#include <locale.h>
const _TimeLocale _DefaultTimeLocale =
{
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
},
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
},
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
},
{
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
},
{
"AM", "PM"
},
"%a %b %e %H:%M:%S %Y",
"%m/%d/%y",
"%H:%M:%S",
"%I:%M:%S %p"
};
const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;

View File

@@ -0,0 +1,59 @@
/* $OpenBSD: localeconv.c,v 1.5 2005/08/08 08:05:35 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <sys/localedef.h>
#include <locale.h>
/*
* The localeconv() function constructs a struct lconv from the current
* monetary and numeric locales.
*
* 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 */
ret.int_curr_symbol = _CurrentMonetaryLocale->int_curr_symbol;
ret.currency_symbol = _CurrentMonetaryLocale->currency_symbol;
ret.mon_decimal_point = _CurrentMonetaryLocale->mon_decimal_point;
ret.mon_thousands_sep = _CurrentMonetaryLocale->mon_thousands_sep;
ret.mon_grouping = _CurrentMonetaryLocale->mon_grouping;
ret.positive_sign = _CurrentMonetaryLocale->positive_sign;
ret.negative_sign = _CurrentMonetaryLocale->negative_sign;
ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
__mlocale_changed = 0;
}
if (__nlocale_changed) {
/* LC_NUMERIC */
ret.decimal_point = (char *) _CurrentNumericLocale->decimal_point;
ret.thousands_sep = (char *) _CurrentNumericLocale->thousands_sep;
ret.grouping = (char *) _CurrentNumericLocale->grouping;
__nlocale_changed = 0;
}
return (&ret);
}