diff options
author | André Goddard Rosa <andre.goddard@gmail.com> | 2010-02-05 18:32:52 -0200 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-04-29 07:29:06 -0700 |
commit | e734769276045c0cb89d4620fdd4ef35a0e6c335 (patch) | |
tree | 8b7cdc163f1dce70efb9f5221e6e0b845a07c368 | |
parent | 1698d9ebfc7e27271852a1fdf305a2ac37b3ebe4 (diff) | |
download | bionic-e734769276045c0cb89d4620fdd4ef35a0e6c335.zip bionic-e734769276045c0cb89d4620fdd4ef35a0e6c335.tar.gz bionic-e734769276045c0cb89d4620fdd4ef35a0e6c335.tar.bz2 |
improve readability of stdlib: fix indentation and remove trailing spaces
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Change-Id: I7dd90a0816b5376ffc1de4499d56935e0bd574a1
-rw-r--r-- | libc/stdlib/assert.c | 2 | ||||
-rw-r--r-- | libc/stdlib/ctype_.c | 2 | ||||
-rw-r--r-- | libc/stdlib/getenv.c | 4 | ||||
-rw-r--r-- | libc/stdlib/putenv.c | 2 | ||||
-rw-r--r-- | libc/stdlib/qsort.c | 26 | ||||
-rw-r--r-- | libc/stdlib/seed48.c | 2 | ||||
-rw-r--r-- | libc/stdlib/sha1hash.c | 15 | ||||
-rw-r--r-- | libc/stdlib/strtod.c | 395 | ||||
-rw-r--r-- | libc/stdlib/strtoimax.c | 6 | ||||
-rw-r--r-- | libc/stdlib/strtoumax.c | 6 | ||||
-rw-r--r-- | libc/stdlib/wchar.c | 2 |
11 files changed, 230 insertions, 232 deletions
diff --git a/libc/stdlib/assert.c b/libc/stdlib/assert.c index b439d8e..816b050 100644 --- a/libc/stdlib/assert.c +++ b/libc/stdlib/assert.c @@ -49,6 +49,6 @@ __assert2(const char *file, int line, const char *func, const char *failedexpr) (void)fprintf(stderr, "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n", failedexpr, file, line, func); - abort(); + abort(); /* NOTREACHED */ } diff --git a/libc/stdlib/ctype_.c b/libc/stdlib/ctype_.c index f59af3e..cf32f16 100644 --- a/libc/stdlib/ctype_.c +++ b/libc/stdlib/ctype_.c @@ -53,7 +53,7 @@ const char _C_ctype_[1 + CTYPE_NUM_CHARS] = { _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, -/* determine printability based on the IS0 8859 8-bit standard */ + /* determine printability based on the IS0 8859 8-bit standard */ _L, _L, _L, _P, _P, _P, _P, _C, _C, _C, _C, _C, _C, _C, _C, _C, /* 80 */ diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c index 13abe30..72367b3 100644 --- a/libc/stdlib/getenv.c +++ b/libc/stdlib/getenv.c @@ -62,8 +62,8 @@ __findenv(const char *name, int *offset) if (i == 0 && *cp++ == '=') { *offset = p - environ; return (cp); - } - } + } + } return (NULL); } diff --git a/libc/stdlib/putenv.c b/libc/stdlib/putenv.c index c3bedae..54482f6 100644 --- a/libc/stdlib/putenv.c +++ b/libc/stdlib/putenv.c @@ -42,7 +42,7 @@ putenv(const char *str) if ((equal = strchr(p, '=')) == NULL) { (void)free(p); return (-1); - } + } *equal = '\0'; rval = setenv(p, equal + 1, 1); (void)free(p); diff --git a/libc/stdlib/qsort.c b/libc/stdlib/qsort.c index cd66961..f6fc8e1 100644 --- a/libc/stdlib/qsort.c +++ b/libc/stdlib/qsort.c @@ -39,11 +39,11 @@ static __inline void swapfunc(char *, char *, int, int); /* * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". */ -#define swapcode(TYPE, parmi, parmj, n) { \ - long i = (n) / sizeof (TYPE); \ - TYPE *pi = (TYPE *) (parmi); \ - TYPE *pj = (TYPE *) (parmj); \ - do { \ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ + do { \ TYPE t = *pi; \ *pi++ = *pj; \ *pj++ = t; \ @@ -56,7 +56,7 @@ static __inline void swapfunc(char *, char *, int, int); static __inline void swapfunc(char *a, char *b, int n, int swaptype) { - if (swaptype <= 1) + if (swaptype <= 1) swapcode(long, a, b, n) else swapcode(char, a, b, n) @@ -70,7 +70,7 @@ swapfunc(char *a, char *b, int n, int swaptype) } else \ swapfunc(a, b, es, swaptype) -#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) static __inline char * med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *)) @@ -110,7 +110,7 @@ loop: SWAPINIT(a, es); } swap(a, pm); pa = pb = (char *)a + es; - + pc = pd = (char *)a + (n - 1) * es; for (;;) { while (pb <= pc && (r = cmp(pb, a)) <= 0) { @@ -118,7 +118,7 @@ loop: SWAPINIT(a, es); swap_cnt = 1; swap(pa, pb); pa += es; - } + } pb += es; } while (pb <= pc && (r = cmp(pc, a)) >= 0) { @@ -138,11 +138,11 @@ loop: SWAPINIT(a, es); } if (swap_cnt == 0) { /* Switch to insertion sort */ for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) - for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; pl -= es) swap(pl, pl - es); return; - } + } pn = (char *)a + n * es; r = min(pa - (char *)a, pb - pa); @@ -151,11 +151,11 @@ loop: SWAPINIT(a, es); vecswap(pb, pn - r, r); if ((r = pb - pa) > (int)es) qsort(a, r / es, es, cmp); - if ((r = pd - pc) > (int)es) { + if ((r = pd - pc) > (int)es) { /* Iterate rather than recurse to save stack space */ a = pn - r; n = r / es; goto loop; } -/* qsort(pn - r, r / es, es, cmp);*/ + /* qsort(pn - r, r / es, es, cmp); */ } diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c index afd5f54..583262f 100644 --- a/libc/stdlib/seed48.c +++ b/libc/stdlib/seed48.c @@ -22,7 +22,7 @@ unsigned short * seed48(unsigned short xseed[3]) { static unsigned short sseed[3]; - + sseed[0] = __rand48_seed[0]; sseed[1] = __rand48_seed[1]; sseed[2] = __rand48_seed[2]; diff --git a/libc/stdlib/sha1hash.c b/libc/stdlib/sha1hash.c index 28e3399..1c7aaf3 100644 --- a/libc/stdlib/sha1hash.c +++ b/libc/stdlib/sha1hash.c @@ -4,7 +4,7 @@ By Steve Reid <sreid@sea-to-sky.net> 100% Public Domain ----------------- -Modified 7/98 +Modified 7/98 By James H. Brown <jbrown@burgoyne.com> Still 100% Public Domain @@ -26,7 +26,7 @@ Since the file IO in main() reads 16K at a time, any file 8K or larger would be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million "a"s). -I also changed the declaration of variables i & j in SHA1Update to +I also changed the declaration of variables i & j in SHA1Update to unsigned long from unsigned int for the same reason. These changes should make no difference to any 32 bit implementations since @@ -53,7 +53,7 @@ Still 100% public domain Modified 4/01 By Saul Kravitz <Saul.Kravitz@celera.com> Still 100% PD -Modified to run on Compaq Alpha hardware. +Modified to run on Compaq Alpha hardware. ----------------- Modified 2/03 @@ -116,7 +116,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context); void SHAPrintContext(SHA1_CTX *context, char *msg){ printf("%s (%d,%d) %x %x %x %x %x\n", msg, - context->count[0], context->count[1], + context->count[0], context->count[1], context->state[0], context->state[1], context->state[2], @@ -238,8 +238,7 @@ unsigned char finalcount[8]; while ((context->count[0] & 504) != 448) { SHA1Update(context, (unsigned char *)"\0", 1); } - SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() -*/ + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ for (i = 0; i < 20; i++) { digest[i] = (unsigned char) ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); @@ -254,7 +253,7 @@ unsigned char finalcount[8]; SHA1Transform(context->state, context->buffer); #endif } - + /*************************************************************/ /* This is not quite the MIME base64 algorithm: it uses _ instead of /, @@ -302,7 +301,7 @@ int main(int argc, char** argv) fputs("Unable to open file.", stderr); return(-1); } - } + } SHA1Init(&context); while (!feof(file)) { /* note: what if ferror(file) */ i = fread(buffer, 1, 16384, file); diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c index 7fb7112..d2582b1 100644 --- a/libc/stdlib/strtod.c +++ b/libc/stdlib/strtod.c @@ -364,7 +364,7 @@ Bigint { struct Bigint *next; int k, maxwds, sign, wds; ULong x[1]; - }; +}; typedef struct Bigint Bigint; @@ -393,19 +393,19 @@ Balloc if ((rv = freelist[k]) != NULL) { freelist[k] = rv->next; - } + } else { x = 1 << k; rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)); rv->k = k; rv->maxwds = x; - } + } rv->sign = rv->wds = 0; mutex_unlock(&freelist_mutex); return rv; - } +} static void Bfree @@ -422,8 +422,8 @@ Bfree freelist[v->k] = v; mutex_unlock(&freelist_mutex); - } } +} #define Bcopy(x,y) memcpy(&x->sign, &y->sign, \ y->wds*sizeof(Long) + 2*sizeof(int)) @@ -458,8 +458,8 @@ multadd a = (int)(y >> 16); *x++ = y & 0xffff; #endif - } - while(++i < wds); + } + while(++i < wds); if (a) { if (wds >= b->maxwds) { b1 = Balloc(b->k+1); @@ -469,9 +469,9 @@ multadd } b->x[wds++] = a; b->wds = wds; - } - return b; } + return b; +} static Bigint * s2b @@ -503,13 +503,13 @@ s2b do b = multadd(b, 10, *s++ - '0'); while(++i < nd0); s++; - } + } else s += 10; for(; i < nd; i++) b = multadd(b, 10, *s++ - '0'); return b; - } +} static int hi0bits @@ -524,26 +524,26 @@ hi0bits if (!(x & 0xffff0000)) { k = 16; x <<= 16; - } + } if (!(x & 0xff000000)) { k += 8; x <<= 8; - } + } if (!(x & 0xf0000000)) { k += 4; x <<= 4; - } + } if (!(x & 0xc0000000)) { k += 2; x <<= 2; - } + } if (!(x & 0x80000000)) { k++; if (!(x & 0x40000000)) return 32; - } - return k; } + return k; +} static int lo0bits @@ -565,33 +565,33 @@ lo0bits } *y = x >> 2; return 2; - } + } k = 0; if (!(x & 0xffff)) { k = 16; x >>= 16; - } + } if (!(x & 0xff)) { k += 8; x >>= 8; - } + } if (!(x & 0xf)) { k += 4; x >>= 4; - } + } if (!(x & 0x3)) { k += 2; x >>= 2; - } + } if (!(x & 1)) { k++; x >>= 1; if (!x & 1) return 32; - } + } *y = x; return k; - } +} static Bigint * i2b @@ -607,7 +607,7 @@ i2b b->x[0] = i; b->wds = 1; return b; - } +} static Bigint * mult @@ -629,7 +629,7 @@ mult c = a; a = b; b = c; - } + } k = a->k; wa = a->wds; wb = b->wds; @@ -656,10 +656,10 @@ mult z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; carry = z2 >> 16; Storeinc(xc, z2, z); - } - while(x < xae); - *xc = carry; } + while(x < xae); + *xc = carry; + } if ((y = *xb >> 16) != 0) { x = xa; xc = xc0; @@ -671,11 +671,11 @@ mult Storeinc(xc, z, z2); z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; carry = z2 >> 16; - } - while(x < xae); - *xc = z2; } + while(x < xae); + *xc = z2; } + } #else for(; xb < xbe; xc0++) { if (y = *xb++) { @@ -686,16 +686,16 @@ mult z = *x++ * y + *xc + carry; carry = z >> 16; *xc++ = z & 0xffff; - } - while(x < xae); - *xc = carry; } + while(x < xae); + *xc = carry; } + } #endif for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; c->wds = wc; return c; - } +} static Bigint *p5s; @@ -720,23 +720,23 @@ pow5mult /* first time */ p5 = p5s = i2b(625); p5->next = 0; - } + } for(;;) { if (k & 1) { b1 = mult(b, p5); Bfree(b); b = b1; - } + } if (!(k = (unsigned int) k >> 1)) break; if (!(p51 = p5->next)) { p51 = p5->next = mult(p5,p5); p51->next = 0; - } - p5 = p51; } - return b; + p5 = p51; } + return b; +} static Bigint * lshift @@ -772,11 +772,11 @@ lshift do { *x1++ = *x << k | z; z = *x++ >> k1; - } - while(x < xe); + } + while(x < xe); if ((*x1 = z) != 0) ++n1; - } + } #else if (k &= 0xf) { k1 = 16 - k; @@ -784,11 +784,11 @@ lshift do { *x1++ = *x << k & 0xffff | z; z = *x++ >> k1; - } - while(x < xe); + } + while(x < xe); if (*x1 = z) ++n1; - } + } #endif else do *x1++ = *x++; @@ -796,7 +796,7 @@ lshift b1->wds = n1 - 1; Bfree(b); return b1; - } +} static int cmp @@ -828,9 +828,9 @@ cmp return *xa < *xb ? -1 : 1; if (xa <= xa0) break; - } - return 0; } + return 0; +} static Bigint * diff @@ -854,13 +854,13 @@ diff c->wds = 1; c->x[0] = 0; return c; - } + } if (i < 0) { c = a; a = b; b = c; i = 1; - } + } else i = 0; c = Balloc(a->k); @@ -882,8 +882,8 @@ diff borrow = (ULong)z >> 16; Sign_Extend(borrow, z); Storeinc(xc, z, y); - } - while(xb < xbe); + } + while(xb < xbe); while(xa < xae) { y = (*xa & 0xffff) + borrow; borrow = (ULong)y >> 16; @@ -892,27 +892,27 @@ diff borrow = (ULong)z >> 16; Sign_Extend(borrow, z); Storeinc(xc, z, y); - } + } #else do { y = *xa++ - *xb++ + borrow; borrow = y >> 16; Sign_Extend(borrow, y); *xc++ = y & 0xffff; - } - while(xb < xbe); + } + while(xb < xbe); while(xa < xae) { y = *xa++ + borrow; borrow = y >> 16; Sign_Extend(borrow, y); *xc++ = y & 0xffff; - } + } #endif while(!*--xc) wa--; c->wds = wa; return c; - } +} static double ulp @@ -937,22 +937,22 @@ ulp word0(a) = L; word1(a) = 0; #ifndef Sudden_Underflow - } + } else { L = (ULong)-L >> Exp_shift; if (L < Exp_shift) { word0(a) = 0x80000 >> L; word1(a) = 0; - } + } else { word0(a) = 0; L -= Exp_shift; word1(a) = L >= 31 ? 1 : 1 << (31 - L); - } } + } #endif return value(a); - } +} static double b2d @@ -986,17 +986,17 @@ b2d w = xa > xa0 ? *--xa : 0; d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); goto ret_d; - } + } z = xa > xa0 ? *--xa : 0; if (k -= Ebits) { d0 = Exp_1 | y << k | z >> (32 - k); y = xa > xa0 ? *--xa : 0; d1 = z << k | y >> (32 - k); - } + } else { d0 = Exp_1 | y; d1 = z; - } + } #else if (k < Ebits + 16) { z = xa > xa0 ? *--xa : 0; @@ -1005,7 +1005,7 @@ b2d y = xa > xa0 ? *--xa : 0; d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; goto ret_d; - } + } z = xa > xa0 ? *--xa : 0; w = xa > xa0 ? *--xa : 0; k -= Ebits + 16; @@ -1022,7 +1022,7 @@ b2d #undef d1 #endif return value(d); - } +} static Bigint * d2b @@ -1072,11 +1072,11 @@ d2b if ((k = lo0bits(&y)) != 0) { x[0] = y | z << (32 - k); z >>= k; - } + } else x[0] = y; i = b->wds = (x[1] = z) ? 2 : 1; - } + } else { #ifdef DEBUG if (!z) @@ -1086,7 +1086,7 @@ d2b x[0] = z; i = b->wds = 1; k += 32; - } + } #else if (y = d1) { if (k = lo0bits(&y)) @@ -1095,22 +1095,22 @@ d2b x[1] = z >> k - 16 & 0xffff; x[2] = z >> k; i = 2; - } + } else { x[0] = y & 0xffff; x[1] = y >> 16 | z << 16 - k & 0xffff; x[2] = z >> k & 0xffff; x[3] = z >> k+16; i = 3; - } + } else { x[0] = y & 0xffff; x[1] = y >> 16; x[2] = z & 0xffff; x[3] = z >> 16; i = 3; - } } + } else { #ifdef DEBUG if (!z) @@ -1120,14 +1120,14 @@ d2b if (k >= 16) { x[0] = z; i = 0; - } + } else { x[0] = z & 0xffff; x[1] = z >> 16; i = 1; - } - k += 32; } + k += 32; + } while(!x[i]) --i; b->wds = i + 1; @@ -1143,7 +1143,7 @@ d2b *bits = P - k; #endif #ifndef Sudden_Underflow - } + } else { *e = de - Bias - (P-1) + 1 + k; #ifdef Pack_32 @@ -1154,7 +1154,7 @@ d2b } #endif return b; - } +} #undef d0 #undef d1 @@ -1181,23 +1181,23 @@ ratio word0(da) += (k >> 2)*Exp_msk1; if (k &= 3) da *= 1 << k; - } + } else { k = -k; word0(db) += (k >> 2)*Exp_msk1; if (k &= 3) db *= 1 << k; - } + } #else if (k > 0) word0(da) += k*Exp_msk1; else { k = -k; word0(db) += k*Exp_msk1; - } + } #endif return value(da) / value(db); - } +} static CONST double tens[] = { @@ -1207,7 +1207,7 @@ tens[] = { #ifdef VAX , 1e23, 1e24 #endif - }; +}; #ifdef IEEE_Arith static CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; @@ -1312,7 +1312,7 @@ strtod while(*++s == '0') ; if (!*s) goto ret; - } + } s0 = s; y = z = 0; for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) @@ -1333,7 +1333,7 @@ strtod goto have_dig; } goto dig_done; - } + } for(; c >= '0' && c <= '9'; c = *++s) { have_dig: nz++; @@ -1349,16 +1349,16 @@ strtod else if (nd <= DBL_DIG + 1) z = 10*z + c; nz = 0; - } } } + } dig_done: e = 0; if (c == 'e' || c == 'E') { if (!nd && !nz && !nz0) { s = s00; goto ret; - } + } s00 = s; esign = 0; switch(c = *++s) { @@ -1367,7 +1367,7 @@ strtod /* FALLTHROUGH */ case '+': c = *++s; - } + } if (c >= '0' && c <= '9') { while(c == '0') c = *++s; @@ -1385,18 +1385,18 @@ strtod e = (int)L; if (esign) e = -e; - } + } else e = 0; - } + } else s = s00; - } + } if (!nd) { if (!nz && !nz0) s = s00; goto ret; - } + } e1 = e -= nf; /* Now we have nd0 digits, starting at s0, followed by a @@ -1415,7 +1415,7 @@ strtod #ifndef RND_PRODQUOT && FLT_ROUNDS == 1 #endif - ) { + ) { if (!e) goto ret; if (e > 0) { @@ -1427,7 +1427,7 @@ strtod tens[e]); goto ret; #endif - } + } i = DBL_DIG - nd; if (e <= Ten_pmax + i) { /* A fancier test would sometimes let us do @@ -1452,16 +1452,16 @@ strtod tens[e]); #endif goto ret; - } } + } #ifndef Inaccurate_Divide else if (e >= -Ten_pmax) { /* value(rv) = */ rounded_quotient(value(rv), tens[-e]); goto ret; - } -#endif } +#endif + } e1 += nd - k; /* Get starting approximation = rv * 10**e1 */ @@ -1477,7 +1477,7 @@ strtod if (bd0) goto retfree; goto ret; - } + } if ((e1 = (unsigned int)e1 >> 4) != 0) { for(j = 0; e1 > 1; j++, e1 = (unsigned int)e1 >> 1) @@ -1497,10 +1497,9 @@ strtod } else word0(rv) += P*Exp_msk1; - } - } } + } else if (e1 < 0) { e1 = -e1; if ((i = e1 & 15) != 0) @@ -1526,15 +1525,15 @@ strtod if (bd0) goto retfree; goto ret; - } + } word0(rv) = Tiny0; word1(rv) = Tiny1; /* The refinement below will clean * this approximation up. */ - } } } + } /* Now the hard part -- adjusting rv to the correct value.*/ @@ -1551,11 +1550,11 @@ strtod if (e >= 0) { bb2 = bb5 = 0; bd2 = bd5 = e; - } + } else { bb2 = bb5 = -e; bd2 = bd5 = 0; - } + } if (bbe >= 0) bb2 += bbe; else @@ -1583,13 +1582,13 @@ strtod bb2 -= i; bd2 -= i; bs2 -= i; - } + } if (bb5 > 0) { bs = pow5mult(bs, bb5); bb1 = mult(bs, bb); Bfree(bb); bb = bb1; - } + } if (bb2 > 0) bb = lshift(bb, bb2); if (bd5 > 0) @@ -1612,7 +1611,7 @@ strtod if (cmp(delta, bs) > 0) goto drop_down; break; - } + } if (i == 0) { /* exactly half-way between */ if (dsign) { @@ -1627,8 +1626,8 @@ strtod ; word1(rv) = 0; break; - } } + } else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { drop_down: /* boundary case -- decrement exponent */ @@ -1651,7 +1650,7 @@ strtod #else break; #endif - } + } #ifndef ROUND_BIASED if (!(word1(rv) & LSB)) break; @@ -1665,10 +1664,10 @@ strtod if (!value(rv)) goto undfl; #endif - } + } #endif break; - } + } if ((aadj = ratio(delta, bs)) <= 2.) { if (dsign) aadj = aadj1 = 1.; @@ -1679,7 +1678,7 @@ strtod #endif aadj = 1.; aadj1 = -1.; - } + } else { /* special case -- power of FLT_RADIX to be */ /* rounded down... */ @@ -1690,7 +1689,7 @@ strtod aadj *= 0.5; aadj1 = -aadj; } - } + } else { aadj *= 0.5; aadj1 = dsign ? aadj : -aadj; @@ -1702,12 +1701,12 @@ strtod case 0: /* towards 0 */ case 3: /* towards -infinity */ aadj1 += 0.5; - } + } #else if (FLT_ROUNDS == 0) aadj1 += 0.5; #endif - } + } y = word0(rv) & Exp_mask; /* Check for overflow */ @@ -1724,10 +1723,10 @@ strtod word0(rv) = Big0; word1(rv) = Big1; goto cont; - } + } else word0(rv) += P*Exp_msk1; - } + } else { #ifdef Sudden_Underflow if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { @@ -1740,21 +1739,21 @@ strtod #else if ((word0(rv) & Exp_mask) <= P*Exp_msk1) #endif - { + { if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1) goto undfl; word0(rv) = Tiny0; word1(rv) = Tiny1; goto cont; - } + } else word0(rv) -= P*Exp_msk1; } else { adj = aadj1 * ulp(value(rv)); value(rv) += adj; - } + } #else /* Compute adj so that the IEEE rounding rules will * correctly round rv + adj in some half-way cases. @@ -1767,11 +1766,11 @@ strtod aadj1 = (double)(int)(aadj + 0.5); if (!dsign) aadj1 = -aadj1; - } + } adj = aadj1 * ulp(value(rv)); value(rv) += adj; #endif - } + } z = word0(rv) & Exp_mask; if (y == z) { /* Can we stop now? */ @@ -1781,16 +1780,16 @@ strtod if (dsign || word1(rv) || word0(rv) & Bndry_mask) { if (aadj < .4999999 || aadj > .5000001) break; - } + } else if (aadj < .4999999/FLT_RADIX) break; - } + } cont: Bfree(bb); Bfree(bd); Bfree(bs); Bfree(delta); - } + } retfree: Bfree(bb); Bfree(bd); @@ -1802,7 +1801,7 @@ strtod /* LINTED interface specification */ *se = (char *)s; return sign ? -value(rv) : value(rv); - } +} static int quorem @@ -1861,15 +1860,15 @@ quorem Sign_Extend(borrow, y); *bx++ = y & 0xffff; #endif - } - while(sx <= sxe); + } + while(sx <= sxe); if (!*bxe) { bx = b->x; while(--bxe > bx && !*bxe) --n; b->wds = n; - } } + } if (cmp(b, S) >= 0) { q++; borrow = 0; @@ -1897,18 +1896,18 @@ quorem Sign_Extend(borrow, y); *bx++ = y & 0xffff; #endif - } - while(sx <= sxe); + } + while(sx <= sxe); bx = b->x; bxe = bx + n; if (!*bxe) { while(--bxe > bx && !*bxe) --n; b->wds = n; - } } - return q; } + return q; +} /* freedtoa(s) must be used to free values s returned by dtoa * when MULTIPLE_THREADS is #defined. It should be used in all cases, @@ -2028,7 +2027,7 @@ __dtoa /* set sign for everything, including 0's and NaNs */ *sign = 1; word0(d) &= ~Sign_bit; /* clear sign bit */ - } + } else *sign = 0; @@ -2038,7 +2037,7 @@ __dtoa #else if (word0(d) == 0x8000) #endif - { + { /* Infinity or NaN */ *decpt = 9999; s = @@ -2046,30 +2045,30 @@ __dtoa !word1(d) && !(word0(d) & 0xfffff) ? "Infinity" : #endif "NaN"; - result = Balloc(strlen(s)+1); - s0 = (char *)(void *)result; - strcpy(s0, s); - if (rve) - *rve = + result = Balloc(strlen(s)+1); + s0 = (char *)(void *)result; + strcpy(s0, s); + if (rve) + *rve = #ifdef IEEE_Arith - s0[3] ? s0 + 8 : + s0[3] ? s0 + 8 : #endif - s0 + 3; + s0 + 3; return s0; - } + } #endif #ifdef IBM value(d) += 0; /* normalize */ #endif if (!value(d)) { *decpt = 1; - result = Balloc(2); - s0 = (char *)(void *)result; - strcpy(s0, "0"); - if (rve) - *rve = s0 + 1; - return s0; - } + result = Balloc(2); + s0 = (char *)(void *)result; + strcpy(s0, "0"); + if (rve) + *rve = s0 + 1; + return s0; + } b = d2b(value(d), &be, &bbits); #ifdef Sudden_Underflow @@ -2114,7 +2113,7 @@ __dtoa #endif #ifndef Sudden_Underflow denorm = 0; - } + } else { /* d is denormalized */ @@ -2125,7 +2124,7 @@ __dtoa word0(d2) -= 31*Exp_msk1; /* adjust exponent */ i -= (Bias + (P-1) - 1) + 1; denorm = 1; - } + } #endif ds = (value(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; @@ -2137,33 +2136,33 @@ __dtoa if (value(d) < tens[k]) k--; k_check = 0; - } + } j = bbits - i - 1; if (j >= 0) { b2 = 0; s2 = j; - } + } else { b2 = -j; s2 = 0; - } + } if (k >= 0) { b5 = 0; s5 = k; s2 += k; - } + } else { b2 -= k; b5 = -k; s5 = 0; - } + } if (mode < 0 || mode > 9) mode = 0; try_quick = 1; if (mode > 5) { mode -= 4; try_quick = 0; - } + } leftright = 1; switch(mode) { case 0: @@ -2189,7 +2188,7 @@ __dtoa ilim1 = i - 1; if (i <= 0) i = 1; - } + } j = sizeof(ULong); for(result_k = 0; (int)(sizeof(Bigint) - sizeof(ULong)) + j <= i; j <<= 1) result_k++; @@ -2225,7 +2224,7 @@ __dtoa ds *= bigtens[i]; } value(d) /= ds; - } + } else if ((jj1 = -k) != 0) { value(d) *= tens[jj1 & 0xf]; for(j = (unsigned int)jj1 >> 4; j; @@ -2233,8 +2232,8 @@ __dtoa if (j & 1) { ieps++; value(d) *= bigtens[i]; - } - } + } + } if (k_check && value(d) < 1. && ilim > 0) { if (ilim1 <= 0) goto fast_failed; @@ -2242,7 +2241,7 @@ __dtoa k--; value(d) *= 10.; ieps++; - } + } value(eps) = ieps*value(d) + 7.; word0(eps) -= (P-1)*Exp_msk1; if (ilim == 0) { @@ -2253,7 +2252,7 @@ __dtoa if (value(d) < -value(eps)) goto no_digits; goto fast_failed; - } + } #ifndef No_leftright if (leftright) { /* Use Steele & White method of only @@ -2273,7 +2272,7 @@ __dtoa value(eps) *= 10.; value(d) *= 10.; } - } + } else { #endif /* Generate ilim digits, then fix them up. */ @@ -2291,17 +2290,17 @@ __dtoa goto ret1; } break; - } } -#ifndef No_leftright } +#ifndef No_leftright + } #endif fast_failed: s = s0; value(d) = value(d2); k = k0; ilim = ilim0; - } + } /* Do we have a "small" integer? */ @@ -2313,7 +2312,7 @@ __dtoa if (ilim < 0 || value(d) <= 5*ds) goto no_digits; goto one_digit; - } + } for(i = 1;; i++) { L = value(d) / ds; value(d) -= L*ds; @@ -2322,7 +2321,7 @@ __dtoa if (value(d) < 0) { L--; value(d) += ds; - } + } #endif *s++ = '0' + (int)L; if (i == ilim) { @@ -2334,16 +2333,16 @@ __dtoa k++; *s = '0'; break; - } + } ++*s++; - } - break; } + break; + } if (!(value(d) *= 10.)) break; } goto ret1; - } + } m2 = b2; m5 = b5; @@ -2359,7 +2358,7 @@ __dtoa #else 1 + P - bbits; #endif - } + } else { j = ilim - 1; if (m5 >= j) @@ -2368,22 +2367,22 @@ __dtoa s5 += j -= m5; b5 += j; m5 = 0; - } + } if ((i = ilim) < 0) { m2 -= i; i = 0; - } } + } b2 += i; s2 += i; mhi = i2b(1); - } + } if (m2 > 0 && s2 > 0) { i = m2 < s2 ? m2 : s2; b2 -= i; m2 -= i; s2 -= i; - } + } if (b5 > 0) { if (leftright) { if (m5 > 0) { @@ -2391,13 +2390,13 @@ __dtoa b1 = mult(mhi, b); Bfree(b); b = b1; - } + } if ((j = b5 - m5) != 0) b = pow5mult(b, j); } else b = pow5mult(b, b5); - } + } S = i2b(1); if (s5 > 0) S = pow5mult(S, s5); @@ -2417,7 +2416,7 @@ __dtoa } else spec_case = 0; - } + } /* Arrange for convenient computation of quotients: * shift left if necessary so divisor has 4 leading 0 bits. @@ -2438,13 +2437,13 @@ __dtoa b2 += i; m2 += i; s2 += i; - } + } else if (i < 4) { i += 28; b2 += i; m2 += i; s2 += i; - } + } if (b2 > 0) b = lshift(b, b2); if (s2 > 0) @@ -2457,19 +2456,19 @@ __dtoa mhi = multadd(mhi, 10, 0); ilim = ilim1; } - } + } if (ilim <= 0 && mode > 2) { if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { /* no digits, fcvt style */ no_digits: k = -1 - ndigits; goto ret; - } + } one_digit: *s++ = '1'; k++; goto ret; - } + } if (leftright) { if (m2 > 0) mhi = lshift(mhi, m2); @@ -2483,7 +2482,7 @@ __dtoa mhi = Balloc(mhi->k); Bcopy(mhi, mlo); mhi = lshift(mhi, Log2P); - } + } for(i = 1;;i++) { dig = quorem(b,S) + '0'; @@ -2502,7 +2501,7 @@ __dtoa dig++; *s++ = dig; goto ret; - } + } #endif if (j < 0 || (j == 0 && !mode #ifndef ROUND_BIASED @@ -2518,7 +2517,7 @@ __dtoa } *s++ = dig; goto ret; - } + } if (jj1 > 0) { if (dig == '9') { /* possible if i == 1 */ round_9_up: @@ -2527,7 +2526,7 @@ __dtoa } *s++ = dig + 1; goto ret; - } + } *s++ = dig; if (i == ilim) break; @@ -2537,16 +2536,16 @@ __dtoa else { mlo = multadd(mlo, 10, 0); mhi = multadd(mhi, 10, 0); - } } } + } else for(i = 1;; i++) { *s++ = dig = quorem(b,S) + '0'; if (i >= ilim) break; b = multadd(b, 10, 0); - } + } /* Round off last digit */ @@ -2561,18 +2560,18 @@ __dtoa goto ret; } ++*s++; - } + } else { while(*--s == '0'); s++; - } + } ret: Bfree(S); if (mhi) { if (mlo && mlo != mhi) Bfree(mlo); Bfree(mhi); - } + } ret1: Bfree(b); if (s == s0) { /* don't return empty string */ @@ -2584,7 +2583,7 @@ __dtoa if (rve) *rve = s; return s0; - } +} #ifdef __cplusplus } #endif diff --git a/libc/stdlib/strtoimax.c b/libc/stdlib/strtoimax.c index a742eb9..0b4323d 100644 --- a/libc/stdlib/strtoimax.c +++ b/libc/stdlib/strtoimax.c @@ -103,7 +103,7 @@ strtoimax(const char *nptr, char **endptr, int base) cutoff = INTMAX_MAX / x; \ }; \ break - + switch (base) { case 4: if (neg) { @@ -118,13 +118,13 @@ strtoimax(const char *nptr, char **endptr, int base) CASE_BASE(8); CASE_BASE(10); CASE_BASE(16); - default: + default: cutoff = neg ? INTMAX_MIN : INTMAX_MAX; cutlim = cutoff % base; cutoff /= base; } #undef CASE_BASE - + if (neg) { if (cutlim > 0) { cutlim -= base; diff --git a/libc/stdlib/strtoumax.c b/libc/stdlib/strtoumax.c index ec45377..e1ff623 100644 --- a/libc/stdlib/strtoumax.c +++ b/libc/stdlib/strtoumax.c @@ -57,7 +57,7 @@ strtoumax(const char *nptr, char **endptr, int base) if (c == '-') { neg = 1; c = *s++; - } else { + } else { neg = 0; if (c == '+') c = *s++; @@ -76,7 +76,7 @@ strtoumax(const char *nptr, char **endptr, int base) case x: cutoff = UINTMAX_MAX / x; \ cutlim = UINTMAX_MAX % x; \ break - + switch (base) { CASE_BASE(8); CASE_BASE(10); @@ -85,7 +85,7 @@ strtoumax(const char *nptr, char **endptr, int base) cutoff = UINTMAX_MAX / base; cutlim = UINTMAX_MAX % base; } - + for (acc = 0, any = 0;; c = (unsigned char) *s++) { if (isdigit(c)) c -= '0'; diff --git a/libc/stdlib/wchar.c b/libc/stdlib/wchar.c index d805333..0bbdaa9 100644 --- a/libc/stdlib/wchar.c +++ b/libc/stdlib/wchar.c @@ -387,7 +387,7 @@ size_t wcsxfrm(wchar_t *ws1, const wchar_t *ws2, size_t n) int wctob(wint_t c) { - return c; + return c; } wctype_t wctype(const char *property) |