stdlib: conditionalize locale usage
_strtod_l as well as the gethex function both fetch the decimal point from the current LC_NUMERIC locale info. This pulls in _C_numeric_locale unconditionally even on targets not supporting locales at all. Another problem is that strtod.c and gdtoa-gethex.c are ELIX 1, while locale information in general isn't. This leads to potential build breakage on bare metal targets. Fix this by setting the decimal point to "." on all targets not defining __HAVE_LOCALE_INFO__. While at it, const'ify the entire local decimal point info in the affected functions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
5036d447c5
commit
bc0e8a9961
|
@ -149,10 +149,16 @@ gethex (struct _reent *ptr, const char **sp, const FPI *fpi,
|
|||
int esign, havedig, irv, k, n, nbits, up, zret;
|
||||
__ULong L, lostbits, *x;
|
||||
Long e, e1;
|
||||
const unsigned char *decimalpoint = (unsigned char *)
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
const unsigned char *decimalpoint = (const unsigned char *)
|
||||
__get_numeric_locale(loc)->decimal_point;
|
||||
size_t decp_len = strlen ((const char *) decimalpoint);
|
||||
unsigned char decp_end = decimalpoint[decp_len - 1];
|
||||
const size_t decp_len = strlen ((const char *) decimalpoint);
|
||||
const unsigned char decp_end = decimalpoint[decp_len - 1];
|
||||
#else
|
||||
const unsigned char *decimalpoint = (const unsigned char *) ".";
|
||||
const size_t decp_len = 1;
|
||||
const unsigned char decp_end = (unsigned char) '.';
|
||||
#endif
|
||||
|
||||
havedig = 0;
|
||||
s0 = *(const unsigned char **)sp + 2;
|
||||
|
|
|
@ -263,8 +263,13 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se,
|
|||
#ifdef Honor_FLT_ROUNDS
|
||||
int rounding;
|
||||
#endif
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
const char *decimal_point = __get_numeric_locale(loc)->decimal_point;
|
||||
int dec_len = strlen (decimal_point);
|
||||
const int dec_len = strlen (decimal_point);
|
||||
#else
|
||||
const char *decimal_point = ".";
|
||||
const int dec_len = 1;
|
||||
#endif
|
||||
|
||||
delta = bs = bd = NULL;
|
||||
sign = nz0 = nz = decpt = 0;
|
||||
|
|
Loading…
Reference in New Issue