1 #include "stdio_impl.h"
3 #define MIN(a,b) ((a)<(b) ? (a) : (b))
5 char *fgets(char *s, int n, FILE *f)
21 z = memchr(f->rpos, '\n', f->rend - f->rpos);
22 k = z ? z - f->rpos + 1 : f->rend - f->rpos;
24 memcpy(p, f->rpos, k);
29 if ((c = getc_unlocked(f)) < 0) {
30 if (p==s || !feof(f)) s = 0;
34 if ((*p++ = c) == '\n') break;
43 weak_alias(fgets, fgets_unlocked);