1 #include "stdio_impl.h"
3 #define MIN(a,b) ((a)<(b) ? (a) : (b))
5 char *fgets(char *s, int n, FILE *f)
15 while (n && !feof(f)) {
16 z = memchr(f->rpos, '\n', f->rend - f->rpos);
17 k = z ? z - f->rpos + 1 : f->rend - f->rpos;
19 memcpy(p, f->rpos, k);
31 return (p == s) ? 0 : s;
34 weak_alias(fgets, fgets_unlocked);