musl/src/stdio/__string_read.c
Rich Felker 835f9f950e clean up stdio_impl.h
this header evolved to facilitate the extremely lazy practice of
omitting explicit includes of the necessary headers in individual
stdio source files; not only was this sloppy, but it also increased
build time.

now, stdio_impl.h is only including the headers it needs for its own
use; any further headers needed by source files are included directly
where needed.
2012-11-08 16:39:41 -05:00

16 lines
349 B
C

#include "stdio_impl.h"
#include <string.h>
size_t __string_read(FILE *f, unsigned char *buf, size_t len)
{
char *src = f->cookie;
size_t k = len+256;
char *end = memchr(src, 0, k);
if (end) k = end-src;
if (k < len) len = k;
memcpy(buf, src, len);
f->rpos = (void *)(src+len);
f->rend = (void *)(src+k);
f->cookie = src+k;
return len;
}