1995-02-18 01:27:10 +00:00
|
|
|
|
/* Read decimal floating point numbers.
|
|
|
|
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
|
|
|
|
Contributed by Ulrich Drepper.
|
|
|
|
|
|
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
|
|
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
|
|
|
|
Cambridge, MA 02139, USA. */
|
|
|
|
|
|
|
|
|
|
/* Configuration part. These macros are defined by `strtold.c' and `strtof.c'
|
|
|
|
|
to produce the `long double' and `float' versions of the reader. */
|
|
|
|
|
#ifndef FLOAT
|
|
|
|
|
#define FLOAT double
|
|
|
|
|
#define FLT DBL
|
|
|
|
|
#define STRTOF strtod
|
|
|
|
|
#define MPN2FLOAT __mpn_construct_double
|
|
|
|
|
#define FLOAT_HUGE_VAL HUGE_VAL
|
|
|
|
|
#endif
|
|
|
|
|
/* End of configuration part. */
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <float.h>
|
Sun Mar 5 19:40:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/localeinfo.h: Rewritten for new locale system, using
locale data files and with <langinfo.h> interface.
* locale/setlocale.c: Rewritten to use locale data files.
* langinfo.h: New file.
* locale/langinfo.h: New file.
* locale/nl_langinfo.c: New file.
* locale/loadlocale.c: New file.
* locale/lc-ctype.c: New file.
* locale/lc-messages.c: New file.
* locale/lc-monetary.c: New file.
* locale/lc-numeric.c: New file.
* locale/lc-time.c: New file.
* locale/categories.def: New file.
* locale/Makefile (headers): Remove localeinfo.h.
(distribute): New variable; put localeinfo.h here, and categories.def.
(routines): Add loadlocale.
(categories): New variable.
(aux): Use that to get C-category and lc-category.
* ctype/ctype.h (_IS*): Use independent bits for all but _ISalnum.
* locale/C-ctype.c, locale/C-messages.c: New files.
* locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c:
Default "C" locale data updated for new locale system.
* locale/C-collate.c: File removed.
* locale/C-ctype_ct.c: File removed.
* locale/C-ctype_mb.c: File removed.
* locale/C-response.c: File removed.
* locale/localeconv.c: Use _NL_CURRENT macro to access locale data.
* stdio/printf_fp.c, stdio/vfprintf.c, stdio/vfscanf.c,
stdlib/strtod.c, time/asctime.c, time/strftime.c:
Include ../locale/localeinfo.h and use _NL_CURRENT macro to access
locale data.
* time/localtime.c: Don't include <localeinfo.h>.
* time/tzset.c: Don't use locale items for default TZ value or
"GMT" string (use "UTC").
* stdio/vfprintf.c [USE_IN_LIBIO] (PAD): Only call the function if
WIDTH>0; update DONE.
* malloc/malloc.c (morecore): Fix last change to calculate by
blocks instead of bytes.
1995-03-06 03:00:08 +00:00
|
|
|
|
#include "../locale/localeinfo.h"
|
1995-02-18 01:27:10 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
1995-03-21 07:58:50 +00:00
|
|
|
|
#include "gmp.h"
|
|
|
|
|
#include "gmp-impl.h"
|
1995-02-18 01:27:10 +00:00
|
|
|
|
#include <gmp-mparam.h>
|
1995-03-21 07:58:50 +00:00
|
|
|
|
#include "longlong.h"
|
|
|
|
|
#include "fpioconst.h"
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
#define NDEBUG 1
|
1995-02-18 01:27:10 +00:00
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Constants we need from float.h; select the set for the FLOAT precision. */
|
1995-02-20 09:50:50 +00:00
|
|
|
|
#define MANT_DIG PASTE(FLT,_MANT_DIG)
|
1995-03-02 10:00:12 +00:00
|
|
|
|
#define DIG PASTE(FLT,_DIG)
|
1995-02-20 09:50:50 +00:00
|
|
|
|
#define MAX_EXP PASTE(FLT,_MAX_EXP)
|
|
|
|
|
#define MIN_EXP PASTE(FLT,_MIN_EXP)
|
|
|
|
|
#define MAX_10_EXP PASTE(FLT,_MAX_10_EXP)
|
|
|
|
|
#define MIN_10_EXP PASTE(FLT,_MIN_10_EXP)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
1995-02-20 09:50:50 +00:00
|
|
|
|
/* Extra macros required to get FLT expanded before the pasting. */
|
|
|
|
|
#define PASTE(a,b) PASTE1(a,b)
|
|
|
|
|
#define PASTE1(a,b) a##b
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Function to construct a floating point number from an MP integer
|
|
|
|
|
containing the fraction bits, a base 2 exponent, and a sign flag. */
|
|
|
|
|
extern FLOAT MPN2FLOAT (mp_srcptr mpn, int exponent, int negative);
|
|
|
|
|
|
|
|
|
|
/* Definitions according to limb size used. */
|
|
|
|
|
#if BITS_PER_MP_LIMB == 32
|
|
|
|
|
# define MAX_DIG_PER_LIMB 9
|
|
|
|
|
# define MAX_FAC_PER_LIMB 1000000000L
|
|
|
|
|
#elif BITS_PER_MP_LIMB == 64
|
|
|
|
|
# define MAX_DIG_PER_LIMB 19
|
|
|
|
|
# define MAX_FAC_PER_LIMB 10000000000000000000L
|
|
|
|
|
#else
|
|
|
|
|
# error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Local data structure. */
|
1995-03-02 10:00:12 +00:00
|
|
|
|
static const mp_limb _tens_in_limb[MAX_DIG_PER_LIMB + 1] =
|
|
|
|
|
{ 0, 10, 100,
|
|
|
|
|
1000, 10000, 100000,
|
|
|
|
|
1000000, 10000000, 100000000,
|
|
|
|
|
1000000000
|
1995-02-18 01:27:10 +00:00
|
|
|
|
#if BITS_PER_MP_LIMB > 32
|
1995-03-02 10:00:12 +00:00
|
|
|
|
, 10000000000, 100000000000,
|
|
|
|
|
1000000000000, 10000000000000, 100000000000000,
|
|
|
|
|
1000000000000000, 10000000000000000, 100000000000000000,
|
|
|
|
|
1000000000000000000, 10000000000000000000
|
1995-02-18 01:27:10 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if BITS_PER_MP_LIMB > 64
|
|
|
|
|
#error "Need to expand tens_in_limb table to" MAX_DIG_PER_LIMB
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifndef howmany
|
|
|
|
|
#define howmany(x,y) (((x)+((y)-1))/(y))
|
|
|
|
|
#endif
|
|
|
|
|
#define SWAP(x, y) ({ typeof(x) _tmp = x; x = y; y = _tmp; })
|
|
|
|
|
|
|
|
|
|
#define NDIG (MAX_10_EXP - MIN_10_EXP + 2 * MANT_DIG)
|
|
|
|
|
#define RETURN_LIMB_SIZE howmany (MANT_DIG, BITS_PER_MP_LIMB)
|
|
|
|
|
|
|
|
|
|
#define RETURN(val,end) \
|
1995-03-17 17:15:40 +00:00
|
|
|
|
do { if (endptr != 0) *endptr = (char *) (end); return val; } while (0)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Maximum size necessary for mpn integers to hold floating point numbers. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
#define MPNSIZE (howmany (MAX_EXP + 2 * MANT_DIG, BITS_PER_MP_LIMB) \
|
|
|
|
|
+ 2)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Declare an mpn integer variable that big. */
|
|
|
|
|
#define MPN_VAR(name) mp_limb name[MPNSIZE]; mp_size_t name##size
|
|
|
|
|
/* Copy an mpn integer value. */
|
|
|
|
|
#define MPN_ASSIGN(dst, src) \
|
|
|
|
|
memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a floating point number of the needed type according to the given
|
|
|
|
|
multi-precision number after possible rounding. */
|
|
|
|
|
static inline FLOAT
|
|
|
|
|
round_and_return (mp_limb *retval, int exponent, int negative,
|
|
|
|
|
mp_limb round_limb, mp_size_t round_bit, int more_bits)
|
|
|
|
|
{
|
1995-03-17 17:15:40 +00:00
|
|
|
|
if (exponent < MIN_EXP - 1)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
1995-03-17 17:15:40 +00:00
|
|
|
|
mp_size_t shift = MIN_EXP - 1 - exponent;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
1995-03-17 17:15:40 +00:00
|
|
|
|
if (shift > MANT_DIG)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
errno = EDOM;
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
more_bits |= (round_limb & ((1 << round_bit) - 1)) != 0;
|
1995-03-17 17:15:40 +00:00
|
|
|
|
if (shift == MANT_DIG)
|
|
|
|
|
/* This is a special case to handle the very seldom case where
|
|
|
|
|
the mantissa will be empty after the shift. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
1995-03-17 17:15:40 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
round_limb = retval[RETURN_LIMB_SIZE - 1];
|
|
|
|
|
round_bit = BITS_PER_MP_LIMB - 1;
|
|
|
|
|
for (i = 0; i < RETURN_LIMB_SIZE; ++i)
|
|
|
|
|
more_bits |= retval[i] != 0;
|
|
|
|
|
MPN_ZERO (retval, RETURN_LIMB_SIZE);
|
|
|
|
|
}
|
|
|
|
|
else if (shift >= BITS_PER_MP_LIMB)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
round_limb = retval[(shift - 1) / BITS_PER_MP_LIMB];
|
|
|
|
|
round_bit = (shift - 1) % BITS_PER_MP_LIMB;
|
1995-03-17 17:15:40 +00:00
|
|
|
|
for (i = 0; i < (shift - 1) / BITS_PER_MP_LIMB; ++i)
|
|
|
|
|
more_bits |= retval[i] != 0;
|
|
|
|
|
more_bits |= (round_limb & ((1 << round_bit) - 1)) != 0;
|
1995-03-02 10:00:12 +00:00
|
|
|
|
|
|
|
|
|
(void) __mpn_rshift (retval, &retval[shift / BITS_PER_MP_LIMB],
|
|
|
|
|
RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB),
|
|
|
|
|
shift % BITS_PER_MP_LIMB);
|
|
|
|
|
MPN_ZERO (&retval[RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB)],
|
|
|
|
|
shift / BITS_PER_MP_LIMB);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
1995-03-02 10:00:12 +00:00
|
|
|
|
else if (shift > 0)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
round_limb = retval[0];
|
|
|
|
|
round_bit = shift - 1;
|
1995-03-02 10:00:12 +00:00
|
|
|
|
(void) __mpn_rshift (retval, retval, RETURN_LIMB_SIZE, shift);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
exponent = MIN_EXP - 2;
|
|
|
|
|
}
|
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
if ((round_limb & (1 << round_bit)) != 0
|
|
|
|
|
&& (more_bits || (retval[0] & 1) != 0
|
|
|
|
|
|| (round_limb & ((1 << round_bit) - 1)) != 0))
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
mp_limb cy = __mpn_add_1 (retval, retval, RETURN_LIMB_SIZE, 1);
|
1995-03-02 10:00:12 +00:00
|
|
|
|
|
|
|
|
|
if (((MANT_DIG % BITS_PER_MP_LIMB) == 0 && cy) ||
|
|
|
|
|
((MANT_DIG % BITS_PER_MP_LIMB) != 0 &&
|
|
|
|
|
(retval[RETURN_LIMB_SIZE - 1]
|
|
|
|
|
& (1 << (MANT_DIG % BITS_PER_MP_LIMB))) != 0))
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
++exponent;
|
|
|
|
|
(void) __mpn_rshift (retval, retval, RETURN_LIMB_SIZE, 1);
|
1995-03-02 10:00:12 +00:00
|
|
|
|
retval[RETURN_LIMB_SIZE - 1] |= 1 << ((MANT_DIG - 1)
|
|
|
|
|
% BITS_PER_MP_LIMB);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
1995-03-17 17:15:40 +00:00
|
|
|
|
else if (exponent == MIN_EXP - 2
|
1995-03-02 10:00:12 +00:00
|
|
|
|
&& (retval[RETURN_LIMB_SIZE - 1]
|
|
|
|
|
& (1 << ((MANT_DIG - 1) % BITS_PER_MP_LIMB))) != 0)
|
|
|
|
|
/* The number was denormalized but now normalized. */
|
|
|
|
|
exponent = MIN_EXP - 1;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exponent > MAX_EXP)
|
|
|
|
|
return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
|
|
|
|
|
|
|
|
|
|
return MPN2FLOAT (retval, exponent, negative);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Read a multi-precision integer starting at STR with exactly DIGCNT digits
|
|
|
|
|
into N. Return the size of the number limbs in NSIZE at the first
|
|
|
|
|
character od the string that is not part of the integer as the function
|
|
|
|
|
value. If the EXPONENT is small enough to be taken as an additional
|
|
|
|
|
factor for the resulting number (see code) multiply by it. */
|
|
|
|
|
static inline const char *
|
|
|
|
|
str_to_mpn (const char *str, int digcnt, mp_limb *n, mp_size_t *nsize,
|
|
|
|
|
int *exponent)
|
|
|
|
|
{
|
|
|
|
|
/* Number of digits for actual limb. */
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
mp_limb low = 0;
|
|
|
|
|
mp_limb base;
|
|
|
|
|
|
|
|
|
|
*nsize = 0;
|
|
|
|
|
assert (digcnt > 0);
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if (cnt == MAX_DIG_PER_LIMB)
|
|
|
|
|
{
|
|
|
|
|
if (*nsize == 0)
|
|
|
|
|
n[0] = low;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mp_limb cy;
|
|
|
|
|
cy = __mpn_mul_1 (n, n, *nsize, MAX_FAC_PER_LIMB);
|
|
|
|
|
cy += __mpn_add_1 (n, n, *nsize, low);
|
|
|
|
|
if (cy != 0)
|
|
|
|
|
n[*nsize] = cy;
|
|
|
|
|
}
|
|
|
|
|
++(*nsize);
|
|
|
|
|
cnt = 0;
|
|
|
|
|
low = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There might be thousands separators or radix characters in the string.
|
|
|
|
|
But these all can be ignored because we know the format of the number
|
|
|
|
|
is correct and we have an exact number of characters to read. */
|
|
|
|
|
while (!isdigit (*str))
|
|
|
|
|
++str;
|
|
|
|
|
low = low * 10 + *str++ - '0';
|
|
|
|
|
++cnt;
|
|
|
|
|
}
|
|
|
|
|
while (--digcnt > 0);
|
|
|
|
|
|
|
|
|
|
if (*exponent > 0 && cnt + *exponent <= MAX_DIG_PER_LIMB)
|
|
|
|
|
{
|
|
|
|
|
low *= _tens_in_limb[*exponent];
|
|
|
|
|
base = _tens_in_limb[cnt + *exponent];
|
|
|
|
|
*exponent = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
base = _tens_in_limb[cnt];
|
|
|
|
|
|
|
|
|
|
if (*nsize == 0)
|
|
|
|
|
{
|
|
|
|
|
n[0] = low;
|
|
|
|
|
*nsize = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mp_limb cy;
|
|
|
|
|
cy = __mpn_mul_1 (n, n, *nsize, base);
|
|
|
|
|
cy += __mpn_add_1 (n, n, *nsize, low);
|
|
|
|
|
if (cy != 0)
|
|
|
|
|
n[(*nsize)++] = cy;
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Shift {PTR, SIZE} COUNT bits to the left, and fill the vacated bits
|
|
|
|
|
with the COUNT most significant bits of LIMB.
|
|
|
|
|
|
|
|
|
|
Tege doesn't like this function so I have to write it here myself. :)
|
|
|
|
|
--drepper */
|
|
|
|
|
static inline void
|
|
|
|
|
__mpn_lshift_1 (mp_limb *ptr, mp_size_t size, unsigned int count, mp_limb limb)
|
|
|
|
|
{
|
|
|
|
|
if (count == BITS_PER_MP_LIMB)
|
|
|
|
|
{
|
|
|
|
|
/* Optimize the case of shifting by exactly a word:
|
|
|
|
|
just copy words, with no actual bit-shifting. */
|
|
|
|
|
mp_size_t i;
|
|
|
|
|
for (i = size - 1; i > 0; --i)
|
|
|
|
|
ptr[i] = ptr[i - 1];
|
|
|
|
|
ptr[0] = limb;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(void) __mpn_lshift (ptr, ptr, size, count);
|
|
|
|
|
ptr[0] |= limb >> (BITS_PER_MP_LIMB - count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
#define INTERNAL(x) INTERNAL1(x)
|
|
|
|
|
#define INTERNAL1(x) __##x##_internal
|
|
|
|
|
|
|
|
|
|
/* This file defines a function to check for correct grouping. */
|
|
|
|
|
#include "grouping.h"
|
|
|
|
|
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Return a floating point number with the value of the given string NPTR.
|
|
|
|
|
Set *ENDPTR to the character after the last used one. If the number is
|
|
|
|
|
smaller than the smallest representable number, set `errno' to ERANGE and
|
|
|
|
|
return 0.0. If the number is too big to be represented, set `errno' to
|
|
|
|
|
ERANGE and return HUGE_VAL with the approriate sign. */
|
|
|
|
|
FLOAT
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
INTERNAL (STRTOF) (nptr, endptr, group)
|
|
|
|
|
const char *nptr;
|
|
|
|
|
char **endptr;
|
|
|
|
|
int group;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
int negative; /* The sign of the number. */
|
|
|
|
|
MPN_VAR (num); /* MP representation of the number. */
|
|
|
|
|
int exponent; /* Exponent of the number. */
|
|
|
|
|
|
|
|
|
|
/* When we have to compute fractional digits we form a fraction with a
|
|
|
|
|
second multi-precision number (and we sometimes need a second for
|
|
|
|
|
temporary results). */
|
|
|
|
|
MPN_VAR (den);
|
|
|
|
|
|
|
|
|
|
/* Representation for the return value. */
|
|
|
|
|
mp_limb retval[RETURN_LIMB_SIZE];
|
|
|
|
|
/* Number of bits currently in result value. */
|
|
|
|
|
int bits;
|
|
|
|
|
|
|
|
|
|
/* Running pointer after the last character processed in the string. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
const char *cp, *tp;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Start of significant part of the number. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
const char *startp, *start_of_digits;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Points at the character following the integer and fractional digits. */
|
|
|
|
|
const char *expp;
|
|
|
|
|
/* Total number of digit and number of digits in integer part. */
|
1995-03-02 10:00:12 +00:00
|
|
|
|
int dig_no, int_no, lead_zero;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Contains the last character read. */
|
|
|
|
|
char c;
|
|
|
|
|
|
|
|
|
|
/* The radix character of the current locale. */
|
|
|
|
|
wchar_t decimal;
|
|
|
|
|
/* The thousands character of the current locale. */
|
|
|
|
|
wchar_t thousands;
|
|
|
|
|
/* The numeric grouping specification of the current locale,
|
|
|
|
|
in the format described in <locale.h>. */
|
|
|
|
|
const char *grouping;
|
|
|
|
|
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
if (group)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
|
|
|
|
if (*grouping <= 0 || *grouping == CHAR_MAX)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
grouping = NULL;
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Figure out the thousands separator character. */
|
|
|
|
|
if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
|
|
|
|
|
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
|
|
|
|
|
thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
|
|
|
|
|
if (thousands == L'\0')
|
|
|
|
|
grouping = NULL;
|
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
else
|
|
|
|
|
grouping = NULL;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Find the locale's decimal point character. */
|
Sun Mar 5 19:40:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/localeinfo.h: Rewritten for new locale system, using
locale data files and with <langinfo.h> interface.
* locale/setlocale.c: Rewritten to use locale data files.
* langinfo.h: New file.
* locale/langinfo.h: New file.
* locale/nl_langinfo.c: New file.
* locale/loadlocale.c: New file.
* locale/lc-ctype.c: New file.
* locale/lc-messages.c: New file.
* locale/lc-monetary.c: New file.
* locale/lc-numeric.c: New file.
* locale/lc-time.c: New file.
* locale/categories.def: New file.
* locale/Makefile (headers): Remove localeinfo.h.
(distribute): New variable; put localeinfo.h here, and categories.def.
(routines): Add loadlocale.
(categories): New variable.
(aux): Use that to get C-category and lc-category.
* ctype/ctype.h (_IS*): Use independent bits for all but _ISalnum.
* locale/C-ctype.c, locale/C-messages.c: New files.
* locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c:
Default "C" locale data updated for new locale system.
* locale/C-collate.c: File removed.
* locale/C-ctype_ct.c: File removed.
* locale/C-ctype_mb.c: File removed.
* locale/C-response.c: File removed.
* locale/localeconv.c: Use _NL_CURRENT macro to access locale data.
* stdio/printf_fp.c, stdio/vfprintf.c, stdio/vfscanf.c,
stdlib/strtod.c, time/asctime.c, time/strftime.c:
Include ../locale/localeinfo.h and use _NL_CURRENT macro to access
locale data.
* time/localtime.c: Don't include <localeinfo.h>.
* time/tzset.c: Don't use locale items for default TZ value or
"GMT" string (use "UTC").
* stdio/vfprintf.c [USE_IN_LIBIO] (PAD): Only call the function if
WIDTH>0; update DONE.
* malloc/malloc.c (morecore): Fix last change to calculate by
blocks instead of bytes.
1995-03-06 03:00:08 +00:00
|
|
|
|
if (mbtowc (&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
|
|
|
|
|
strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0)
|
|
|
|
|
decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Prepare number representation. */
|
|
|
|
|
exponent = 0;
|
|
|
|
|
negative = 0;
|
|
|
|
|
bits = 0;
|
|
|
|
|
|
|
|
|
|
/* Parse string to get maximal legal prefix. We need the number of
|
|
|
|
|
characters of the interger part, the fractional part and the exponent. */
|
|
|
|
|
cp = nptr - 1;
|
|
|
|
|
/* Ignore leading white space. */
|
|
|
|
|
do
|
|
|
|
|
c = *++cp;
|
|
|
|
|
while (isspace (c));
|
|
|
|
|
|
|
|
|
|
/* Get sign of the result. */
|
|
|
|
|
if (c == '-')
|
|
|
|
|
{
|
|
|
|
|
negative = 1;
|
|
|
|
|
c = *++cp;
|
|
|
|
|
}
|
|
|
|
|
else if (c == '+')
|
|
|
|
|
c = *++cp;
|
|
|
|
|
|
|
|
|
|
/* Return 0.0 if no legal string is found.
|
|
|
|
|
No character is used even if a sign was found. */
|
1995-02-21 06:02:58 +00:00
|
|
|
|
if (!isdigit (c) && (c != decimal || !isdigit (cp[1])))
|
1995-02-18 01:27:10 +00:00
|
|
|
|
RETURN (0.0, nptr);
|
|
|
|
|
|
|
|
|
|
/* Record the start of the digits, in case we will check their grouping. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
start_of_digits = startp = cp;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Ignore leading zeroes. This helps us to avoid useless computations. */
|
|
|
|
|
while (c == '0' || (thousands != L'\0' && c == thousands))
|
|
|
|
|
c = *++cp;
|
|
|
|
|
|
|
|
|
|
/* If no other digit but a '0' is found the result is 0.0.
|
|
|
|
|
Return current read pointer. */
|
|
|
|
|
if (!isdigit (c) && c != decimal)
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
{
|
1995-03-17 17:40:02 +00:00
|
|
|
|
tp = correctly_grouped_prefix (start_of_digits, cp, thousands, grouping);
|
|
|
|
|
/* If TP is at the start of the digits, there was no correctly
|
|
|
|
|
grouped prefix of the string; so no number found. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
RETURN (0.0, tp == start_of_digits ? nptr : tp);
|
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Remember first significant digit and read following characters until the
|
|
|
|
|
decimal point, exponent character or any non-FP number character. */
|
|
|
|
|
startp = cp;
|
|
|
|
|
dig_no = 0;
|
|
|
|
|
while (dig_no < NDIG ||
|
|
|
|
|
/* If parsing grouping info, keep going past useful digits
|
|
|
|
|
so we can check all the grouping separators. */
|
|
|
|
|
grouping)
|
|
|
|
|
{
|
|
|
|
|
if (isdigit (c))
|
|
|
|
|
++dig_no;
|
|
|
|
|
else if (thousands == L'\0' || c != thousands)
|
|
|
|
|
/* Not a digit or separator: end of the integer part. */
|
|
|
|
|
break;
|
|
|
|
|
c = *++cp;
|
|
|
|
|
}
|
|
|
|
|
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
if (grouping && dig_no > 0)
|
|
|
|
|
{
|
|
|
|
|
/* Check the grouping of the digits. */
|
|
|
|
|
tp = correctly_grouped_prefix (start_of_digits, cp, thousands, grouping);
|
|
|
|
|
if (cp != tp)
|
1995-03-17 17:15:40 +00:00
|
|
|
|
{
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
/* Less than the entire string was correctly grouped. */
|
|
|
|
|
|
|
|
|
|
if (tp == start_of_digits)
|
|
|
|
|
/* No valid group of numbers at all: no valid number. */
|
|
|
|
|
RETURN (0.0, nptr);
|
|
|
|
|
|
|
|
|
|
if (tp < startp)
|
|
|
|
|
/* The number is validly grouped, but consists
|
|
|
|
|
only of zeroes. The whole value is zero. */
|
|
|
|
|
RETURN (0.0, tp);
|
|
|
|
|
|
|
|
|
|
/* Recompute DIG_NO so we won't read more digits than
|
|
|
|
|
are properly grouped. */
|
|
|
|
|
cp = tp;
|
|
|
|
|
dig_no = 0;
|
|
|
|
|
for (tp = startp; tp < cp; ++tp)
|
|
|
|
|
if (isdigit (*tp))
|
|
|
|
|
++dig_no;
|
|
|
|
|
|
|
|
|
|
int_no = dig_no;
|
|
|
|
|
lead_zero = 0;
|
|
|
|
|
|
|
|
|
|
goto number_parsed;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
if (dig_no >= NDIG)
|
|
|
|
|
/* Too many digits to be representable. Assigning this to EXPONENT
|
|
|
|
|
allows us to read the full number but return HUGE_VAL after parsing. */
|
|
|
|
|
exponent = MAX_10_EXP;
|
|
|
|
|
|
|
|
|
|
/* We have the number digits in the integer part. Whether these are all or
|
|
|
|
|
any is really a fractional digit will be decided later. */
|
|
|
|
|
int_no = dig_no;
|
1995-03-02 10:00:12 +00:00
|
|
|
|
lead_zero = int_no == 0 ? -1 : 0;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Read the fractional digits. */
|
|
|
|
|
if (c == decimal)
|
|
|
|
|
{
|
|
|
|
|
if (isdigit (cp[1]))
|
|
|
|
|
{
|
1995-03-02 10:00:12 +00:00
|
|
|
|
c = *++cp;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
1995-03-02 10:00:12 +00:00
|
|
|
|
if (c != '0' && lead_zero == -1)
|
|
|
|
|
lead_zero = dig_no - int_no;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
++dig_no;
|
|
|
|
|
c = *++cp;
|
|
|
|
|
}
|
|
|
|
|
while (isdigit (c));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remember start of exponent (if any). */
|
|
|
|
|
expp = cp;
|
|
|
|
|
|
|
|
|
|
/* Read exponent. */
|
|
|
|
|
if (tolower (c) == 'e')
|
|
|
|
|
{
|
|
|
|
|
int exp_negative = 0;
|
|
|
|
|
|
|
|
|
|
c = *++cp;
|
|
|
|
|
if (c == '-')
|
|
|
|
|
{
|
|
|
|
|
exp_negative = 1;
|
|
|
|
|
c = *++cp;
|
|
|
|
|
}
|
|
|
|
|
else if (c == '+')
|
|
|
|
|
c = *++cp;
|
|
|
|
|
|
|
|
|
|
if (isdigit (c))
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if ((!exp_negative && exponent * 10 + int_no > MAX_10_EXP)
|
|
|
|
|
|| (exp_negative
|
|
|
|
|
&& exponent * 10 + int_no > -MIN_10_EXP + MANT_DIG))
|
|
|
|
|
/* The exponent is too large/small to represent a valid
|
|
|
|
|
number. */
|
|
|
|
|
{
|
|
|
|
|
FLOAT retval;
|
|
|
|
|
|
|
|
|
|
/* Overflow or underflow. */
|
|
|
|
|
errno = ERANGE;
|
|
|
|
|
retval = (exp_negative ? 0.0 :
|
|
|
|
|
negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL);
|
|
|
|
|
|
|
|
|
|
/* Accept all following digits as part of the exponent. */
|
|
|
|
|
do
|
|
|
|
|
++cp;
|
|
|
|
|
while (isdigit (*cp));
|
|
|
|
|
|
|
|
|
|
RETURN (retval, cp);
|
|
|
|
|
/* NOTREACHED */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exponent *= 10;
|
|
|
|
|
exponent += c - '0';
|
|
|
|
|
c = *++cp;
|
|
|
|
|
}
|
|
|
|
|
while (isdigit (c));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cp = expp;
|
|
|
|
|
|
|
|
|
|
if (exp_negative)
|
|
|
|
|
exponent = -exponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We don't want to have to work with trailing zeroes after the radix. */
|
|
|
|
|
if (dig_no > int_no)
|
|
|
|
|
{
|
|
|
|
|
while (expp[-1] == '0')
|
|
|
|
|
{
|
|
|
|
|
--expp;
|
|
|
|
|
--dig_no;
|
|
|
|
|
}
|
|
|
|
|
assert (dig_no >= int_no);
|
|
|
|
|
}
|
|
|
|
|
|
1995-03-17 17:40:02 +00:00
|
|
|
|
number_parsed:
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* The whole string is parsed. Store the address of the next character. */
|
|
|
|
|
if (endptr)
|
|
|
|
|
*endptr = (char *) cp;
|
|
|
|
|
|
|
|
|
|
if (dig_no == 0)
|
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
|
|
/* Now we have the number of digits in total and the integer digits as well
|
|
|
|
|
as the exponent and its sign. We can decide whether the read digits are
|
|
|
|
|
really integer digits or belong to the fractional part; i.e. we normalize
|
|
|
|
|
123e-2 to 1.23. */
|
|
|
|
|
{
|
|
|
|
|
register int incr = exponent < 0 ? MAX (-int_no, exponent)
|
|
|
|
|
: MIN (dig_no - int_no, exponent);
|
|
|
|
|
int_no += incr;
|
|
|
|
|
exponent -= incr;
|
|
|
|
|
}
|
|
|
|
|
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
if (int_no + exponent > MAX_10_EXP + 1)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
errno = ERANGE;
|
|
|
|
|
return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
|
|
|
|
|
}
|
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
if (exponent - MAX(0, lead_zero) < MIN_10_EXP - (DIG + 1))
|
1995-02-18 01:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
errno = ERANGE;
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (int_no > 0)
|
|
|
|
|
{
|
|
|
|
|
/* Read the integer part as a multi-precision number to NUM. */
|
|
|
|
|
startp = str_to_mpn (startp, int_no, num, &numsize, &exponent);
|
|
|
|
|
|
|
|
|
|
if (exponent > 0)
|
|
|
|
|
{
|
|
|
|
|
/* We now multiply the gained number by the given power of ten. */
|
|
|
|
|
mp_limb *psrc = num;
|
|
|
|
|
mp_limb *pdest = den;
|
|
|
|
|
int expbit = 1;
|
|
|
|
|
const struct mp_power *ttab = &_fpioconst_pow10[0];
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if ((exponent & expbit) != 0)
|
|
|
|
|
{
|
|
|
|
|
mp_limb cy;
|
|
|
|
|
exponent ^= expbit;
|
|
|
|
|
|
|
|
|
|
/* FIXME: not the whole multiplication has to be done.
|
|
|
|
|
If we have the needed number of bits we only need the
|
|
|
|
|
information whether more non-zero bits follow. */
|
|
|
|
|
if (numsize >= ttab->arraysize - 2)
|
|
|
|
|
cy = __mpn_mul (pdest, psrc, numsize,
|
|
|
|
|
&ttab->array[2], ttab->arraysize - 2);
|
|
|
|
|
else
|
|
|
|
|
cy = __mpn_mul (pdest, &ttab->array[2],
|
|
|
|
|
ttab->arraysize - 2,
|
|
|
|
|
psrc, numsize);
|
|
|
|
|
numsize += ttab->arraysize - 2;
|
|
|
|
|
if (cy == 0)
|
|
|
|
|
--numsize;
|
|
|
|
|
SWAP (psrc, pdest);
|
|
|
|
|
}
|
|
|
|
|
expbit <<= 1;
|
|
|
|
|
++ttab;
|
|
|
|
|
}
|
|
|
|
|
while (exponent != 0);
|
|
|
|
|
|
|
|
|
|
if (psrc == den)
|
|
|
|
|
memcpy (num, den, numsize * sizeof (mp_limb));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Determine how many bits of the result we already have. */
|
|
|
|
|
count_leading_zeros (bits, num[numsize - 1]);
|
|
|
|
|
bits = numsize * BITS_PER_MP_LIMB - bits;
|
|
|
|
|
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
/* Now we know the exponent of the number in base two.
|
|
|
|
|
Check it against the maximum possible exponent. */
|
|
|
|
|
if (bits > MAX_EXP)
|
|
|
|
|
{
|
|
|
|
|
errno = ERANGE;
|
|
|
|
|
return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* We have already the first BITS bits of the result. Together with
|
|
|
|
|
the information whether more non-zero bits follow this is enough
|
|
|
|
|
to determine the result. */
|
|
|
|
|
if (bits > MANT_DIG)
|
|
|
|
|
{
|
1995-03-02 10:00:12 +00:00
|
|
|
|
int i;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
const mp_size_t least_idx = (bits - MANT_DIG) / BITS_PER_MP_LIMB;
|
|
|
|
|
const mp_size_t least_bit = (bits - MANT_DIG) % BITS_PER_MP_LIMB;
|
|
|
|
|
const mp_size_t round_idx = least_bit == 0 ? least_idx - 1
|
|
|
|
|
: least_idx;
|
|
|
|
|
const mp_size_t round_bit = least_bit == 0 ? BITS_PER_MP_LIMB - 1
|
1995-03-02 10:00:12 +00:00
|
|
|
|
: least_bit - 1;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
if (least_bit == 0)
|
|
|
|
|
memcpy (retval, &num[least_idx],
|
|
|
|
|
RETURN_LIMB_SIZE * sizeof (mp_limb));
|
|
|
|
|
else
|
1995-03-02 10:00:12 +00:00
|
|
|
|
{
|
|
|
|
|
for (i = least_idx; i < numsize - 1; ++i)
|
|
|
|
|
retval[i - least_idx] = (num[i] >> least_bit)
|
|
|
|
|
| (num[i + 1]
|
|
|
|
|
<< (BITS_PER_MP_LIMB - least_bit));
|
|
|
|
|
if (i - least_idx < RETURN_LIMB_SIZE)
|
|
|
|
|
retval[RETURN_LIMB_SIZE - 1] = num[i] >> least_bit;
|
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
/* Check whether any limb beside the ones in RETVAL are non-zero. */
|
|
|
|
|
for (i = 0; num[i] == 0; ++i)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
return round_and_return (retval, bits - 1, negative,
|
|
|
|
|
num[round_idx], round_bit,
|
|
|
|
|
int_no < dig_no || i < round_idx);
|
|
|
|
|
/* NOTREACHED */
|
|
|
|
|
}
|
|
|
|
|
else if (dig_no == int_no)
|
|
|
|
|
{
|
|
|
|
|
const mp_size_t target_bit = (MANT_DIG - 1) % BITS_PER_MP_LIMB;
|
|
|
|
|
const mp_size_t is_bit = (bits - 1) % BITS_PER_MP_LIMB;
|
|
|
|
|
|
|
|
|
|
if (target_bit == is_bit)
|
|
|
|
|
{
|
|
|
|
|
memcpy (&retval[RETURN_LIMB_SIZE - numsize], num,
|
|
|
|
|
numsize * sizeof (mp_limb));
|
|
|
|
|
/* FIXME: the following loop can be avoided if we assume a
|
|
|
|
|
maximal MANT_DIG value. */
|
|
|
|
|
MPN_ZERO (retval, RETURN_LIMB_SIZE - numsize);
|
|
|
|
|
}
|
|
|
|
|
else if (target_bit > is_bit)
|
|
|
|
|
{
|
|
|
|
|
(void) __mpn_lshift (&retval[RETURN_LIMB_SIZE - numsize],
|
|
|
|
|
num, numsize, target_bit - is_bit);
|
|
|
|
|
/* FIXME: the following loop can be avoided if we assume a
|
|
|
|
|
maximal MANT_DIG value. */
|
|
|
|
|
MPN_ZERO (retval, RETURN_LIMB_SIZE - numsize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mp_limb cy;
|
|
|
|
|
assert (numsize < RETURN_LIMB_SIZE);
|
|
|
|
|
|
|
|
|
|
cy = __mpn_rshift (&retval[RETURN_LIMB_SIZE - numsize],
|
|
|
|
|
num, numsize, is_bit - target_bit);
|
|
|
|
|
retval[RETURN_LIMB_SIZE - numsize - 1] = cy;
|
|
|
|
|
/* FIXME: the following loop can be avoided if we assume a
|
|
|
|
|
maximal MANT_DIG value. */
|
|
|
|
|
MPN_ZERO (retval, RETURN_LIMB_SIZE - numsize - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return round_and_return (retval, bits - 1, negative, 0, 0, 0);
|
|
|
|
|
/* NOTREACHED */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store the bits we already have. */
|
|
|
|
|
memcpy (retval, num, numsize * sizeof (mp_limb));
|
|
|
|
|
#if RETURN_LIMB_SIZE > 1
|
|
|
|
|
if (numsize < RETURN_LIMB_SIZE)
|
|
|
|
|
retval[numsize] = 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We have to compute at least some of the fractional digits. */
|
|
|
|
|
{
|
|
|
|
|
/* We construct a fraction and the result of the division gives us
|
|
|
|
|
the needed digits. The denominator is 1.0 multiplied by the
|
|
|
|
|
exponent of the lowest digit; i.e. 0.123 gives 123 / 1000 and
|
|
|
|
|
123e6 gives 123 / 1000000. */
|
|
|
|
|
|
|
|
|
|
int expbit;
|
|
|
|
|
int cnt;
|
1995-03-02 10:00:12 +00:00
|
|
|
|
int neg_exp;
|
|
|
|
|
int more_bits;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
mp_limb cy;
|
|
|
|
|
mp_limb *psrc = den;
|
|
|
|
|
mp_limb *pdest = num;
|
|
|
|
|
const struct mp_power *ttab = &_fpioconst_pow10[0];
|
|
|
|
|
|
|
|
|
|
assert (dig_no > int_no && exponent <= 0);
|
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
|
|
|
|
|
/* For the fractional part we need not process too much digits. One
|
|
|
|
|
decimal digits gives us log_2(10) ~ 3.32 bits. If we now compute
|
|
|
|
|
ceil(BITS / 3) =: N
|
|
|
|
|
digits we should have enough bits for the result. The remaining
|
|
|
|
|
decimal digits give us the information that more bits are following.
|
|
|
|
|
This can be used while rounding. (One added as a safety margin.) */
|
1995-09-28 09:20:04 +00:00
|
|
|
|
if (dig_no - int_no - lead_zero > (MANT_DIG - bits + 2) / 3 + 1)
|
1995-03-02 10:00:12 +00:00
|
|
|
|
{
|
1995-09-28 09:20:04 +00:00
|
|
|
|
dig_no = int_no + lead_zero + (MANT_DIG - bits + 2) / 3 + 1;
|
1995-03-02 10:00:12 +00:00
|
|
|
|
more_bits = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
more_bits = 0;
|
|
|
|
|
|
|
|
|
|
neg_exp = dig_no - int_no - exponent;
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Construct the denominator. */
|
|
|
|
|
densize = 0;
|
|
|
|
|
expbit = 1;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if ((neg_exp & expbit) != 0)
|
|
|
|
|
{
|
|
|
|
|
mp_limb cy;
|
|
|
|
|
neg_exp ^= expbit;
|
|
|
|
|
|
|
|
|
|
if (densize == 0)
|
|
|
|
|
memcpy (psrc, &ttab->array[2],
|
|
|
|
|
(densize = ttab->arraysize - 2) * sizeof (mp_limb));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cy = __mpn_mul (pdest, &ttab->array[2], ttab->arraysize - 2,
|
|
|
|
|
psrc, densize);
|
|
|
|
|
densize += ttab->arraysize - 2;
|
|
|
|
|
if (cy == 0)
|
|
|
|
|
--densize;
|
|
|
|
|
SWAP (psrc, pdest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expbit <<= 1;
|
|
|
|
|
++ttab;
|
|
|
|
|
}
|
|
|
|
|
while (neg_exp != 0);
|
|
|
|
|
|
|
|
|
|
if (psrc == num)
|
|
|
|
|
memcpy (den, num, densize * sizeof (mp_limb));
|
|
|
|
|
|
1995-09-28 09:20:04 +00:00
|
|
|
|
/* If we have leading zeroes now reduce the number of significant digits
|
|
|
|
|
and set the pointer to the first non-0 digit. */
|
|
|
|
|
if (lead_zero > 0)
|
|
|
|
|
{
|
|
|
|
|
startp += lead_zero + 1; /* +1 for radix character */
|
|
|
|
|
dig_no -= lead_zero;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
/* Read the fractional digits from the string. */
|
|
|
|
|
(void) str_to_mpn (startp, dig_no - int_no, num, &numsize, &exponent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We now have to shift both numbers so that the highest bit in the
|
|
|
|
|
denominator is set. In the same process we copy the numerator to
|
|
|
|
|
a high place in the array so that the division constructs the wanted
|
|
|
|
|
digits. This is done by a "quasi fix point" number representation.
|
|
|
|
|
|
|
|
|
|
num: ddddddddddd . 0000000000000000000000
|
|
|
|
|
|--- m ---|
|
|
|
|
|
den: ddddddddddd n >= m
|
|
|
|
|
|--- n ---|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
count_leading_zeros (cnt, den[densize - 1]);
|
|
|
|
|
|
|
|
|
|
(void) __mpn_lshift (den, den, densize, cnt);
|
|
|
|
|
cy = __mpn_lshift (num, num, numsize, cnt);
|
|
|
|
|
if (cy != 0)
|
|
|
|
|
num[numsize++] = cy;
|
|
|
|
|
|
|
|
|
|
/* Now we are ready for the division. But it is not necessary to
|
|
|
|
|
do a full multi-precision division because we only need a small
|
|
|
|
|
number of bits for the result. So we do not use __mpn_divmod
|
|
|
|
|
here but instead do the division here by hand and stop whenever
|
|
|
|
|
the needed number of bits is reached. The code itself comes
|
|
|
|
|
from the GNU MP Library by Torbj\"orn Granlund. */
|
|
|
|
|
|
|
|
|
|
exponent = bits;
|
|
|
|
|
|
|
|
|
|
switch (densize)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
mp_limb d, n, quot;
|
|
|
|
|
int used = 0;
|
|
|
|
|
|
|
|
|
|
n = num[0];
|
|
|
|
|
d = den[0];
|
|
|
|
|
assert (numsize == 1 && n < d);
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
udiv_qrnnd (quot, n, n, 0, d);
|
|
|
|
|
|
|
|
|
|
#define got_limb \
|
|
|
|
|
if (bits == 0) \
|
|
|
|
|
{ \
|
|
|
|
|
register int cnt; \
|
|
|
|
|
if (quot == 0) \
|
|
|
|
|
cnt = BITS_PER_MP_LIMB; \
|
|
|
|
|
else \
|
|
|
|
|
count_leading_zeros (cnt, quot); \
|
|
|
|
|
exponent -= cnt; \
|
|
|
|
|
if (BITS_PER_MP_LIMB - cnt > MANT_DIG) \
|
|
|
|
|
{ \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
used = MANT_DIG + cnt; \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
retval[0] = quot >> (BITS_PER_MP_LIMB - used); \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
bits = MANT_DIG + 1; \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
/* Note that we only clear the second element. */ \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
/* The conditional is determined at compile time. */ \
|
|
|
|
|
if (RETURN_LIMB_SIZE > 1) \
|
|
|
|
|
retval[1] = 0; \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
retval[0] = quot; \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
bits = -cnt; \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else if (bits + BITS_PER_MP_LIMB <= MANT_DIG) \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE, BITS_PER_MP_LIMB, \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
quot); \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
used = MANT_DIG - bits; \
|
|
|
|
|
if (used > 0) \
|
1995-03-02 10:00:12 +00:00
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE, used, quot); \
|
1995-02-18 01:27:10 +00:00
|
|
|
|
} \
|
|
|
|
|
bits += BITS_PER_MP_LIMB
|
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
got_limb;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
while (bits <= MANT_DIG);
|
|
|
|
|
|
|
|
|
|
return round_and_return (retval, exponent - 1, negative,
|
|
|
|
|
quot, BITS_PER_MP_LIMB - 1 - used,
|
1995-03-02 10:00:12 +00:00
|
|
|
|
more_bits || n != 0);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
mp_limb d0, d1, n0, n1;
|
|
|
|
|
mp_limb quot = 0;
|
|
|
|
|
int used = 0;
|
|
|
|
|
|
|
|
|
|
d0 = den[0];
|
|
|
|
|
d1 = den[1];
|
|
|
|
|
|
|
|
|
|
if (numsize < densize)
|
|
|
|
|
{
|
|
|
|
|
if (bits <= 0)
|
|
|
|
|
exponent -= BITS_PER_MP_LIMB;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (bits + BITS_PER_MP_LIMB <= MANT_DIG)
|
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE,
|
|
|
|
|
BITS_PER_MP_LIMB, 0);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
used = MANT_DIG - bits;
|
|
|
|
|
if (used > 0)
|
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE, used, 0);
|
|
|
|
|
}
|
|
|
|
|
bits += BITS_PER_MP_LIMB;
|
|
|
|
|
}
|
|
|
|
|
n1 = num[0];
|
|
|
|
|
n0 = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
n1 = num[1];
|
|
|
|
|
n0 = num[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (bits <= MANT_DIG)
|
|
|
|
|
{
|
|
|
|
|
mp_limb r;
|
|
|
|
|
|
|
|
|
|
if (n1 == d1)
|
|
|
|
|
{
|
|
|
|
|
/* QUOT should be either 111..111 or 111..110. We need
|
|
|
|
|
special treatment of this rare case as normal division
|
|
|
|
|
would give overflow. */
|
|
|
|
|
quot = ~(mp_limb) 0;
|
|
|
|
|
|
|
|
|
|
r = n0 + d1;
|
|
|
|
|
if (r < d1) /* Carry in the addition? */
|
|
|
|
|
{
|
|
|
|
|
add_ssaaaa (n1, n0, r - d0, 0, 0, d0);
|
|
|
|
|
goto have_quot;
|
|
|
|
|
}
|
|
|
|
|
n1 = d0 - (d0 != 0);
|
|
|
|
|
n0 = -d0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
udiv_qrnnd (quot, r, n1, n0, d1);
|
|
|
|
|
umul_ppmm (n1, n0, d0, quot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
q_test:
|
|
|
|
|
if (n1 > r || (n1 == r && n0 > 0))
|
|
|
|
|
{
|
|
|
|
|
/* The estimated QUOT was too large. */
|
|
|
|
|
--quot;
|
|
|
|
|
|
|
|
|
|
sub_ddmmss (n1, n0, n1, n0, 0, d0);
|
|
|
|
|
r += d1;
|
|
|
|
|
if (r >= d1) /* If not carry, test QUOT again. */
|
|
|
|
|
goto q_test;
|
|
|
|
|
}
|
|
|
|
|
sub_ddmmss (n1, n0, r, 0, n1, n0);
|
|
|
|
|
|
|
|
|
|
have_quot:
|
|
|
|
|
got_limb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return round_and_return (retval, exponent - 1, negative,
|
|
|
|
|
quot, BITS_PER_MP_LIMB - 1 - used,
|
1995-03-02 10:00:12 +00:00
|
|
|
|
more_bits || n1 != 0 || n0 != 0);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
mp_limb cy, dX, d1, n0, n1;
|
|
|
|
|
mp_limb quot = 0;
|
|
|
|
|
int used = 0;
|
|
|
|
|
|
|
|
|
|
dX = den[densize - 1];
|
|
|
|
|
d1 = den[densize - 2];
|
|
|
|
|
|
|
|
|
|
/* The division does not work if the upper limb of the two-limb
|
|
|
|
|
numerator is greater than the denominator. */
|
1995-03-02 10:00:12 +00:00
|
|
|
|
if (__mpn_cmp (num, &den[densize - numsize], numsize) > 0)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
num[numsize++] = 0;
|
|
|
|
|
|
|
|
|
|
if (numsize < densize)
|
|
|
|
|
{
|
|
|
|
|
mp_size_t empty = densize - numsize;
|
|
|
|
|
|
|
|
|
|
if (bits <= 0)
|
|
|
|
|
{
|
|
|
|
|
register int i;
|
|
|
|
|
for (i = numsize; i > 0; --i)
|
|
|
|
|
num[i + empty] = num[i - 1];
|
|
|
|
|
MPN_ZERO (num, empty + 1);
|
|
|
|
|
exponent -= empty * BITS_PER_MP_LIMB;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (bits + empty * BITS_PER_MP_LIMB <= MANT_DIG)
|
|
|
|
|
{
|
|
|
|
|
/* We make a difference here because the compiler
|
|
|
|
|
cannot optimize the `else' case that good and
|
|
|
|
|
this reflects all currently used FLOAT types
|
|
|
|
|
and GMP implementations. */
|
|
|
|
|
register int i;
|
|
|
|
|
#if RETURN_LIMB_SIZE <= 2
|
|
|
|
|
assert (empty == 1);
|
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE,
|
|
|
|
|
BITS_PER_MP_LIMB, 0);
|
|
|
|
|
#else
|
|
|
|
|
for (i = RETURN_LIMB_SIZE; i > empty; --i)
|
|
|
|
|
retval[i] = retval[i - empty];
|
|
|
|
|
#endif
|
|
|
|
|
retval[1] = 0;
|
|
|
|
|
for (i = numsize; i > 0; --i)
|
|
|
|
|
num[i + empty] = num[i - 1];
|
|
|
|
|
MPN_ZERO (num, empty + 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
used = MANT_DIG - bits;
|
|
|
|
|
if (used >= BITS_PER_MP_LIMB)
|
|
|
|
|
{
|
|
|
|
|
register int i;
|
|
|
|
|
(void) __mpn_lshift (&retval[used
|
|
|
|
|
/ BITS_PER_MP_LIMB],
|
|
|
|
|
retval, RETURN_LIMB_SIZE,
|
|
|
|
|
used % BITS_PER_MP_LIMB);
|
|
|
|
|
for (i = used / BITS_PER_MP_LIMB; i >= 0; --i)
|
|
|
|
|
retval[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (used > 0)
|
|
|
|
|
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE, used, 0);
|
|
|
|
|
}
|
|
|
|
|
bits += empty * BITS_PER_MP_LIMB;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
assert (numsize == densize);
|
|
|
|
|
for (i = numsize; i > 0; --i)
|
|
|
|
|
num[i] = num[i - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
den[densize] = 0;
|
|
|
|
|
n0 = num[densize];
|
|
|
|
|
|
|
|
|
|
while (bits <= MANT_DIG)
|
|
|
|
|
{
|
|
|
|
|
if (n0 == dX)
|
|
|
|
|
/* This might over-estimate QUOT, but it's probably not
|
|
|
|
|
worth the extra code here to find out. */
|
|
|
|
|
quot = ~(mp_limb) 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mp_limb r;
|
|
|
|
|
|
|
|
|
|
udiv_qrnnd (quot, r, n0, num[densize - 1], dX);
|
|
|
|
|
umul_ppmm (n1, n0, d1, quot);
|
|
|
|
|
|
|
|
|
|
while (n1 > r || (n1 == r && n0 > num[densize - 2]))
|
|
|
|
|
{
|
|
|
|
|
--quot;
|
|
|
|
|
r += dX;
|
|
|
|
|
if (r < dX) /* I.e. "carry in previous addition?" */
|
|
|
|
|
break;
|
|
|
|
|
n1 -= n0 < d1;
|
|
|
|
|
n0 -= d1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Possible optimization: We already have (q * n0) and (1 * n1)
|
|
|
|
|
after the calculation of QUOT. Taking advantage of this, we
|
|
|
|
|
could make this loop make two iterations less. */
|
|
|
|
|
|
|
|
|
|
cy = __mpn_submul_1 (num, den, densize + 1, quot);
|
|
|
|
|
|
|
|
|
|
if (num[densize] != cy)
|
|
|
|
|
{
|
|
|
|
|
cy = __mpn_add_n (num, num, den, densize);
|
|
|
|
|
assert (cy != 0);
|
|
|
|
|
--quot;
|
|
|
|
|
}
|
|
|
|
|
n0 = num[densize] = num[densize - 1];
|
|
|
|
|
for (i = densize - 1; i > 0; --i)
|
|
|
|
|
num[i] = num[i - 1];
|
|
|
|
|
|
|
|
|
|
got_limb;
|
|
|
|
|
}
|
|
|
|
|
|
1995-03-02 10:00:12 +00:00
|
|
|
|
for (i = densize; num[i] == 0 && i >= 0; --i)
|
1995-02-18 01:27:10 +00:00
|
|
|
|
;
|
|
|
|
|
return round_and_return (retval, exponent - 1, negative,
|
|
|
|
|
quot, BITS_PER_MP_LIMB - 1 - used,
|
1995-03-02 10:00:12 +00:00
|
|
|
|
more_bits || i >= 0);
|
1995-02-18 01:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* NOTREACHED */
|
|
|
|
|
}
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
|
|
|
|
|
/* External user entry point. */
|
|
|
|
|
|
1995-04-10 18:58:00 +00:00
|
|
|
|
#define weak_this(x) weak_symbol(x)
|
|
|
|
|
weak_this (STRTOF)
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
|
|
|
|
|
|
FLOAT
|
|
|
|
|
STRTOF (nptr, endptr)
|
|
|
|
|
const char *nptr;
|
|
|
|
|
char **endptr;
|
|
|
|
|
{
|
|
|
|
|
return INTERNAL (STRTOF) (nptr, endptr, 0);
|
|
|
|
|
}
|