diff --git a/libio/libio.c b/libio/libio.c index 4cdeea6..35e988b 100644 --- a/libio/libio.c +++ b/libio/libio.c @@ -1,5 +1,3 @@ -#include -#include #include #include "libio.h" @@ -57,37 +55,12 @@ fdprint(int fd, char *s){ return _write(fd, s, strlen(s)); } -int -fdputd(int fd, int d){ - int r; - int s; - - r = 0; - /* Just an implementation looking for a math person to improve it... */ - /* Rather than storing the log base 10 of d, store 10^(log base 10 (d)) - * which requires less Weird Hax. Then slowly chop off digits and print - * out the system encoding's representations. Finally, print a newline. - * Generally this function is slow and sucks implementation-wise. */ - if(d < 100){ - s = d < 10 ? 1 : 10; - goto put; - } - for(s = 10; d > (s *= 10);); -put: while(s > 0){ - r += _write1(fd, (d - (d % s)) / s + '0'); - if((s /= 10) == 0) - r += _write1(fd, '\n'); - } - - return r; -} - int fdputs(int fd, char *s){ int i; int r; - i = strlen(s); + i = _strlen(s); /* RACE CONDITION */ /* This leaves s as an invalid string while the write(2) syscall is @@ -108,7 +81,7 @@ parse_uint(char *s){ unsigned int r; for( r = 0; - isdigit(*s); + _isdigit(*s); r = r * 10 + *s - '0', ++s );