| 497 | } |
| 498 | |
| 499 | cc_result Stream_WriteLine(struct Stream* s, cc_string* text) { |
| 500 | cc_uint8 buffer[2048 + 10]; /* some space for newline */ |
| 501 | const char* nl; |
| 502 | cc_uint8* cur; |
| 503 | cc_result res; |
| 504 | int i, len = 0; |
| 505 | |
| 506 | for (i = 0; i < text->length; i++) { |
| 507 | /* For extremely large strings */ |
| 508 | if (len >= 2048) { |
| 509 | if ((res = Stream_Write(s, buffer, len))) return res; |
| 510 | len = 0; |
| 511 | } |
| 512 | |
| 513 | cur = buffer + len; |
| 514 | len += Convert_CP437ToUtf8(text->buffer[i], cur); |
| 515 | } |
| 516 | |
| 517 | nl = _NL; |
| 518 | while (*nl) { buffer[len++] = *nl++; } |
| 519 | return Stream_Write(s, buffer, len); |
| 520 | } |
no test coverage detected