Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: clean up zlib.gyp, don't build minizip #276

Merged
merged 7 commits into from
Jan 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions deps/zlib/zlib.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
'target_name': 'zlib',
'type': 'static_library',
'sources': [
'contrib/minizip/ioapi.c',
'contrib/minizip/ioapi.h',
'contrib/minizip/iowin32.c',
'contrib/minizip/iowin32.h',
'contrib/minizip/unzip.c',
'contrib/minizip/unzip.h',
'contrib/minizip/zip.c',
'contrib/minizip/zip.h',
'adler32.c',
'compress.c',
'crc32.c',
Expand Down Expand Up @@ -50,8 +42,6 @@
],
'include_dirs': [
'.',
# For contrib/minizip
'./contrib/minizip',
],
'direct_dependent_settings': {
'include_dirs': [
Expand All @@ -60,11 +50,8 @@
},
'conditions': [
['OS!="win"', {
'product_name': 'chrome_zlib',
'cflags!': [ '-ansi' ],
'sources!': [
'contrib/minizip/iowin32.c'
],
'defines': [ 'Z_HAVE_UNISTD_H' ],
}],
['OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="android"', {
# Mac, Android and the BSDs don't have fopen64, ftello64, or
Expand All @@ -90,14 +77,6 @@
'defines': [
'USE_SYSTEM_ZLIB',
],
'sources': [
'contrib/minizip/ioapi.c',
'contrib/minizip/ioapi.h',
'contrib/minizip/unzip.c',
'contrib/minizip/unzip.h',
'contrib/minizip/zip.c',
'contrib/minizip/zip.h',
],
'link_settings': {
'libraries': [
'-lz',
Expand Down
9 changes: 1 addition & 8 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,21 +582,14 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
self._buffer = new Buffer(self._chunkSize);
}

if (availOutAfter === 0 || availInAfter > 0) {
if (availOutAfter === 0) {
// Not actually done. Need to reprocess.
// Also, update the availInBefore to the availInAfter value,
// so that if we have to hit it a third (fourth, etc.) time,
// it'll have the correct byte counts.
inOff += (availInBefore - availInAfter);
availInBefore = availInAfter;

if (availOutAfter !== 0) {
// There is still some data available for reading.
// This is usually a concatenated stream, so, reset and restart.
self.reset();
self._offset = 0;
}

if (!async)
return true;

Expand Down
8 changes: 8 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3355,6 +3355,14 @@ void Init(int* argc,
DispatchDebugMessagesAsyncCallback);
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));

// TODO(bnoordhuis) V8 3.32 is unshipping Harmony classes for the moment.
// We're currently at 3.31, disable classes for feature parity. Remove
// again when we upgrade.
V8::SetFlagsFromString("--noharmony_classes",
sizeof("--noharmony_classes") - 1);
V8::SetFlagsFromString("--noharmony_object_literals",
sizeof("--noharmony_object_literals") - 1);

#if defined(NODE_V8_OPTIONS)
// Should come before the call to V8::SetFlagsFromCommandLine()
// so the user can disable a flag --foo at run-time by passing
Expand Down
31 changes: 7 additions & 24 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ enum node_zlib_mode {
UNZIP
};

enum node_zlib_error {
kNoError,
kFailed,
kWritePending
};

void InitZlib(v8::Handle<v8::Object> target);

Expand Down Expand Up @@ -208,7 +203,7 @@ class ZCtx : public AsyncWrap {
if (!async) {
// sync version
Process(work_req);
if (CheckError(ctx) == kNoError)
if (CheckError(ctx))
AfterSync(ctx, args);
return;
}
Expand Down Expand Up @@ -292,7 +287,7 @@ class ZCtx : public AsyncWrap {
}


static node_zlib_error CheckError(ZCtx* ctx) {
static bool CheckError(ZCtx* ctx) {
// Acceptable error states depend on the type of zlib stream.
switch (ctx->err_) {
case Z_OK:
Expand All @@ -305,18 +300,14 @@ class ZCtx : public AsyncWrap {
ZCtx::Error(ctx, "Missing dictionary");
else
ZCtx::Error(ctx, "Bad dictionary");
return kFailed;
return false;
default:
// something else.
if (ctx->strm_.total_out == 0) {
ZCtx::Error(ctx, "Zlib error");
return kFailed;
} else {
return kWritePending;
}
ZCtx::Error(ctx, "Zlib error");
return false;
}

return kNoError;
return true;
}


Expand All @@ -330,8 +321,7 @@ class ZCtx : public AsyncWrap {
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());

node_zlib_error error = CheckError(ctx);
if (error == kFailed)
if (!CheckError(ctx))
return;

Local<Integer> avail_out = Integer::New(env->isolate(),
Expand All @@ -345,11 +335,6 @@ class ZCtx : public AsyncWrap {
Local<Value> args[2] = { avail_in, avail_out };
ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args);

if (error == kWritePending) {
ZCtx::Error(ctx, "Zlib error");
return;
}

ctx->Unref();
if (ctx->pending_close_)
ctx->Close();
Expand Down Expand Up @@ -554,12 +539,10 @@ class ZCtx : public AsyncWrap {
switch (ctx->mode_) {
case DEFLATE:
case DEFLATERAW:
case GZIP:
ctx->err_ = deflateReset(&ctx->strm_);
break;
case INFLATE:
case INFLATERAW:
case GUNZIP:
ctx->err_ = inflateReset(&ctx->strm_);
break;
default:
Expand Down
31 changes: 31 additions & 0 deletions test/parallel/test-v8-features.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var common = require('../common');
var assert = require('assert');
var spawnSync = require('child_process').spawnSync;
var v8 = require('v8');

// --harmony_classes implies --harmony_scoping; ensure that scoping still works
// when classes are disabled.
assert.throws(function() { eval('"use strict"; class C {}'); }, SyntaxError);
eval('"use strict"; let x = 42'); // Should not throw.
eval('"use strict"; const y = 42'); // Should not throw.

v8.setFlagsFromString('--harmony_classes');
eval('"use strict"; class C {}'); // Should not throw.
eval('"use strict"; let x = 42'); // Should not throw.
eval('"use strict"; const y = 42'); // Should not throw.

// Verify that the --harmony_classes flag unlocks classes again.
var args = ['--harmony_classes', '--use_strict', '-p', 'class C {}'];
var cp = spawnSync(process.execPath, args);
assert.equal(cp.status, 0);
assert.equal(cp.stdout.toString('utf8').trim(), '[Function: C]');

// Now do the same for --harmony_object_literals.
assert.throws(function() { eval('({ f() {} })'); }, SyntaxError);
v8.setFlagsFromString('--harmony_object_literals');
eval('({ f() {} })');

var args = ['--harmony_object_literals', '-p', '({ f() {} })'];
var cp = spawnSync(process.execPath, args);
assert.equal(cp.status, 0);
assert.equal(cp.stdout.toString('utf8').trim(), '{ f: [Function: f] }');
83 changes: 0 additions & 83 deletions test/parallel/test-zlib-from-multiple-gzip-with-garbage.js

This file was deleted.

74 changes: 0 additions & 74 deletions test/parallel/test-zlib-from-multiple-gzip.js

This file was deleted.

Loading