X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=strbuf.c;h=692cf1bd9a5e7d97d68eb44722afbdd1b59d2cda;hb=00fb2d25632191b89ac4144e1a6498470a4a1c9e;hp=3ad2cc00160fbf24e1e4904bb37ce44e8c414ce5;hpb=a4fdd79f13ec0551be94d7a3ac57e87434239f11;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;