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)
22 z = memchr(f->rpos, '\n', f->rend - f->rpos);
23 k = z ? z - f->rpos + 1 : f->rend - f->rpos;
25 memcpy(p, f->rpos, k);
30 if ((c = getc_unlocked(f)) < 0) {
31 if (p==s || !feof(f)) s = 0;
35 if ((*p++ = c) == '\n') break;
44 weak_alias(fgets, fgets_unlocked);