iconv: add aliases for GBK
[musl.git] / src / stdio / fgetln.c
blob5748435d9f6f937c07cd448182df0cc875f0e871
1 #define _GNU_SOURCE
2 #include "stdio_impl.h"
3 #include <string.h>
5 char *fgetln(FILE *f, size_t *plen)
7 char *ret = 0, *z;
8 ssize_t l;
9 FLOCK(f);
10 ungetc(getc_unlocked(f), f);
11 if (f->rend && (z=memchr(f->rpos, '\n', f->rend - f->rpos))) {
12 ret = (char *)f->rpos;
13 *plen = ++z - ret;
14 f->rpos = (void *)z;
15 } else if ((l = getline(&f->getln_buf, (size_t[]){0}, f)) > 0) {
16 *plen = l;
17 ret = f->getln_buf;
19 FUNLOCK(f);
20 return ret;