standard library 9 from skid row
This commit is contained in:
parent
07216c778a
commit
f0362041c0
11
lib/libio.c
11
lib/libio.c
@ -1,3 +1,4 @@
|
|||||||
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -9,10 +10,10 @@ _strlen(char *s){
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SLOW. DO NOT USE. */
|
||||||
static int write1(int fd, int c){
|
static int write1(int fd, int c){
|
||||||
int *s;
|
while(write(fd, &c, 1) != 1);
|
||||||
s = &c;
|
return 1;
|
||||||
while(write(fd, s, 1) != 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdputd(int fd, int d){
|
int fdputd(int fd, int d){
|
||||||
@ -27,9 +28,9 @@ int fdputd(int fd, int d){
|
|||||||
}
|
}
|
||||||
for(s = 10; d > (s *= 10););
|
for(s = 10; d > (s *= 10););
|
||||||
put: while(s > 0){
|
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)
|
if((s /= 10) == 0)
|
||||||
r += write1(fd, "\n", 1);
|
r += write1(1, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user