1
0
Fork 0

remove broken fdputd(3)

This commit is contained in:
dtb 2022-09-18 10:48:37 -04:00
parent 9189124f2d
commit fd8f2bee3e
1 changed files with 2 additions and 29 deletions

View File

@ -1,5 +1,3 @@
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#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
);