simplifications
This commit is contained in:
parent
d588d7097c
commit
5f15b515e1
@ -1,10 +1,8 @@
|
||||
#include "tests.h"
|
||||
#include "simple_getline.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[8192];
|
||||
size_t bufsize = 0;
|
||||
FILE *f = argc > 1 ? fopen(argv[1], "r") : NULL;
|
||||
utf8proc_uint8_t src[1024];
|
||||
int len;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "tests.h"
|
||||
#include "simple_getline.h"
|
||||
|
||||
#define CHECK_NORM(NRM, norm, src) { \
|
||||
char *src_norm = (char*) utf8proc_ ## NRM((utf8proc_uint8_t*) src); \
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
/* simplistic, portable replacement for getline, sufficient for our tests */
|
||||
static size_t simple_getline(char buf[8192], FILE *f) {
|
||||
size_t i = 0;
|
||||
while (i < 1023) {
|
||||
int c = getc(f);
|
||||
if (c == EOF || c == '\n') break;
|
||||
buf[i++] = (char) c;
|
||||
}
|
||||
buf[i] = 0;
|
||||
return i;
|
||||
}
|
||||
12
test/tests.c
12
test/tests.c
@ -44,3 +44,15 @@ size_t encode(char *dest, const char *buf)
|
||||
d += utf8proc_encode_char(c, (utf8proc_uint8_t *) (dest + d));
|
||||
}
|
||||
}
|
||||
|
||||
/* simplistic, portable replacement for getline, sufficient for our tests */
|
||||
size_t simple_getline(char buf[8192], FILE *f) {
|
||||
size_t i = 0;
|
||||
while (i < 1023) {
|
||||
int c = getc(f);
|
||||
if (c == EOF || c == '\n') break;
|
||||
buf[i++] = (char) c;
|
||||
}
|
||||
buf[i] = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -21,3 +21,4 @@ extern size_t lineno;
|
||||
void check(int cond, const char *format, ...);
|
||||
size_t skipspaces(const char *buf, size_t i);
|
||||
size_t encode(char *dest, const char *buf);
|
||||
size_t simple_getline(char buf[8192], FILE *f);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user