move declaration of interfaces between malloc and ldso to dynlink.h
[musl] / src / internal / floatscan.c
index eef70df..8c0828f 100644 (file)
@@ -33,9 +33,6 @@
 
 #define MASK (KMAX-1)
 
-#define CONCAT2(x,y) x ## y
-#define CONCAT(x,y) CONCAT2(x,y)
-
 static long long scanexp(FILE *f, int pok)
 {
        int c;
@@ -110,7 +107,10 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
                        gotdig=1;
                } else {
                        dc++;
-                       if (c!='0') x[KMAX-4] |= 1;
+                       if (c!='0') {
+                               lnz = (KMAX-4)*9;
+                               x[KMAX-4] |= 1;
+                       }
                }
        }
        if (!gotrad) lrp=dc;
@@ -172,6 +172,9 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
                        return sign * (long double)x[0] * p10s[rp-10];
        }
 
+       /* Drop trailing zeros */
+       for (; !x[z-1]; z--);
+
        /* Align radix point to B1B digit boundary */
        if (rp % 9) {
                int rpm9 = rp>=0 ? rp%9 : rp%9+9;
@@ -295,7 +298,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
        y -= bias;
 
        if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) {
-               if (fabs(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) {
+               if (fabsl(y) >= 2/LDBL_EPSILON) {
                        if (denormal && bits==LDBL_MANT_DIG+e2-emin)
                                denormal = 0;
                        y *= 0.5;