source:
asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/stdio/fgetln.c
Last change on this file was 352, checked in by , 6 years ago | |
---|---|
|
|
File size: 430 bytes |
Rev | Line | |
---|---|---|
[352] | 1 | #define _GNU_SOURCE |
2 | #include "stdio_impl.h" | |
3 | #include <string.h> | |
4 | ||
5 | char *fgetln(FILE *f, size_t *plen) | |
6 | { | |
7 | char *ret = 0, *z; | |
8 | ssize_t l; | |
9 | FLOCK(f); | |
10 | ungetc(getc_unlocked(f), f); | |
11 | if ((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; | |
18 | } | |
19 | FUNLOCK(f); | |
20 | return ret; | |
21 | } |
Note:
See TracBrowser
for help on using the repository browser.