files rename/cleanup (+ dropped inflatePrime method)

master
Vitaly Puzrin 2014-04-10 07:06:04 +04:00
rodzic 471505d113
commit 195e40c0df
3 zmienionych plików z 38 dodań i 48 usunięć

Wyświetl plik

@ -256,22 +256,6 @@ function inflateInit(strm) {
return inflateInit2(strm, DEF_WBITS);
}
function inflatePrime(strm, bits, value) {
var state;
if (!strm || !strm.state) { return Z_STREAM_ERROR; }
state = strm.state;
if (bits < 0) {
state.hold = 0;
state.bits = 0;
return Z_OK;
}
if (bits > 16 || state.bits + bits > 32) { return Z_STREAM_ERROR; }
value &= (1 << bits) - 1;
state.hold += value << state.bits;
state.bits += bits;
return Z_OK;
}
/*
Return state with length and distance decoding tables and index sizes set to
@ -406,10 +390,10 @@ function inflate(strm, flush) {
[16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
// TODO: check if needed and don't affect speed
//if (strm === Z_NULL || strm.state === Z_NULL || strm.next_out === Z_NULL ||
// (strm.next_in === Z_NULL && strm.avail_in !== 0))
// return Z_STREAM_ERROR;
if (!strm || !strm.state || !strm.next_out ||
(!strm.next_in && strm.avail_in !== 0)) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
@ -1463,8 +1447,11 @@ function inflate(strm, flush) {
}
function inflateEnd(strm) {
// if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
// return Z_STREAM_ERROR;
if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
return Z_STREAM_ERROR;
}
var state = strm.state;
if (state.window) {
state.window = null;
@ -1493,7 +1480,6 @@ exports.inflateReset2 = inflateReset2;
exports.inflateResetKeep = inflateResetKeep;
exports.inflateInit = inflateInit;
exports.inflateInit2 = inflateInit2;
exports.inflatePrime = inflatePrime;
exports.inflate = inflate;
exports.inflateEnd = inflateEnd;
exports.inflateGetHeader = inflateGetHeader;
@ -1507,4 +1493,5 @@ exports.inflateSyncPoint = inflateSyncPoint;
exports.inflateCopy = inflateCopy;
exports.inflateUndermine = inflateUndermine;
exports.inflateMark = inflateMark;
exports.inflatePrime = inflatePrime;
*/

Wyświetl plik

@ -17,8 +17,9 @@ function a2s(array) {
}
describe('Inflate gzip header', function() {
it('Check headers content from prepared file', function() {
describe('Gzip special cases', function() {
it('Read custom headers', function() {
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-headers.gz'));
var inflator = new pako.Inflate();
inflator.push(data, true);
@ -27,10 +28,8 @@ describe('Inflate gzip header', function() {
assert.equal(inflator.header.comment, 'test comment');
assert.equal(a2s(inflator.header.extra), 'test extra');
});
});
describe('Inflate gzip joined', function() {
it('Check content from prepared file', function() {
it('Read stream with SYNC marks', function() {
var inflator, strm, _in, len, pos = 0, i = 0;
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-joined.gz'));
@ -51,4 +50,5 @@ describe('Inflate gzip joined', function() {
assert(i === 2, 'invalid blobs count');
});
});

Wyświetl plik

@ -1,3 +1,5 @@
// This tests are ported from original zlib
/*global describe, it*/
@ -8,7 +10,7 @@ var assert = require('assert');
var c = require('../lib/zlib/constants');
var msg = require('../lib/zlib/messages');
var zlib_stream = require('../lib/zlib/zstream');
//var zlib_stream = require('../lib/zlib/zstream');
var zlib_inflate = require('../lib/zlib/inflate.js');
var inflate_table = require('../lib/zlib/inftrees');
@ -36,20 +38,20 @@ function testInflate(hex, wbits, status) {
describe('Inflate states', function() {
// //in port checking input parameters was removed
// it.skip('inflate bad parameters', function() {
// var ret;
//
// ret = zlib_inflate.inflate(null, 0);
// assert(ret == c.Z_STREAM_ERROR);
//
// ret = zlib_inflate.inflateEnd(null);
// assert(ret == c.Z_STREAM_ERROR);
//
// //skip: inflateCopy is not implemented
// //ret = zlib_inflate.inflateCopy(null, null);
// //assert(ret == c.Z_STREAM_ERROR);
// });
//in port checking input parameters was removed
it('inflate bad parameters', function() {
var ret;
ret = zlib_inflate.inflate(null, 0);
assert(ret === c.Z_STREAM_ERROR);
ret = zlib_inflate.inflateEnd(null);
assert(ret === c.Z_STREAM_ERROR);
//skip: inflateCopy is not implemented
//ret = zlib_inflate.inflateCopy(null, null);
//assert(ret == c.Z_STREAM_ERROR);
});
it('bad gzip method', function() {
testInflate('1f 8b 0 0', 31, c.Z_DATA_ERROR);
});
@ -203,7 +205,8 @@ describe('Inflate fast', function() {
});
describe('Inflate support', function() {
it('prime', function() {
// `inflatePrime` not implemented
/*it('prime', function() {
var ret;
var strm = new zlib_stream();
strm.avail_in = 0;
@ -218,13 +221,13 @@ describe('Inflate support', function() {
ret = zlib_inflate.inflatePrime(strm, -1, 0);
assert(ret === c.Z_OK);
// skipped: inflateSetDictionary is not implemented
// ret = inflateSetDictionary(strm, null, 0);
// assert(ret === c.Z_STREAM_ERROR);
// `inflateSetDictionary` not implemented
// ret = zlib_inflate.inflateSetDictionary(strm, null, 0);
// assert(ret === c.Z_STREAM_ERROR);
ret = zlib_inflate.inflateEnd(strm);
assert(ret === c.Z_OK);
});
});*/
it('force window allocation', function() {
testInflate('63 0', -15, c.Z_OK);
});