code/comments cleanup

master
Vitaly Puzrin 2015-09-14 15:01:53 +03:00
rodzic 2c504a0865
commit 5f728b177d
1 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -177,8 +177,10 @@ Inflate.prototype.push = function(data, mode) {
var chunkSize = this.options.chunkSize;
var status, _mode;
var next_out_utf8, tail, utf8str;
// allow Z_BUF_ERROR on next inflate call
var allowBufError = 0;
// Flag to properly process Z_BUF_ERROR on testing inflate call
// when we check that all output data was flushed.
var allowBufError = false;
if (this.ended) { return false; }
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
@ -205,9 +207,9 @@ Inflate.prototype.push = function(data, mode) {
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
if (status === c.Z_BUF_ERROR && allowBufError === 1) {
if (status === c.Z_BUF_ERROR && allowBufError === true) {
status = c.Z_OK;
allowBufError = 0;
allowBufError = false;
}
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
@ -238,10 +240,18 @@ Inflate.prototype.push = function(data, mode) {
}
}
}
// we need to check internal inflate buffers and state but inflate can return Z_BUF_ERROR if no output
// When no more input data, we should check that internal inflate buffers
// are flushed. The only way to do it when avail_out = 0 - run one more
// inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
// Here we set flag to process this error properly.
//
// NOTE. Deflate does not return error in this case and does not needs such
// logic.
if (strm.avail_in === 0 && strm.avail_out === 0) {
allowBufError = 1;
allowBufError = true;
}
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
if (status === c.Z_STREAM_END) {