avoid depending on POSIX symbol in code used from plain C functions

This commit is contained in:
Rich Felker 2012-04-17 13:17:01 -04:00
parent 03de77f521
commit 8b57a81577

View File

@ -3,7 +3,9 @@
size_t __string_read(FILE *f, unsigned char *buf, size_t len)
{
char *src = f->cookie;
size_t k = strnlen(src, len+256);
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);