| 372 | } |
| 373 | |
| 374 | static void add_lines(struct strbuf *out, |
| 375 | const char *prefix, |
| 376 | const char *buf, size_t size, |
| 377 | int space_after_prefix) |
| 378 | { |
| 379 | while (size) { |
| 380 | const char *next = memchr(buf, '\n', size); |
| 381 | next = next ? (next + 1) : (buf + size); |
| 382 | |
| 383 | strbuf_addstr(out, prefix); |
| 384 | if (space_after_prefix && buf[0] != '\n' && buf[0] != '\t') |
| 385 | strbuf_addch(out, ' '); |
| 386 | strbuf_add(out, buf, next - buf); |
| 387 | size -= next - buf; |
| 388 | buf = next; |
| 389 | } |
| 390 | strbuf_complete_line(out); |
| 391 | } |
| 392 | |
| 393 | void strbuf_add_commented_lines(struct strbuf *out, const char *buf, |
| 394 | size_t size, const char *comment_prefix) |
no test coverage detected