1
0

standard library 9 from skid row

This commit is contained in:
dtb 2022-06-14 10:47:09 -04:00
parent 07216c778a
commit f0362041c0

View File

@ -1,3 +1,4 @@
#include <ctype.h>
#include <unistd.h>
static int
@ -9,10 +10,10 @@ _strlen(char *s){
return i;
}
/* SLOW. DO NOT USE. */
static int write1(int fd, int c){
int *s;
s = &c;
while(write(fd, s, 1) != 1);
while(write(fd, &c, 1) != 1);
return 1;
}
int fdputd(int fd, int d){
@ -27,9 +28,9 @@ int fdputd(int fd, int d){
}
for(s = 10; d > (s *= 10););
put: while(s > 0){
r += write1(fd, (d - (d % s)) / s + '0', 1);
r += write1(1, (d - (d % s)) / s + '0');
if((s /= 10) == 0)
r += write1(fd, "\n", 1);
r += write1(1, '\n');
}
}