Blame stdlib/strtod.c

Packit 6c4009
/* Read decimal floating point numbers.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <bits/floatn.h>
Packit 6c4009
Packit 6c4009
#ifdef FLOAT
Packit 6c4009
# define BUILD_DOUBLE 0
Packit 6c4009
#else
Packit 6c4009
# define BUILD_DOUBLE 1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if BUILD_DOUBLE
Packit 6c4009
# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
Packit 6c4009
#  define strtof64 __hide_strtof64
Packit 6c4009
#  define wcstof64 __hide_wcstof64
Packit 6c4009
# endif
Packit 6c4009
# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
Packit 6c4009
#  define strtof32x __hide_strtof32x
Packit 6c4009
#  define wcstof32x __hide_wcstof32x
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
#include <wchar.h>
Packit 6c4009
#include <locale/localeinfo.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifndef FLOAT
Packit 6c4009
# include <math_ldbl_opt.h>
Packit 6c4009
# define FLOAT double
Packit 6c4009
# ifdef USE_WIDE_CHAR
Packit 6c4009
#  define STRTOF wcstod
Packit 6c4009
#  define STRTOF_L __wcstod_l
Packit 6c4009
# else
Packit 6c4009
#  define STRTOF strtod
Packit 6c4009
#  define STRTOF_L __strtod_l
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef USE_WIDE_CHAR
Packit 6c4009
# include <wctype.h>
Packit 6c4009
# define STRING_TYPE wchar_t
Packit 6c4009
#else
Packit 6c4009
# define STRING_TYPE char
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define INTERNAL(x) INTERNAL1(x)
Packit 6c4009
#define INTERNAL1(x) __##x##_internal
Packit 6c4009
Packit 6c4009
Packit 6c4009
FLOAT
Packit 6c4009
INTERNAL (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group)
Packit 6c4009
{
Packit 6c4009
  return INTERNAL(STRTOF_L) (nptr, endptr, group, _NL_CURRENT_LOCALE);
Packit 6c4009
}
Packit 6c4009
#if defined _LIBC
Packit 6c4009
libc_hidden_def (INTERNAL (STRTOF))
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
FLOAT
Packit 6c4009
#ifdef weak_function
Packit 6c4009
weak_function
Packit 6c4009
#endif
Packit 6c4009
STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
Packit 6c4009
{
Packit 6c4009
  return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
Packit 6c4009
}
Packit 6c4009
#if defined _LIBC
Packit 6c4009
libc_hidden_def (STRTOF)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef LONG_DOUBLE_COMPAT
Packit 6c4009
# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
Packit 6c4009
#  ifdef USE_WIDE_CHAR
Packit 6c4009
compat_symbol (libc, wcstod, wcstold, GLIBC_2_0);
Packit 6c4009
compat_symbol (libc, __wcstod_internal, __wcstold_internal, GLIBC_2_0);
Packit 6c4009
#  else
Packit 6c4009
compat_symbol (libc, strtod, strtold, GLIBC_2_0);
Packit 6c4009
compat_symbol (libc, __strtod_internal, __strtold_internal, GLIBC_2_0);
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if BUILD_DOUBLE
Packit 6c4009
# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
Packit 6c4009
#  undef strtof64
Packit 6c4009
#  undef wcstof64
Packit 6c4009
#  ifdef USE_WIDE_CHAR
Packit 6c4009
weak_alias (wcstod, wcstof64)
Packit 6c4009
#  else
Packit 6c4009
weak_alias (strtod, strtof64)
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
Packit 6c4009
#  undef strtof32x
Packit 6c4009
#  undef wcstof32x
Packit 6c4009
#  ifdef USE_WIDE_CHAR
Packit 6c4009
weak_alias (wcstod, wcstof32x)
Packit 6c4009
#  else
Packit 6c4009
weak_alias (strtod, strtof32x)
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#endif