aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-08-21 18:47:44 -0700
committerJunio C Hamano <gitster@pobox.com>2009-08-21 18:47:44 -0700
commitbcd45e27d8790d8981d4c6734bc573363121efd3 (patch)
tree8693e3c78697d0ad72c976e798276c635bbc15cf /strbuf.c
parentf5d5ea525b6aa8b6435d4e8c92f5e797b4076fc0 (diff)
parentc2ca1d79dbd54b06a05e5d14a897699e59dc9f9f (diff)
downloadgit-bcd45e27d8790d8981d4c6734bc573363121efd3.tar.gz
git-bcd45e27d8790d8981d4c6734bc573363121efd3.tar.xz
Merge branch 'bc/mailsplit-cr-at-eol'
* bc/mailsplit-cr-at-eol: Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings builtin-mailsplit.c: remove read_line_with_nul() since it is no longer used builtin-mailinfo,builtin-mailsplit: use strbufs strbuf: add new function strbuf_getwholeline()
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/strbuf.c b/strbuf.c
index f03d11702..a6153dca2 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -322,7 +322,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
return -1;
}
-int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
+int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term)
{
int ch;
@@ -332,10 +332,10 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
strbuf_reset(sb);
while ((ch = fgetc(fp)) != EOF) {
- if (ch == term)
- break;
strbuf_grow(sb, 1);
sb->buf[sb->len++] = ch;
+ if (ch == term)
+ break;
}
if (ch == EOF && sb->len == 0)
return EOF;
@@ -344,6 +344,15 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
return 0;
}
+int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
+{
+ if (strbuf_getwholeline(sb, fp, term))
+ return EOF;
+ if (sb->buf[sb->len-1] == term)
+ strbuf_setlen(sb, sb->len-1);
+ return 0;
+}
+
int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
{
int fd, len;