1
0
Fork 0

p8: fixed issue with p8 not following ANSI C standard

This commit is contained in:
H Hautakoski 2010-08-19 12:53:18 +02:00
parent 1c210b879d
commit 5e39e3554e
5 changed files with 73 additions and 25 deletions

24
lib/io.c Normal file
View file

@ -0,0 +1,24 @@
#include "io.h"
int readnum(FILE *fd, char *buf, size_t len) {
int i = 0;
for(;;) {
int c = getc(fd);
if (c == EOF)
break;
if (c < '0' || c > '9')
continue;
buf[i] = c;
if (i+1 > len)
break;
i++;
}
return i;
}

9
lib/io.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef __IO_H
#define __IO_H
#include <stdio.h>
int readnum(FILE *fd, char *buf, size_t len);
#endif /* __IO_H */