diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-20 09:31:12 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-20 09:31:12 +0100 |
| commit | 9b2653be1ef81437fe73fe9a8670ab3fcddeda78 (patch) | |
| tree | f1e8091570bf48e9bf115d6e70e92fbc83ffd837 | |
| parent | Fix blind-from-text, blind-to-text works (diff) | |
| download | blind-9b2653be1ef81437fe73fe9a8670ab3fcddeda78.tar.gz blind-9b2653be1ef81437fe73fe9a8670ab3fcddeda78.tar.bz2 blind-9b2653be1ef81437fe73fe9a8670ab3fcddeda78.tar.xz | |
Forgot to commit a file
Signed-off-by: Mattias Andrée <maandree@kth.se>
| -rw-r--r-- | src/stream.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/stream.c b/src/stream.c index 04dd516..4b2cc23 100644 --- a/src/stream.c +++ b/src/stream.c @@ -17,13 +17,17 @@ eninit_stream(int status, struct stream *stream) size_t n; char *p = NULL, *w, *h, *f, *end; - for (stream->ptr = 0; stream->fd >= 0 && !p;) { - r = read(stream->fd, stream->buf + stream->ptr, sizeof(stream->buf) - stream->ptr); - if (r < 0) - enprintf(status, "read %s:", stream->file); - if (r == 0) - goto bad_format; - stream->ptr += (size_t)r; + if (stream->fd >= 0) { + for (stream->ptr = 0; !p;) { + r = read(stream->fd, stream->buf + stream->ptr, sizeof(stream->buf) - stream->ptr); + if (r < 0) + enprintf(status, "read %s:", stream->file); + if (r == 0) + goto bad_format; + stream->ptr += (size_t)r; + p = memchr(stream->buf, '\n', stream->ptr); + } + } else { p = memchr(stream->buf, '\n', stream->ptr); } @@ -281,7 +285,7 @@ nprocess_multiple_streams(int status, struct stream *streams, size_t n_streams, while (n_streams) { n = SIZE_MAX; for (i = 0; i < n_streams; i++) { - if (streams[i].ptr < sizeof(streams->buf) && !eread_stream(streams + i, SIZE_MAX)) { + if (streams[i].ptr < sizeof(streams->buf) && !enread_stream(status, streams + i, SIZE_MAX)) { close(streams[i].fd); streams[i].fd = -1; } |
