Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2003-11-21 23:48:49 +0300
committerJeff Johnston <jjohnstn@redhat.com>2003-11-21 23:48:49 +0300
commit4f6149d6f07c79fd48c0d41f303786f610e81bd1 (patch)
tree0d24a01ed2c4446b82c40afa1554890f3e9ceddb /newlib/libc/stdio/vfscanf.c
parent4bd6628553506745bfa6c738658fecb0d2b40065 (diff)
2003-11-21 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfscanf.c (__svfscanf_r)[!_NO_LONGDBL]: Don't use _strtold routine for processing floats and doubles since it is not as fast as _strtod_r.
Diffstat (limited to 'newlib/libc/stdio/vfscanf.c')
-rw-r--r--newlib/libc/stdio/vfscanf.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 3c0472b57..fab2fbf3c 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -998,10 +998,12 @@ __svfscanf_r (rptr, fp, fmt0, ap)
}
if ((flags & SUPPRESS) == 0)
{
-#ifdef _NO_LONGDBL
double res;
+#ifdef _NO_LONGDBL
+#define QUAD_RES res;
#else /* !_NO_LONG_DBL */
- long double res;
+ long double qres;
+#define QUAD_RES qres;
#endif /* !_NO_LONG_DBL */
long new_exp = 0;
@@ -1023,11 +1025,17 @@ __svfscanf_r (rptr, fp, fmt0, ap)
exp_start = buf + sizeof (buf) - MAX_LONG_LEN - 1;
sprintf (exp_start, "e%ld", new_exp);
}
-#ifdef _NO_LONGDBL
- res = _strtod_r (rptr, buf, NULL);
-#else /* !_NO_LONGDBL */
- res = _strtold (buf, NULL);
-#endif /* !_NO_LONGDBL */
+
+ /* Current _strtold routine is markedly slower than
+ _strtod_r. Only use it if we have a long double
+ result. */
+#ifndef _NO_LONGDBL /* !_NO_LONGDBL */
+ if (flags & LONGDBL)
+ qres = _strtold (buf, NULL);
+ else
+#endif
+ res = _strtod_r (rptr, buf, NULL);
+
if (flags & LONG)
{
dp = va_arg (ap, double *);
@@ -1036,7 +1044,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
else if (flags & LONGDBL)
{
ldp = va_arg (ap, _LONG_DOUBLE *);
- *ldp = res;
+ *ldp = QUAD_RES;
}
else
{