]> git.ipfire.org Git - thirdparty/git.git/commit
vcs-svn: add binary-safe read function
authorJonathan Nieder <jrnieder@gmail.com>
Mon, 3 Jan 2011 03:05:46 +0000 (21:05 -0600)
committerJonathan Nieder <jrnieder@gmail.com>
Sat, 26 Feb 2011 10:59:37 +0000 (04:59 -0600)
commite832f43c1d26bf70611d98b62d95870a99292add
tree1b24a34f03268e1061ce6ee9c679c05b9912724b
parentd280f68313eecb8b3838c70641a246382d5e5343
vcs-svn: add binary-safe read function

buffer_read_string works well for non line-oriented input except for
one problem: it does not tell the caller how many bytes were actually
written.  This means that unless one is very careful about checking
for errors (and eof) the calling program cannot tell the difference
between the string "foo" followed by an early end of file and the
string "foo\0bar\0baz".

So introduce a variant that reports the length, too, a thinner wrapper
around strbuf_fread.  Its result is written to a strbuf so the caller
does not need to keep track of the number of bytes read.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
t/t0081-line-buffer.sh
test-line-buffer.c
vcs-svn/line_buffer.c
vcs-svn/line_buffer.h