| 3482 | } |
| 3483 | |
| 3484 | static int fputs_unlocked(const char *s, FILE *stream) |
| 3485 | { |
| 3486 | if (stdio_stream_write_init(stream) < 0) |
| 3487 | return EOF; |
| 3488 | if (stream->write_ptr == NULL) |
| 3489 | { |
| 3490 | size_t len = strlen(s); |
| 3491 | if (stdio_stream_write_buf(stream, s, s + len) < 0) |
| 3492 | return EOF; |
| 3493 | return 0; |
| 3494 | } |
| 3495 | bool flush = false; |
| 3496 | for (; *s != 0; s++) |
| 3497 | { |
| 3498 | *stream->write_ptr++ = *s; |
| 3499 | if (stream->write_ptr >= stream->write_end) |
| 3500 | { |
| 3501 | if (stdio_stream_write(stream) < 0) |
| 3502 | return EOF; |
| 3503 | flush = false; |
| 3504 | } |
| 3505 | else if ((int)(unsigned char)*s == stream->eol) |
| 3506 | flush = true; |
| 3507 | } |
| 3508 | if (flush && stdio_stream_write(stream) < 0) |
| 3509 | return EOF; |
| 3510 | return 0; |
| 3511 | } |
| 3512 | |
| 3513 | static int fputs(const char *s, FILE *stream) |
| 3514 | { |
no test coverage detected