1 #include "stdio_impl.h"
4 #define MIN(a,b) ((a)<(b) ? (a) : (b))
6 char *fgets(char *restrict s, int n, FILE *restrict f)
24 z = memchr(f->rpos, '\n', f->rend - f->rpos);
25 k = z ? z - f->rpos + 1 : f->rend - f->rpos;
27 memcpy(p, f->rpos, k);
32 if ((c = getc_unlocked(f)) < 0) {
33 if (p==s || !feof(f)) s = 0;
37 if ((*p++ = c) == '\n') break;
46 weak_alias(fgets, fgets_unlocked);