| 3623 | } |
| 3624 | |
| 3625 | static char *fgets_unlocked(char *s, int size, FILE *stream) |
| 3626 | { |
| 3627 | if (stdio_stream_read_init(stream) < 0) |
| 3628 | return NULL; |
| 3629 | int i; |
| 3630 | for (i = 0; i < size-1; i++) |
| 3631 | { |
| 3632 | int c; |
| 3633 | if (stream->read_ptr < stream->read_end) |
| 3634 | c = (int)*stream->read_ptr++; |
| 3635 | else |
| 3636 | { |
| 3637 | c = fgetc_unlocked(stream); |
| 3638 | if (feof_unlocked(stream)) |
| 3639 | break; |
| 3640 | if (ferror_unlocked(stream)) |
| 3641 | return NULL; |
| 3642 | } |
| 3643 | s[i] = c; |
| 3644 | if (c == '\n') |
| 3645 | { |
| 3646 | i++; |
| 3647 | break; |
| 3648 | } |
| 3649 | } |
| 3650 | s[i] = '\0'; |
| 3651 | return s; |
| 3652 | } |
| 3653 | |
| 3654 | static char *fgets(char *s, int size, FILE *stream) |
| 3655 | { |
no test coverage detected