From f0bf9cb92c28c9ec0ac3376d87055e9d14610082 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 16 Mar 1995 05:32:45 +0000 Subject: Thu Mar 16 00:04:41 1995 Roland McGrath * 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 * 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 * 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 . (__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. --- stdio/internals.c | 2 +- stdio/printf_fp.c | 9 +++---- stdio/vfscanf.c | 81 ++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 36 deletions(-) (limited to 'stdio') diff --git a/stdio/internals.c b/stdio/internals.c index b01c5bd531..c238bf39f9 100644 --- a/stdio/internals.c +++ b/stdio/internals.c @@ -265,7 +265,7 @@ DEFUN(flushbuf, (fp, c), } } - if (fp->__bufp - fp->__buffer <= buffer_offset) + if (fp->__bufp - fp->__buffer <= buffer_offset && flush_only) { /* There is nothing new in the buffer, only data that was read back aligned from the file. */ diff --git a/stdio/printf_fp.c b/stdio/printf_fp.c index 42443fa003..33fe427999 100644 --- a/stdio/printf_fp.c +++ b/stdio/printf_fp.c @@ -36,12 +36,11 @@ Cambridge, MA 02139, USA. */ #include #include #include -#include #include #include #include -/* #define NDEBUG 1 */ +#define NDEBUG /* Undefine this for debugging assertions. */ #include /* This defines make it possible to use the same code for GNU C library and @@ -133,7 +132,7 @@ int __printf_fp (fp, info, args) FILE *fp; const struct printf_info *info; - va_list *args; + const **const args; { /* The floating-point value to output. */ union @@ -254,7 +253,7 @@ __printf_fp (fp, info, args) /* Fetch the argument value. */ if (info->is_long_double && sizeof (long double) > sizeof (double)) { - fpnum.ldbl = va_arg (*args, LONG_DOUBLE); + fpnum.ldbl = *(const long double *) args[0]; /* Check for special values: not a number or infinity. */ if (__isnanl (fpnum.ldbl)) @@ -279,7 +278,7 @@ __printf_fp (fp, info, args) } else { - fpnum.dbl = va_arg (*args, double); + fpnum.dbl = *(const double *) args[0]; /* Check for special values: not a number or infinity. */ if (__isnan (fpnum.dbl)) diff --git a/stdio/vfscanf.c b/stdio/vfscanf.c index 47781ed566..9a9e3bb79c 100644 --- a/stdio/vfscanf.c +++ b/stdio/vfscanf.c @@ -57,6 +57,7 @@ DEFUN(__vfscanf, (s, format, arg), register int c; /* Last char read. */ register int do_assign; /* Whether to do an assignment. */ register int width; /* Maximum field width. */ + int group_flag; /* %' modifier flag. */ /* Type modifiers. */ char is_short, is_long, is_long_double; @@ -76,8 +77,13 @@ DEFUN(__vfscanf, (s, format, arg), /* Signedness for integral numbers. */ int number_signed; /* Integral holding variables. */ - long int num; - unsigned long int unum; + union + { + long long int q; + unsigned long long int uq; + long int l; + unsigned long int ul; + } num; /* Character-buffer pointer. */ register char *str, **strptr; size_t strsize; @@ -93,8 +99,8 @@ DEFUN(__vfscanf, (s, format, arg), } /* Figure out the decimal point character. */ - if (mbtowc(&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT), - strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0) + 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); c = inchar(); @@ -102,10 +108,10 @@ DEFUN(__vfscanf, (s, format, arg), /* Run through the format string. */ while (*f != '\0') { - if (!isascii(*f)) + if (!isascii (*f)) { /* Non-ASCII, may be a multibyte. */ - int len = mblen(f, strlen(f)); + int len = mblen (f, strlen(f)); if (len > 0) { while (len-- > 0) @@ -139,15 +145,20 @@ DEFUN(__vfscanf, (s, format, arg), continue; } - /* Check for the assignment-suppressant. */ - if (*f == '*') - { - do_assign = 0; - ++f; - } - else - do_assign = 1; - + /* Check for the assignment-suppressant and the number grouping flag. */ + do_assign = 1; + group_flag = 0; + while (*f == '*' || *f == '\'') + switch (*f++) + { + case '*': + do_assign = 0; + break; + case '\'': + group_flag = 1; + break; + } + /* Find the maximum field width. */ width = 0; while (isdigit(*f)) @@ -396,9 +407,19 @@ DEFUN(__vfscanf, (s, format, arg), /* Convert the number. */ *w = '\0'; if (number_signed) - num = strtol (work, &w, base); + { + if (is_longlong) + num.q = __strtoq_internal (work, &w, base, group_flag); + else + num.uq = __strtouq_internal (work, &w, base, group_flag); + } else - unum = strtoul (work, &w, base); + { + if (is_long_double) + num.l = __strtol_internal (work, &w, base, group_flag); + else + num.ul = __strtoul_internal (work, &w, base, group_flag); + } if (w == work) conv_error (); @@ -407,25 +428,25 @@ DEFUN(__vfscanf, (s, format, arg), if (! number_signed) { if (is_longlong) - *va_arg (arg, unsigned LONGLONG int *) = unum; + *va_arg (arg, unsigned LONGLONG int *) = num.uq; else if (is_long) - *va_arg (arg, unsigned long int *) = unum; + *va_arg (arg, unsigned long int *) = num.ul; else if (is_short) *va_arg (arg, unsigned short int *) - = (unsigned short int) unum; + = (unsigned short int) num.ul; else - *va_arg(arg, unsigned int *) = (unsigned int) unum; + *va_arg (arg, unsigned int *) = (unsigned int) num.ul; } else { if (is_longlong) - *va_arg(arg, LONGLONG int *) = num; + *va_arg (arg, LONGLONG int *) = num.q; else if (is_long) - *va_arg(arg, long int *) = num; + *va_arg (arg, long int *) = num.l; else if (is_short) - *va_arg(arg, short int *) = (short int) num; + *va_arg (arg, short int *) = (short int) num.l; else - *va_arg(arg, int *) = (int) num; + *va_arg (arg, int *) = (int) num.l; } ++done; } @@ -482,19 +503,19 @@ DEFUN(__vfscanf, (s, format, arg), *w = '\0'; if (is_long_double) { - long double d = __strtold (work, &w); + long double d = __strtold_internal (work, &w, group_flag); if (do_assign && w != work) *va_arg (arg, long double *) = d; } else if (is_long) { - double d = strtod (work, &w); + double d = __strtod_internal (work, &w, group_flag); if (do_assign && w != work) *va_arg (arg, double *) = d; } else { - float d = __strtof (work, &w); + float d = __strtof_internal (work, &w, group_flag); if (do_assign && w != work) *va_arg (arg, float *) = d; } @@ -536,7 +557,7 @@ DEFUN(__vfscanf, (s, format, arg), conv_error(); *w = '\0'; - unum = read_in; + num.ul = read_in; do { if ((strchr (work, c) == NULL) != not_in) @@ -545,7 +566,7 @@ DEFUN(__vfscanf, (s, format, arg), if (width > 0) --width; } while (inchar () != EOF && width != 0); - if (read_in == unum) + if (read_in == num.ul) conv_error (); if (do_assign) -- cgit v1.2.3