summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-16 14:39:37 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-16 14:39:37 -0800
commit87afe9a5ed759668e35513c44eacd2fd393ba658 (patch)
tree3f4afa5b8c9a896cee7795a3dcc1de8c0037b13d
parent284e3d280ea84957f5bedcb302848dbdcdbb9a62 (diff)
downloadgit-cn/maint-lf-to-crlf-filter.tar.gz
lf_to_crlf_filter(): tell the caller we added "\n" when drainingcn/maint-lf-to-crlf-filter
This can only happen when the input size is multiple of the buffer size of the cascade filter (16k) and ends with an LF, but in such a case, the code forgot to tell the caller that it added the "\n" it could not add during the last round. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--convert.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/convert.c b/convert.c
index c2c2c1144d..c028275c14 100644
--- a/convert.c
+++ b/convert.c
@@ -879,7 +879,7 @@ int is_null_stream_filter(struct stream_filter *filter)
struct lf_to_crlf_filter {
struct stream_filter filter;
- int want_lf;
+ unsigned want_lf:1;
};
static int lf_to_crlf_filter_fn(struct stream_filter *filter,
@@ -895,8 +895,11 @@ static int lf_to_crlf_filter_fn(struct stream_filter *filter,
lf_to_crlf->want_lf = 0;
}
- if (!input)
- return 0; /* We've already dealt with the state */
+ /* We are told to drain */
+ if (!input) {
+ *osize_p -= o;
+ return 0;
+ }
count = *isize_p;
if (count) {
@@ -931,10 +934,9 @@ static struct stream_filter_vtbl lf_to_crlf_vtbl = {
static struct stream_filter *lf_to_crlf_filter(void)
{
- struct lf_to_crlf_filter *lf_to_crlf = xmalloc(sizeof(*lf_to_crlf));
+ struct lf_to_crlf_filter *lf_to_crlf = xcalloc(1, sizeof(*lf_to_crlf));
lf_to_crlf->filter.vtbl = &lf_to_crlf_vtbl;
- lf_to_crlf->want_lf = 0;
return (struct stream_filter *)lf_to_crlf;
}