diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2020-01-07 19:09:34 -0800 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-02-07 10:44:20 +0100 |
commit | e0a711cdde1d0390a922f80b69e3b365533b34cf (patch) | |
tree | d5f71e2e28a08b5e6dde57959679198a324ec49e /gzread.c | |
parent | 550f98395c8677ae9b08ec39433f5137e5cea2c8 (diff) |
Fixed formatting, 4 spaces for code intent, 2 spaces for preprocessor indent, initial function brace on the same line as definition, removed extraneous spaces and new lines.
Diffstat (limited to 'gzread.c')
-rw-r--r-- | gzread.c | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -519,29 +519,31 @@ char * ZEXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) { the contents, let the user worry about that) */ str = buf; left = (unsigned)len - 1; - if (left) do { - /* assure that something is in the output buffer */ - if (state->x.have == 0 && gz_fetch(state) == -1) - return NULL; /* error */ - if (state->x.have == 0) { /* end of file */ - state->past = 1; /* read past end */ - break; /* return what we have */ - } - - /* look for end-of-line in current output buffer */ - n = state->x.have > left ? left : state->x.have; - eol = (unsigned char *)memchr(state->x.next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - state->x.next) + 1; - - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->x.next, n); - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); + if (left) { + do { + /* assure that something is in the output buffer */ + if (state->x.have == 0 && gz_fetch(state) == -1) + return NULL; /* error */ + if (state->x.have == 0) { /* end of file */ + state->past = 1; /* read past end */ + break; /* return what we have */ + } + + /* look for end-of-line in current output buffer */ + n = state->x.have > left ? left : state->x.have; + eol = (unsigned char *)memchr(state->x.next, '\n', n); + if (eol != NULL) + n = (unsigned)(eol - state->x.next) + 1; + + /* copy through end-of-line, or remainder if not found */ + memcpy(buf, state->x.next, n); + state->x.have -= n; + state->x.next += n; + state->x.pos += n; + left -= n; + buf += n; + } while (left && eol == NULL); + } /* return terminated string, or if nothing, end of file */ if (buf == str) |