diff options
author | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2016-11-17 22:58:16 +0100 |
---|---|---|
committer | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2016-11-17 22:58:16 +0100 |
commit | ed76659c054ce781ae6050e563de9ad40b3d25cd (patch) | |
tree | 5e13e5b83248248c6462b1d0514971f7aa8e6dfd /sys/src/libstdio | |
parent | 28f4567ba615c4036c079021392825757ef2a008 (diff) |
/sys/src/lib*: clean up
Diffstat (limited to 'sys/src/libstdio')
-rw-r--r-- | sys/src/libstdio/dtoa.c | 124 | ||||
-rw-r--r-- | sys/src/libstdio/setvbuf.c | 11 |
2 files changed, 5 insertions, 130 deletions
diff --git a/sys/src/libstdio/dtoa.c b/sys/src/libstdio/dtoa.c index f8de75dbe..80fd3c73e 100644 --- a/sys/src/libstdio/dtoa.c +++ b/sys/src/libstdio/dtoa.c @@ -151,34 +151,6 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */ return b; } -static Bigint * -s2b(const char *s, int nd0, int nd, unsigned int y9) -{ - Bigint * b; - int i, k; - int x, y; - - x = (nd + 8) / 9; - for (k = 0, y = 1; x > y; y <<= 1, k++) - ; - b = Balloc(k); - b->x[0] = y9; - b->wds = 1; - - i = 9; - if (9 < nd0) { - s += 9; - 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(register unsigned int x) { @@ -483,18 +455,6 @@ diff(Bigint *a, Bigint *b) return c; } -static double -ulp(FPdbleword x) -{ - int L; - FPdbleword a; - - L = (fpword0(x) & Exp_mask) - (P - 1) * Exp_msk1; - fpword0(a) = L; - fpword1(a) = 0; - return a.x; -} - static FPdbleword b2d(Bigint *a, int *e) { @@ -567,24 +527,6 @@ d2b(FPdbleword d, int *e, int *bits) #undef d0 #undef d1 -static double -ratio(Bigint *a, Bigint *b) -{ - FPdbleword da, db; - int k, ka, kb; - - da = b2d(a, &ka); - db = b2d(b, &kb); - k = ka - kb + 32 * (a->wds - b->wds); - if (k > 0) - fpword0(da) += k * Exp_msk1; - else { - k = -k; - fpword0(db) += k * Exp_msk1; - } - return da.x / db.x; -} - static const double tens[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, @@ -596,11 +538,6 @@ static const double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; -static const double tinytens[] = { - 1e-16, 1e-32, 1e-64, 1e-128, - 9007199254740992.e-256 -}; - /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ /* flag unnecessarily. It leads to a song and dance at the end of strtod. */ #define Scale_Bit 0x10 @@ -611,67 +548,6 @@ static const double tinytens[] = { #define NAN_WORD1 0 static int -match(const char **sp, char *t) -{ - int c, d; - const char * s = *sp; - - while (d = *t++) { - if ((c = *++s) >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != d) - return 0; - } - *sp = s + 1; - return 1; -} - -static void -gethex(FPdbleword *rvp, const char **sp) -{ - unsigned int c, x[2]; - const char * s; - int havedig, udx0, xshift; - - x[0] = x[1] = 0; - havedig = xshift = 0; - udx0 = 1; - s = *sp; - while (c = *(const unsigned char * )++s) { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'a' && c <= 'f') - c += 10 - 'a'; - else if (c >= 'A' && c <= 'F') - c += 10 - 'A'; - else if (c <= ' ') { - if (udx0 && havedig) { - udx0 = 0; - xshift = 1; - } - continue; - } else if (/*(*/ c == ')') { - *sp = s + 1; - break; - } else - return; /* invalid form: don't change *sp */ - havedig = 1; - if (xshift) { - xshift = 0; - x[0] = x[1]; - x[1] = 0; - } - if (udx0) - x[0] = (x[0] << 4) | (x[1] >> 28); - x[1] = (x[1] << 4) | c; - } - if ((x[0] &= 0xfffff) || x[1]) { - fpword0(*rvp) = Exp_mask | x[0]; - fpword1(*rvp) = x[1]; - } -} - -static int quorem(Bigint *b, Bigint *S) { int n; diff --git a/sys/src/libstdio/setvbuf.c b/sys/src/libstdio/setvbuf.c index 34c3bf7c8..e63e8db9d 100644 --- a/sys/src/libstdio/setvbuf.c +++ b/sys/src/libstdio/setvbuf.c @@ -31,12 +31,6 @@ int setvbuf(FILE *f, char *buf, int mode, long size){ f->state=RDWR; return 0; } -int _IO_setvbuf(FILE *f){ - static int isatty(int); - if(f==stderr || (f==stdout && isatty(1))) - return setvbuf(f, (char *)0, _IOLBF, BUFSIZ); - else return setvbuf(f, (char *)0, _IOFBF, BUFSIZ); -} static int isatty(int fd) { @@ -48,3 +42,8 @@ isatty(int fd) /* might be /mnt/term/dev/cons */ return strlen(buf) >= 9 && strcmp(buf+strlen(buf)-9, "/dev/cons") == 0; } +int _IO_setvbuf(FILE *f){ + if(f==stderr || (f==stdout && isatty(1))) + return setvbuf(f, (char *)0, _IOLBF, BUFSIZ); + else return setvbuf(f, (char *)0, _IOFBF, BUFSIZ); +} |