X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=strbuf.c;h=692cf1bd9a5e7d97d68eb44722afbdd1b59d2cda;hb=fc2d99f1e95252dcd3eb645a370a658bea7fd5bd;hp=3ad2cc00160fbf24e1e4904bb37ce44e8c414ce5;hpb=b42e81afe2d98faee7728ef02a558847fd08cf90;p=git.git diff --git a/strbuf.c b/strbuf.c index 3ad2cc001..692cf1bd9 100644 --- a/strbuf.c +++ b/strbuf.c @@ -383,6 +383,22 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term) return 0; } +int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term) +{ + strbuf_reset(sb); + + while (1) { + char ch; + ssize_t len = xread(fd, &ch, 1); + if (len <= 0) + return EOF; + strbuf_addch(sb, ch); + if (ch == term) + break; + } + return 0; +} + int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) { int fd, len;