X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=strbuf.c;h=a849705197a6ad3d0d2ab9de22b269de6b4fc2b1;hb=3c4b5ad5a5d4356948f1207908bd3ba62b1a7773;hp=3ad2cc00160fbf24e1e4904bb37ce44e8c414ce5;hpb=de263479506066f240cf629aa3aac50c94668d89;p=git.git diff --git a/strbuf.c b/strbuf.c index 3ad2cc001..a84970519 100644 --- a/strbuf.c +++ b/strbuf.c @@ -397,3 +397,17 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) return len; } + +void strbuf_add_lines(struct strbuf *out, const char *prefix, + const char *buf, size_t size) +{ + while (size) { + const char *next = memchr(buf, '\n', size); + next = next ? (next + 1) : (buf + size); + strbuf_addstr(out, prefix); + strbuf_add(out, buf, next - buf); + size -= next - buf; + buf = next; + } + strbuf_complete_line(out); +}