2013-12-06 12:04:52 +01:00
|
|
|
/* $NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $ */
|
2011-02-14 20:36:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Written by Klaus Klein <kleink@NetBSD.org>, November 16, 2005.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTICE: This is not a standalone file. To use it, #include it in
|
|
|
|
* the format-specific strtold_*.c, like so:
|
|
|
|
*
|
|
|
|
* #define GDTOA_LD_FMT <gdtoa extended-precision format code>
|
|
|
|
* #include "strtold_subr.c"
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
2013-12-06 12:04:52 +01:00
|
|
|
__RCSID("$NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $");
|
2011-02-14 20:36:03 +01:00
|
|
|
#endif /* LIBC_SCCS and not lint */
|
|
|
|
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "gdtoa.h"
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
#include <locale.h>
|
|
|
|
#include "setlocale_local.h"
|
|
|
|
|
2011-02-14 20:36:03 +01:00
|
|
|
#ifdef __weak_alias
|
|
|
|
__weak_alias(strtold, _strtold)
|
2013-12-06 12:04:52 +01:00
|
|
|
__weak_alias(strtold_l, _strtold_l)
|
2011-02-14 20:36:03 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __HAVE_LONG_DOUBLE
|
|
|
|
#error no extended-precision long double type
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GDTOA_LD_FMT
|
|
|
|
#error GDTOA_LD_FMT must be defined by format-specific source file
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define STRTOP(x) __CONCAT(strtop, x)
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
static long double
|
|
|
|
_int_strtold_l(const char *nptr, char **endptr, locale_t loc)
|
2011-02-14 20:36:03 +01:00
|
|
|
{
|
|
|
|
long double ld;
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
(void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld, loc);
|
2011-02-14 20:36:03 +01:00
|
|
|
return ld;
|
|
|
|
}
|
2013-12-06 12:04:52 +01:00
|
|
|
|
|
|
|
long double
|
|
|
|
strtold(CONST char *s, char **sp)
|
|
|
|
{
|
|
|
|
return _int_strtold_l(s, sp, _current_locale());
|
|
|
|
}
|
|
|
|
|
|
|
|
long double
|
|
|
|
strtold_l(CONST char *s, char **sp, locale_t loc)
|
|
|
|
{
|
|
|
|
return _int_strtold_l(s, sp, loc);
|
|
|
|
}
|