# HG changeset patch # User Timo Sirainen # Date 1452531607 -7200 # Node ID dd68e15cdc22d46d25217ff98df7b0e5e576fb18 # Parent 93b54ac4851c2e7166e88c113ce68518cef48c1b lib: i_stream_get_error() now returns "EOF" if stream_errno==0 and eof==TRUE. This can be used to replace a lot of code like: input->stream_errno == 0 ? "EOF" : i_stream_get_error(input) with simply: i_stream_get_error(input) diff -r 93b54ac4851c -r dd68e15cdc22 src/lib/istream.c --- a/src/lib/istream.c Sat Jan 09 22:55:15 2016 +0200 +++ b/src/lib/istream.c Mon Jan 11 19:00:07 2016 +0200 @@ -82,10 +82,11 @@ { struct istream *s; - /* we'll only return errors for streams that have stream_errno set. - we might be returning unintended error otherwise. */ + /* we'll only return errors for streams that have stream_errno set or + that have reached EOF. we might be returning unintended error + otherwise. */ if (stream->stream_errno == 0) - return ""; + return stream->eof ? "EOF" : ""; for (s = stream; s != NULL; s = s->real_stream->parent) { if (s->stream_errno == 0) diff -r 93b54ac4851c -r dd68e15cdc22 src/lib/istream.h --- a/src/lib/istream.h Sat Jan 09 22:55:15 2016 +0200 +++ b/src/lib/istream.h Mon Jan 11 19:00:07 2016 +0200 @@ -74,7 +74,8 @@ /* Return file descriptor for stream, or -1 if none is available. */ int i_stream_get_fd(struct istream *stream); -/* Returns error string for the last error. */ +/* Returns error string for the last error. It also returns "EOF" in case there + is no error, but eof is set. Otherwise it returns "". */ const char *i_stream_get_error(struct istream *stream); /* Mark the stream and all of its parent streams closed. Any reads after this