aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2012-02-28 12:23:26 +0800
committerJiang Xin <worldhello.net@gmail.com>2012-02-28 12:23:26 +0800
commit508d1244dc8d38188c70e98207efa8a97d16b47c (patch)
treefc8688b80be453755f8135df11bf1db2d247725a /strbuf.c
parent0ad9e96d2e2f42f4d2ce7cd612bf741913242bc0 (diff)
parent25a7850a106ed0f27b88b8ce0b89fd326120dff4 (diff)
downloadgit-508d1244dc8d38188c70e98207efa8a97d16b47c.tar.gz
git-508d1244dc8d38188c70e98207efa8a97d16b47c.tar.xz
Merge branch 'master' into git-po
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c16
1 files changed, 16 insertions, 0 deletions
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;