X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=strbuf.c;h=5135d5950d9a5ea3ce8064e5491e53da17645da9;hb=926b1ec63ee045503f609e88ca445b94c06bd5d7;hp=ff0b96b4162bd92162a7eb05eee5be7a5ec2b6ba;hpb=87cb3b82a42613dc3ffd1eddf95f8c306a045ad1;p=git.git diff --git a/strbuf.c b/strbuf.c index ff0b96b41..5135d5950 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;